Skip to content

Commit

Permalink
Merge branch 'roulette' into maintainer
Browse files Browse the repository at this point in the history
  • Loading branch information
lukego committed Oct 8, 2016
2 parents c3224bb + b0a75b4 commit 96cfbb3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions bench/roulette.lua
Original file line number Diff line number Diff line change
@@ -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)))

0 comments on commit 96cfbb3

Please sign in to comment.