Skip to content

Commit

Permalink
Require profiling libraries only when they are strictly necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzedge committed Feb 19, 2018
1 parent cf7551c commit f5a9290
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,7 @@

## 1.0.3 [compare][compare_v1_0_2_and_master]

- Require profiling libraries only when they are strictly necessary by [@gonzedge][github_user_gonzedge]
- Add `#compress` method to public API by [@gonzedge][github_user_gonzedge]
- Refactor trie integration tests by [@gonzedge][github_user_gonzedge]
- Refactor serializer tests by [@gonzedge][github_user_gonzedge]
Expand Down
7 changes: 2 additions & 5 deletions tasks/performance.rb
@@ -1,9 +1,4 @@
require 'fileutils'
require 'benchmark'
require 'ruby-prof'
require 'memory_profiler'
require 'benchmark/ips'
require 'flamegraph'

%w{
configuration directory report task
Expand All @@ -12,6 +7,8 @@
end

task :performance, [:type, :method] => 'performance:directory' do |t, args|
require 'benchmark/ips'

configuration = Performance::Configuration.new
task = Performance::Task.new configuration
task.run args
Expand Down
1 change: 1 addition & 0 deletions tasks/performance/reporters/benchmark.rb
Expand Up @@ -25,6 +25,7 @@ def do_report iterations, params
def measure iterations, param
result = nil

require 'benchmark'
measure = ::Benchmark.measure do
iterations.times do
result = yield param
Expand Down
1 change: 1 addition & 0 deletions tasks/performance/reporters/call_tree_profile.rb
Expand Up @@ -10,6 +10,7 @@ def initialize dirname
def do_report iterations, params
FileUtils.mkdir_p dirpath

require 'ruby-prof'
result = RubyProf.profile merge_fibers: true do
params.each do |param|
iterations.times do
Expand Down
1 change: 1 addition & 0 deletions tasks/performance/reporters/flamegraph.rb
Expand Up @@ -10,6 +10,7 @@ def initialize filename
def do_report iterations, params
FileUtils.mkdir_p dirpath

require 'flamegraph'
result = ::Flamegraph.generate filepath do
params.each do |param|
iterations.times do
Expand Down
1 change: 1 addition & 0 deletions tasks/performance/reporters/memory_profile.rb
Expand Up @@ -10,6 +10,7 @@ def initialize filename
def do_report iterations, params
FileUtils.mkdir_p dirpath

require 'memory_profiler'
result = MemoryProfiler.report allow_files: 'lib/rambling/trie', ignore_files: 'lib/rambling/trie/tasks' do
with_gc_stats "performing #{filename}" do
params.each do |param|
Expand Down

0 comments on commit f5a9290

Please sign in to comment.