Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
This gem is to help debug slow portions of the code. When RubyProf isn't enough and you need to get deeper into the code base this is the solution. The output will look like this:
1.8040 └── search
1.0554 └── 1st
0.0033 └── config
0.0001 └── 1.1
0.6579 └── 1.2
0.0087 └── 1.2.1
0.0075 └── 1.2.2
0.6416 └── set_custom_variable
0.3941 └── 1.3
0.3938 └── 1.3.1
0.0002 └── 1.3.2
0.1487 └── 2nd
0.5999 └── 3rd
0.0133 └── presenter
0.0023 └── serialize
0.5843 └── respond_to
0.5842 └── render
0.1506 └── presenter.view
Add this line to your application's Gemfile:
gem 'debug_timer'
And then execute:
$ bundle
Or install it yourself as:
$ gem install debug_timer
You can add your logger instance if you want:
# Straight assignment
DebugTimer.logger = Logger.new('asdf')
DebugTimer.object_allocations = true
# or config assignment
DebugTimer.config do |config|
config.logger = Logger.new('asdf')
config.object_allocations = true
end
To use DebugTimer simply wrap the code you want to time in a block.
DebugTimer.start('search function') do
Search.searchysearchsearch('search query')
SomeOtherCode.DoWhatever?
IhazFunction?
end
When you run that piece of code you will see in your log. The number on the left is the time that block of code took to run
1.8040 └── search function
You can nest blocks within blocks.
DebugTimer.start('search function') do
Search.searchysearchsearch('search query')
DebugTimer.start('Some other code') do
SomeOtherCode.DoWhatever?
end
IhazFunction?
end
And the output will look like:
1.8040 └── search function
1.0554 └── Some other code
# Enable it
DebugTimer.object_allocations = true
# Time
DebugTimer.start('search function') do
Search.todo('in here')
end
And the output will look like:
INFO -- : 0.0036 | T_OBJECT: 1 | FREE: -91 └── search function
The second pipe is the is ObjectSpace's T_OBJECT change
The third pipe is the ObjectSpace's :FREE change
> rake
Finished in 0.00926 seconds (files took 0.11604 seconds to load)
5 examples, 0 failures
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that debug_timer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.