defmodule Rollex.Timings do def time() do {time, _result} = :timer.tc(Rollex.Timings, :same_string_compute, [100]) IO.puts time {time, _result} = :timer.tc(Rollex.Timings, :with_dice, [100]) IO.puts time {time, _result} = :timer.tc(Rollex.Timings, :simple, [100]) IO.puts time end def simple(times) do for _x <- 1..times do Rollex.roll("0.5") end end def same_string_compute(times) do for _x <- 1..times do Rollex.roll("(1-(33+(44-(3.45+(1.23+(8.1-(0.5)))))))+(1-(33+(44-(3.45+(1.23+(8.1-(0.5)))))))+(1-(33+(44-(3.45+(1.23+(8.1-(0.5)))))))") end end def with_dice(times) do for _x <- 1..times do Rollex.roll("400d33+300d5-515d1000") end end end