Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

About

No description, website, or topics provided.

Resources

License

Releases

No releases published

Packages

No packages published