TechScript provides benchmarking utilities to measure execution performance and track speed regressions.
Use the benchmark module to run functions and measure elapsed times:
use benchmark
# Define a function to benchmark
do compute_factorial()
val = 1
for i in 1..100000
val = val * i
end
end
# Run the benchmark: benchmark.run(name, iterations, function)
benchmark.run("Factorial loop 100k", 100, compute_factorial)
Execute your benchmark script:
tech run perf.txsOutput:
Benchmark: Factorial loop 100k
Iterations: 100
Mean execution time: 2.15 ms
Min time: 2.01 ms
Max time: 2.45 ms
You can also benchmark standard code snippets directly from the CLI:
tech benchmark "say 10 + 10" --iterations 1000This runs the VM in isolation to output microsecond-accurate telemetry statistics.