bnchmrkr 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/bnchmrkr.rb +22 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81543d9e532bbc61a99896b8019287a145dcd15b
|
4
|
+
data.tar.gz: 9272a8d8e1764d176f4e5b8d8e049a6e78f6c181
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8ac397da4feaa130d033aa0d014faef00cc256bbbb5646f8f3b503a9fad1ac71b0f1c5e58f22c180e9009c25aadeda5e8e80c142a74455eeec0ab243b13a176
|
7
|
+
data.tar.gz: 717623a9113bb53a82ad04fdfd10271034cf13643eaae0b713405c3e47cfb8519dc471baeed90f9befa39939994c1dc224ae55c48cc6cbb5c266aaf820eddb53
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/bnchmrkr.rb
CHANGED
@@ -179,25 +179,39 @@ class Bnchmrkr
|
|
179
179
|
self.results[name] << measure
|
180
180
|
end
|
181
181
|
|
182
|
+
# +mode_precision+ Fixnum indicating number of digits to consider during mode calculation, default to 0, which will use all signal
|
182
183
|
# from existing results, generate some statistics per lambda type
|
183
|
-
def calculate_per_lambda
|
184
|
+
def calculate_per_lambda(mode_precision = 0)
|
184
185
|
hash = Hash.new
|
185
186
|
|
186
|
-
# TODO come up with way to not recompute unless contents have changed
|
187
|
+
# TODO come up with way to not recompute unless contents have changed -- https://github.com/chorankates/bnchmrkr/issues/3
|
187
188
|
|
188
189
|
@results.each_pair do |name, measures|
|
189
|
-
|
190
|
+
hash[name] = Hash.new
|
191
|
+
frequency_hash = Hash.new(0)
|
192
|
+
mode_candidate = { :frequency => 1, :operand => nil }
|
193
|
+
total = 0
|
190
194
|
|
191
|
-
|
195
|
+
sorted = measures.sort { |a,b| a.real <=> b.real }
|
196
|
+
measures.each do |measure|
|
197
|
+
operand = mode_precision.equal?(0) ? measure.real : measure.real.round(mode_precision)
|
198
|
+
frequency_hash[operand] += 1
|
199
|
+
|
200
|
+
# i hate maths
|
201
|
+
if frequency_hash[operand] > mode_candidate[:frequency] and frequency_hash[operand] > 1
|
202
|
+
mode_candidate[:frequency] = frequency_hash[operand]
|
203
|
+
mode_candidate[:operand] = operand
|
204
|
+
end
|
205
|
+
end
|
192
206
|
|
193
|
-
total = 0
|
194
|
-
# TODO add the mode
|
195
207
|
measures.collect {|m| total += m.real }
|
196
208
|
hash[name][:fastest] = sorted.first.real
|
197
209
|
hash[name][:slowest] = sorted.last.real
|
198
|
-
hash[name][:mean] = sprintf('%5f', total / sorted.size)
|
210
|
+
hash[name][:mean] = sprintf('%5f', total / sorted.size).to_f
|
199
211
|
hash[name][:median] = sorted[(sorted.size / 2)].real
|
200
|
-
|
212
|
+
# TODO need to handle the rare case that we have multiple modes -- https://github.com/chorankates/bnchmrkr/issues/4
|
213
|
+
hash[name][:mode] = mode_candidate[:operand] # collect key name with highest value
|
214
|
+
hash[name][:total] = sprintf('%5f', total).to_f
|
201
215
|
end
|
202
216
|
|
203
217
|
hash
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bnchmrkr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Conor Horan-Kates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|