No release in over 3 years
Low commit activity in last 3 years
Sampling and measurement of execution cycles
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

diagnostics-sample

Sampling and measurement of execution cycles

Synopsis

To measure a single execution cycle:

result = Diagnostics::Sample.() do
  some_method(...)
end

result.time_milliseconds
# => 11.1

To measure many execution cycles (i.e. iterations):

result = Diagnostics::Sample.(1000) do
  some_method(...)
end

# Total elapsed time across all cycles
result.time_milliseconds
# => 11111.11

# Average elapsed time across all cycles
result.mean_cycle_time_milliseconds
# => 11.1

# Cycles per second
result.cycle_frequency
# => 111.1

A number of warmup cycles may be specified:

Diagnostics::Sample.(1000, warmup_cycles: 10) do
  some_method(...)
end

The garbage collector by default is disabled during the measurement. It can be enabled optionally:

Diagnostics::Sample.(1000, gc: true) do
  some_method(...)
end

License

The diagnostics-sample library is released under the MIT License.