From 42aef306a95563bdd60e8ded1974e4b1e0d4c714 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Sun, 12 Apr 2026 08:40:28 +1000 Subject: [PATCH] Added a lua benchmark for performance comparisons --- tests/benchmarks/fizzbuzz.lua | 17 +++++++++++++++++ tests/benchmarks/fizzbuzz.toy | 23 +++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/benchmarks/fizzbuzz.lua create mode 100644 tests/benchmarks/fizzbuzz.toy diff --git a/tests/benchmarks/fizzbuzz.lua b/tests/benchmarks/fizzbuzz.lua new file mode 100644 index 0000000..011322e --- /dev/null +++ b/tests/benchmarks/fizzbuzz.lua @@ -0,0 +1,17 @@ +for counter = 1, 10000 do + local result = "" + + if counter % 3 == 0 then + result = result .. "fizz" + end + + if counter % 5 == 0 then + result = result .. "buzz" + end + + if result ~= "" then + print(result) + else + print(counter) + end +end diff --git a/tests/benchmarks/fizzbuzz.toy b/tests/benchmarks/fizzbuzz.toy new file mode 100644 index 0000000..816cd47 --- /dev/null +++ b/tests/benchmarks/fizzbuzz.toy @@ -0,0 +1,23 @@ +//standard example, using 'while' instead of 'for', because it's not ready yet + +var counter: int = 0; + +while (++counter <= 10_000) { + var result: string = ""; + + if (counter % 3 == 0) { + result = result .. "fizz"; + } + + if (counter % 5 == 0) { + result = result .. "buzz"; + } + + //finally + if (result != "") { + print result; + } + else { + print counter; + } +}