Skip to content

Commit

Permalink
Update benchmark timing
Browse files Browse the repository at this point in the history
Use erlang:monotonic_time instead of os:timestamp.
  • Loading branch information
tomas-abrahamsson committed Nov 18, 2023
1 parent edda100 commit d87ca81
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions benchmarks/proto-bench
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,13 @@ iterate_until_elapsed_2(NumIterations, MaxDuration, Action) ->

time_action(NumIterations, Action) ->
garbage_collect(),
T0 = os:timestamp(),
T0 = erlang:monotonic_time(),
iterate_action(NumIterations, Action),
T1 = os:timestamp(),
timer:now_diff(T1, T0) / 1000000.
T1 = erlang:monotonic_time(),
to_seconds(T1 - T0, native).

to_seconds(Time, InUnit) ->
erlang:convert_time_unit(Time, InUnit, microsecond) / 1000000.

iterate_action(N, Action) when N > 0 ->
Action(),
Expand Down

0 comments on commit d87ca81

Please sign in to comment.