From b0a75b45a6d99e73472906cc668d1c7804f5147b Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Sat, 8 Oct 2016 16:32:12 +0000 Subject: [PATCH] Added bench/roulette.lua This benchmark exhibits non-deterministic performance. --- bench/roulette.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 bench/roulette.lua diff --git a/bench/roulette.lua b/bench/roulette.lua new file mode 100644 index 0000000000..77c9fbb2b5 --- /dev/null +++ b/bench/roulette.lua @@ -0,0 +1,20 @@ +-- Russian Roulette simulator +-- This benchmark includes randomness from an external source that can +-- produce non-deterministic performance. +-- See https://github.com/LuaJIT/LuaJIT/issues/218 + +math.randomseed(os.time()) + +local population = 100e6 +local live = 0 +local die = 0 + +for i = 1, population do + if math.random(6) == 6 then + die = die + 1 + else + live = live + 1 + end +end + +print(("Survived %d/%d (%.3f%%)"):format(live, population, live*100/(live+die)))