mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Added a lua benchmark for performance comparisons
This commit is contained in:
17
tests/benchmarks/fizzbuzz.lua
Normal file
17
tests/benchmarks/fizzbuzz.lua
Normal file
@@ -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
|
||||||
23
tests/benchmarks/fizzbuzz.toy
Normal file
23
tests/benchmarks/fizzbuzz.toy
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user