We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents c3224bb + b0a75b4 commit 96cfbb3Copy full SHA for 96cfbb3
bench/roulette.lua
@@ -0,0 +1,20 @@
1
+-- Russian Roulette simulator
2
+-- This benchmark includes randomness from an external source that can
3
+-- produce non-deterministic performance.
4
+-- See https://github.com/LuaJIT/LuaJIT/issues/218
5
+
6
+math.randomseed(os.time())
7
8
+local population = 100e6
9
+local live = 0
10
+local die = 0
11
12
+for i = 1, population do
13
+ if math.random(6) == 6 then
14
+ die = die + 1
15
+ else
16
+ live = live + 1
17
+ end
18
+end
19
20
+print(("Survived %d/%d (%.3f%%)"):format(live, population, live*100/(live+die)))
0 commit comments