Description
Easily calculates the time running (elapsed time) from one location to another inside your code and reports statistics. It helps you improve your code and find out which part of your code is consuming more time.
Timify alternatives and similar gems
Based on the "Testing" category.
Alternatively, view timify alternatives based on common mentions on social networks and blogs.
-
vcr
Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests. -
minitest
minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking. -
timecop
A gem providing "time travel", "time freezing", and "time acceleration" capabilities, making it simple to test time-dependent code. It provides a unified method to mock Time.now, Date.today, and DateTime.now in a single call. -
Spork
A DRb server for testing frameworks (RSpec / Cucumber currently) that forks before each run to ensure a clean testing state. -
Konacha
Test your Rails application's JavaScript with the mocha test framework and chai assertion library -
Fabrication
DISCONTINUED. This project has moved to GitLab! Please check there for the latest updates. -
Knapsack
Knapsack splits tests evenly across parallel CI nodes to run fast CI build and save you time. -
ActiveMocker
Generate mocks from ActiveRecord models for unit tests that run fast because they don’t need to load Rails or a database. -
Wrong
Wrong provides a general assert method that takes a predicate block. Assertion failure messages are rich in detail. -
RR
RR is a test double framework that features a rich selection of double techniques and a terse syntax. ⛺ -
turbo_tests
Run RSpec tests on multiple cores. Like parallel_tests but with incremental summarized output. Originally extracted from the Discourse and Rubygems source code. -
RSpecTracer
RSpec Tracer is a specs dependency analyzer, flaky tests detector, tests accelerator, and coverage reporter tool for RSpec. It maintains a list of files for each test, enabling itself to skip tests in the subsequent runs if none of the dependent files are changed. It uses Ruby's built-in coverage library to keep track of the coverage for each test.
Scout Monitoring - Performance metrics and, now, Logs Management Monitoring with Scout Monitoring
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Timify or a related project?
README
Timify
Easily calculates the time running (elapsed time) from one location to another inside your code and reports statistics. It helps you improve your code and find out which part of your code is consuming more time.
Installation
Add this line to your application's Gemfile:
gem 'timify'
And then execute:
$ bundle
Or install it yourself as:
$ gem install timify
Usage
initialize
You need to supply a name for your Timify instance. You can have all the Timify instances you want at the same time.
t = Timify.new :create_user
t.show = false
t.min_time_to_show = 0.5
min_time_to_show: minimum time to show the elapsed time when calling 'add' method
show: print out results on screen
you can supply those parameters also:
t = Timify.new :create_user, show: true, min_time_to_show: 0.3
The scopes of the instances can be even global so you can measure the elapsed times between different classes, methods... on your code.
You can disable the timify counter whenever you want using the status attritute that admits :on or :off, by default is set to :on
t.status = :off
add
Adds a new point to count the elapsed time. It will count from the last 'add' call or Timify creation in case of the first 'add'.
You can supply a label that will summarize all the ones with the same label
The output of this method will be the time elapsed in seconds (float).
Examples:
t=Timify.new :example
t.add; run_sqls; t.add :database
t.add
#some processes
t.add
#some processes
send_email_alert(t.totals[:message]) if t.add > 0.2
#some processes
do_log(t.totals[:message]) if t.add > 0.5
totals
Returns all data for this instance
In case json parameter supplied as true, the output will be in json format instead of a hash.
The output hash contains:
name: (String) name given for this instance'
total_time: (float) total elapsed time from initialization to last 'add' call
started: (Time)
finished: (Time)
message: (String) a printable friendly message giving all information
locations, labels, ranges: (Hash) the resultant hash contains:
secs: (float) number of seconds
percent: (integer) percentage in reference to the total time
count: (integer) number of times
locations: (Hash) All summary data by location where was called
labels: (Hash) All summary data by label given on 'add' method
ranges: (Hash) All summary data by ranges where was called, from last 'add' call to current 'add' call
Example of output:
{ :name=>:add_customer_wrong,
:total_time=>4.461446,
:started=>2017-11-06 16:10:53 +0000,
:finished=>2017-11-06 16:10:57 +0000,
:locations=>{
"/add_customer.rb:509"=>{:secs=>0.0, :percent=>0, :count=>1},
"/add_customer.rb:529"=>{:secs=>0.008001, :percent=>0, :count=>1},
"/add_customer.rb:532"=>{:secs=>0.212021, :percent=>5, :count=>1},
"/add_customer.rb:569"=>{:secs=>0.006001, :percent=>0, :count=>1},
"/add_customer.rb:581"=>{:secs=>0.446045, :percent=>10, :count=>1},
"/add_customer.rb:583"=>{:secs=>3.789378, :percent=>85, :count=>1},
"/add_customer.rb:585"=>{:secs=>0.0, :percent=>0, :count=>1},
"/add_customer.rb:587"=>{:secs=>0.0, :percent=>0, :count=>1},
"/add_customer.rb:595"=>{:secs=>0.0, :percent=>0, :count=>1},
"/add_customer.rb:603"=>{:secs=>0.0, :percent=>0, :count=>1},
"/add_customer.rb:612"=>{:secs=>0.0, :percent=>0, :count=>1},
"/add_customer.rb:617"=>{:secs=>0.0, :percent=>0, :count=>1}
},
:labels=>{
:database_access=>{:secs=>4,447444, :percent=>99, :count=>3},
:checkouts=>{:secs=>0.0, :percent=>0, :count=>2},
},
:ranges=>{
"/add_customer.rb:509 - /add_customer.rb:529"=>{:secs=>0.008001, :percent=>0, :count=>1},
"/add_customer.rb:529 - /add_customer.rb:532"=>{:secs=>0.212021, :percent=>5, :count=>1},
"/add_customer.rb:532 - /add_customer.rb:569"=>{:secs=>0.006001, :percent=>0, :count=>1},
"/add_customer.rb:569 - /add_customer.rb:581"=>{:secs=>0.446045, :percent=>10, :count=>1},
"/add_customer.rb:581 - /add_customer.rb:583"=>{:secs=>3.789378, :percent=>85, :count=>1},
"/add_customer.rb:583 - /add_customer.rb:585"=>{:secs=>0.0, :percent=>0, :count=>1},
"/add_customer.rb:585 - /add_customer.rb:587"=>{:secs=>0.0, :percent=>0, :count=>1},
"/add_customer.rb:587 - /add_customer.rb:595"=>{:secs=>0.0, :percent=>0, :count=>1},
"/add_customer.rb:595 - /add_customer.rb:603"=>{:secs=>0.0, :percent=>0, :count=>1},
"/add_customer.rb:603 - /add_customer.rb:612"=>{:secs=>0.0, :percent=>0, :count=>1},
"/add_customer.rb:612 - /add_customer.rb:617"=>{:secs=>0.0, :percent=>0, :count=>1}
},
:message=>"
Total time <add_customer_wrong>:4.46
Total time by location:
/add_customer.rb:509: 0.0 (0%) #1
/add_customer.rb:529: 0.01 (0%) #1
/add_customer.rb:532: 0.21 (5%) #1
/add_customer.rb:569: 0.01 (0%) #1
/add_customer.rb:581: 0.45 (10%) #1
/add_customer.rb:583: 3.79 (85%) #1
/add_customer.rb:585: 0.0 (0%) #1
/add_customer.rb:587: 0.0 (0%) #1
/add_customer.rb:595: 0.0 (0%) #1
/add_customer.rb:603: 0.0 (0%) #1
/add_customer.rb:612: 0.0 (0%) #1
/add_customer.rb:617: 0.0 (0%) #1
Total time by label:
database_access: 4.45 (99%) #3
checkouts: 0.0 (0%) #2
Total time by range:
/add_customer.rb:509 - /add_customer.rb:529: 0.01 (0%) #1
/add_customer.rb:529 - /add_customer.rb:532: 0.21 (5%) #1
/add_customer.rb:532 - /add_customer.rb:569: 0.01 (0%) #1
/add_customer.rb:569 - /add_customer.rb:581: 0.45 (10%) #1
/add_customer.rb:581 - /add_customer.rb:583: 3.79 (85%) #1
/add_customer.rb:583 - /add_customer.rb:585: 0.0 (0%) #1
/add_customer.rb:585 - /add_customer.rb:587: 0.0 (0%) #1
/add_customer.rb:587 - /add_customer.rb:595: 0.0 (0%) #1
/add_customer.rb:595 - /add_customer.rb:603: 0.0 (0%) #1
/add_customer.rb:603 - /add_customer.rb:612: 0.0 (0%) #1
/add_customer.rb:612 - /add_customer.rb:617: 0.0 (0%) #1
"
}
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/marioruiz/timify.
License
The gem is available as open source under the terms of the MIT License.
*Note that all licence references and agreements mentioned in the Timify README section above
are relevant to that project's source code only.