factory_girl-benchmark 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f457a07c3ebf1a14034f8b1958303b38d216ce7c
4
- data.tar.gz: b0380f100da4158d2e7a76d6a488427e232d0fbe
3
+ metadata.gz: 1e921586226b4d385dfb4ce120bd579313c2faa9
4
+ data.tar.gz: b701edb2e424d8befa48a334cdf9b2d144d0fcee
5
5
  SHA512:
6
- metadata.gz: 54b5d68e70a49dfdc70fddf22a6126685f611bcf3722347b47741f10dd00da9769ac4a294e39b0425c4502c7e889fca99e3aff1f852f25e3cc90009a1f40aa02
7
- data.tar.gz: 07f3ce177c397553b51e88cd6a70996ef502f2923b2c0210d71cadb96abf9b8a2985dadf6159ca1430af490181263efcd46717073c6682c44cb66b343c14ed97
6
+ metadata.gz: 28d6bf28228b1c5f3d0a4618f07d8affd913cdd236dce44727667b5addf71b8e4f6334f6df7a488c1f2d043de0de4d0957a45c48802749c1b53c677a3dee3b58
7
+ data.tar.gz: 949ed7a84262e9e773f3a2dfb31d8984c4babe2e5cbdea18112de6b74a429fff77bce0bd547c07f996070754b33cba25f28efb01af03298d529e8dadf03cebee
data/README.md CHANGED
@@ -5,7 +5,7 @@ benchmark your top-level factory_girl factories
5
5
  ## Installation
6
6
 
7
7
  ```rb
8
- gem 'factory_girl-benchmark'
8
+ gem 'factory_girl-benchmark', require: false
9
9
  ```
10
10
 
11
11
  ## Usage
@@ -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(20).map {|h| puts "\t#{h}".colorize(color)}
95
+ arr.first(max).map {|h| puts "\t#{h}".colorize(color)}
96
96
  puts
97
97
  end
98
98
 
@@ -1,5 +1,5 @@
1
1
  module FactoryGirl
2
2
  module Benchmark
3
- VERSION = '0.0.1'
3
+ VERSION = '0.1.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factory_girl-benchmark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Bodah