Implement a new `benchmark` standard library module providing high-precision nanosecond timing functions (`bench_start`, `bench_end`, `bench_format`, `bench_format_auto`, `bench_reset`). Add a dedicated `memory.c` module with runtime memory safety validation, including stack overflow detection, local variable limit enforcement, and high-water mark tracking. Integrate memory checks into the interpreter's variable declaration path in `src/interpreter.c` and initialize the memory subsystem in `src/main.c`. Update the build system (`Makefile`) to compile the new source files and include benchmark tests in the test suite. Extend `TUTORIAL.md` with comprehensive documentation for the benchmarking API and random number functions (`rand`, `srand`, `rand_range`, `time`). Add two example scripts (`examples/bench.rc` and `examples/benchmark_demo.rc`) demonstrating performance measurement of recursive Fibonacci, loop iterations, list operations, string concatenation, object creation, and sorting algorithms.
21 lines
551 B
C
21 lines
551 B
C
#include "stdlib.h"
|
|
#include "string/string_stdlib.h"
|
|
#include "math/math_stdlib.h"
|
|
#include "io/file_stdlib.h"
|
|
#include "io/socket_stdlib.h"
|
|
#include "async/async_stdlib.h"
|
|
#include "constants/constants_stdlib.h"
|
|
#include "eval/eval_stdlib.h"
|
|
#include "benchmark/benchmark_stdlib.h"
|
|
|
|
void register_stdlib() {
|
|
register_string_stdlib();
|
|
register_math_stdlib();
|
|
register_file_stdlib();
|
|
register_socket_stdlib();
|
|
register_async_stdlib();
|
|
register_constants_stdlib();
|
|
register_eval_stdlib();
|
|
register_benchmark_stdlib();
|
|
}
|