Project

quicky

0.0
No commit activity in last 3 years
No release in over 3 years
Rest client wrapper that chooses best installed client.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Quicky if for easily timing chunks of code.

Getting Started

gem install quicky

Timing

Time anything

quicky = Quicky::Timer.new
quicky.time(:test1) do
  sleep 2
end

Call time over and over again and when ready for results:

# Print average duration for all :test1 timings
p quicky.results(:test1).duration
# Print total duration for all :test1 timings
p quicky.results(:test1).total_duration
# Print longest duration for all :test1 timings
p quicky.results(:test1).max_duration
# Print shortest duration for all :test1 timings
p quicky.results(:test1).min_duration

Time in a loop

Good for performance testing.

quicky = Quicky::Timer.new
# This will loop 10 times
quicky.loop(:test2, 10) do |i|
  puts 'sleeping'
  sleep 1
end

Or loop for X seconds:

# This will loop for 10 seconds
quicky.loop_for(:test3, 10) do |i|
  puts 'sleeping'
  sleep 0.5
end

Looping Options

  • warmup: X -- will throw out the first X results.

Results

You can get all the results with:

results =  quicky.results

Or a single result:

result = quicky.results(:test1)

Or turn it into a straight up hash:

hash = quicky.results.to_hash

And even marshal a hash back into a quicky objects:

results = Quicky::ResultsHash.from_hash(hash)

Or merge several results hashes together (if you were doing some tests in parallel):

results.merge!(other_results)