Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/diagnostics
test
.gitignore
Gemfile
MIT-License.txt
README.md
diagnostics-sample.gemspec
init.rb
install-gems.sh
library-symlinks.sh
load_path.rb
remove-lib-symlinks.sh
sketch.rb
symlink-lib.sh
test.rb

README.md

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.

You can’t perform that action at this time.