Add more benchmarks.

This commit is contained in:
Stephen Chung
2020-04-13 23:38:10 +08:00
parent f600e59401
commit 691541c176
4 changed files with 122 additions and 1 deletions

22
scripts/fibonacci.rhai Normal file
View File

@@ -0,0 +1,22 @@
// This script calculates the n-th Fibonacci number using a really dumb algorithm
// to test the speed of the scripting engine.
const target = 30;
let now = timestamp();
fn fib(n) {
if n < 2 {
n
} else {
fib(n-1) + fib(n-2)
}
}
print("Ready... Go!");
let result = fib(target);
print("Fibonacci number #" + target + " = " + result);
print("Finished. Run time = " + now.elapsed() + " seconds.");