Module: Benchmark::Ipsa
- Included in:
- Benchmark
- Defined in:
- lib/benchmark/ipsa.rb,
lib/benchmark/ipsa/version.rb
Constant Summary collapse
- VERSION =
"0.2.0"
Instance Method Summary collapse
- #allocations(x) ⇒ Object
- #ipsa(*args, &block) ⇒ Object
-
#rjust(label) ⇒ Object
stolen from benchmark-ips.
Instance Method Details
#allocations(x) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/benchmark/ipsa.rb', line 15 def allocations(x) return unless RUBY_VERSION >= "2.1.0" # MemoryProfiler needs 2.1. degrade to just ips puts "Allocations -------------------------------------" x.list.each do |entry| report = MemoryProfiler.report(&entry.action) $stdout.print(rjust(entry.label)) $stdout.printf("%10s alloc/ret %10s strings/ret\n", "#{report.total_allocated}/#{report.total_retained}", "#{report.strings_allocated.count}/#{report.strings_retained.count}") end end |
#ipsa(*args, &block) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/benchmark/ipsa.rb', line 7 def ipsa(*args, &block) Benchmark.ips(*args){ |x| block.call(x) allocations(x) } end |
#rjust(label) ⇒ Object
stolen from benchmark-ips
28 29 30 31 32 33 34 35 |
# File 'lib/benchmark/ipsa.rb', line 28 def rjust(label) #stolen from benchmark-ips label = label.to_s if label.size > 20 "#{label}\n#{' ' * 20}" else label.rjust(20) end end |