Class: YARD::Bench::Marks
- Inherits:
-
Object
- Object
- YARD::Bench::Marks
- Includes:
- MonkeyPatches
- Defined in:
- lib/dsl/bm_dsl.rb
Overview
Class to be included for benchmarking DSL.
It contains ‘Hash` of the following structure:
—
Defined Under Namespace
Classes: Mark
Class Method Summary collapse
-
.get(file, namespace, m) ⇒ Object
Returns benchmarks for the method given by spec (or the whole collection if none specified).
-
.⌚(clazz, m, iterations = 3) ⇒ Object
Measures the specified method of the class given.
-
.☑(clazz, m, iterations = 10) ⇒ Object
Measures the memory required for a method in KBytes.
Class Method Details
.get(file, namespace, m) ⇒ Object
Returns benchmarks for the method given by spec (or the whole collection if none specified)
114 115 116 117 |
# File 'lib/dsl/bm_dsl.rb', line 114 def self.get file, namespace, m load "#{file}" self.∈! Object.const_get(namespace), m end |
.⌚(clazz, m, iterations = 3) ⇒ Object
Measures the specified method of the class given
124 125 126 127 128 129 130 131 132 |
# File 'lib/dsl/bm_dsl.rb', line 124 def self.⌚ clazz, m, iterations = 3 # Let’ calculate the applicable range deg = (1..10).each { |v| break v if Benchmark.measure { (10**v).times {clazz.☏ m} }.total > 0.01 } (deg...deg+iterations).to_a.map { |d| 10**d }.map { |e| { e => Benchmark.measure { e.times {clazz.☏ m} }.total / STANDARD_TIME } } end |
.☑(clazz, m, iterations = 10) ⇒ Object
Measures the memory required for a method in KBytes. FIXME This is VERY inaccurate and lame.
139 140 141 142 143 144 145 |
# File 'lib/dsl/bm_dsl.rb', line 139 def self.☑ clazz, m, iterations = 10 kb = `ps -o rss= -p #{$$}`.to_i iterations.times.map { clazz.☏ m `ps -o rss= -p #{$$}`.to_i }.reduce(:+) / iterations - kb end |