Mach Modules Documentation
Lua Module API Documentation
Loading...
Searching...
No Matches
TestBenchmarkModule.lua File Reference

Go to the source code of this file.

Functions

TestBenchmarkModule calculate_sum (n)
 Calculate the sum of all integers from 1 to n.
TestBenchmarkModule fibonacci (n)
 Recursively compute the nth Fibonacci number.
TestBenchmarkModule process_data ()
 Process all stored numbers and return a doubled value array.

Function Documentation

◆ calculate_sum()

TestBenchmarkModule calculate_sum ( n )

Calculate the sum of all integers from 1 to n.

Parameters
n(number) The upper bound of the summation range (inclusive). Must be a non-negative integer
Returns
(number) The sum of all integers from 1 to n, or 0 if n is less than 1
Note
Documentation generated by AI on 2026-03-03

◆ fibonacci()

TestBenchmarkModule fibonacci ( n )

Recursively compute the nth Fibonacci number.

Uses naive recursive implementation without memoization. Performance degrades exponentially with larger values of n - avoid calling with n > 30 in performance-sensitive contexts. Base cases: fibonacci(0) = 0, fibonacci(1) = 1.

Parameters
n(number) The zero-based index into the Fibonacci sequence. Must be a non-negative integer
Returns
(number) The nth Fibonacci number
Warning
Recursive implementation with O(2^n) time complexity. Large values of n will cause significant delays or stack overflow
Note
Documentation generated by AI on 2026-03-03

◆ process_data()

TestBenchmarkModule process_data ( )

Process all stored numbers and return a doubled value array.

Iterates over the module's internal numbers table (populated at load time with squares of 1-100) and returns a new array where each value is doubled. The source data is read from TestBenchmarkModule.data.numbers and is not modified.

Returns
(table) Array of 100 numbers, each being double the corresponding value in TestBenchmarkModule.data.numbers
Note
Documentation generated by AI on 2026-03-03