factory_girl-benchmark 0.0.1 → 0.1.0
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/README.md +1 -1
- data/lib/factory_girl/benchmark.rb +9 -9
- data/lib/factory_girl/benchmark/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e921586226b4d385dfb4ce120bd579313c2faa9
|
4
|
+
data.tar.gz: b701edb2e424d8befa48a334cdf9b2d144d0fcee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28d6bf28228b1c5f3d0a4618f07d8affd913cdd236dce44727667b5addf71b8e4f6334f6df7a488c1f2d043de0de4d0957a45c48802749c1b53c677a3dee3b58
|
7
|
+
data.tar.gz: 949ed7a84262e9e773f3a2dfb31d8984c4babe2e5cbdea18112de6b74a429fff77bce0bd547c07f996070754b33cba25f28efb01af03298d529e8dadf03cebee
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ module FactoryGirl
|
|
18
18
|
|
19
19
|
class << self
|
20
20
|
# Example usage
|
21
|
-
def benchmark!
|
21
|
+
def benchmark!(max = 20)
|
22
22
|
# Install
|
23
23
|
FactoryGirl.singleton_class.prepend(FactoryGirl::Benchmark)
|
24
24
|
|
@@ -33,7 +33,7 @@ module FactoryGirl
|
|
33
33
|
end
|
34
34
|
|
35
35
|
# Report
|
36
|
-
FactoryGirl::Benchmark.report
|
36
|
+
FactoryGirl::Benchmark.report(max)
|
37
37
|
end
|
38
38
|
|
39
39
|
def benchmarks
|
@@ -64,22 +64,22 @@ module FactoryGirl
|
|
64
64
|
@benching = o
|
65
65
|
end
|
66
66
|
|
67
|
-
def report
|
67
|
+
def report(max = 20)
|
68
68
|
puts 'Most frequent'
|
69
69
|
r = benchmarks.reduce([]) do |m, (k, _)|
|
70
70
|
m << { key: k, count: benchmarks[k].size }
|
71
71
|
end.sort {|a,b| b[:count] <=> a[:count]}
|
72
|
-
print_report(r)
|
72
|
+
print_report(r, max)
|
73
73
|
|
74
74
|
puts 'Slowest instances'
|
75
75
|
r = benchmarks.each_value.to_a.flatten.sort {|a,b| b[:bm] <=> a[:bm]}
|
76
|
-
print_report(r)
|
76
|
+
print_report(r, max)
|
77
77
|
|
78
78
|
puts 'Slowest total'
|
79
79
|
r = benchmarks.reduce([]) do |m, (k, _)|
|
80
80
|
m << { key: k, count: benchmarks[k].size, total_time: benchmarks[k].reduce(0) {|sum, bm| sum + bm[:bm]} }
|
81
81
|
end.sort {|a,b| b[:total_time] <=> a[:total_time]}
|
82
|
-
print_report(r)
|
82
|
+
print_report(r, max)
|
83
83
|
|
84
84
|
puts 'Slowest average'
|
85
85
|
r = benchmarks.reduce([]) do |m, (k, _)|
|
@@ -87,12 +87,12 @@ module FactoryGirl
|
|
87
87
|
count = benchmarks[k].size
|
88
88
|
m << { key: k, avg: total_time.to_f/count, count: count, total_time: total_time }
|
89
89
|
end.sort {|a,b| b[:avg] <=> a[:avg]}
|
90
|
-
print_report(r)
|
90
|
+
print_report(r, max)
|
91
91
|
end
|
92
92
|
|
93
|
-
def print_report(arr)
|
93
|
+
def print_report(arr, max = 20)
|
94
94
|
require 'colorize'
|
95
|
-
arr.first(
|
95
|
+
arr.first(max).map {|h| puts "\t#{h}".colorize(color)}
|
96
96
|
puts
|
97
97
|
end
|
98
98
|
|