perf_check 0.6.1 → 0.7.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: ff2a870f80503656b1009c03e5d9f70863816e07
4
- data.tar.gz: 2e4be555c0c5e49ae514e5ca189e2d70fb393f3f
3
+ metadata.gz: 6733d94e8539da19fc3c00d781e5fe6e530e90f5
4
+ data.tar.gz: 3b2e5e2f196b87ffb7a875f5addb789bc459c83d
5
5
  SHA512:
6
- metadata.gz: 5fd105fa1395240e9bd01a237f8fc0635770974e7d8b19198af349cbf76423c3fabe4f9b72f4f324156598c5ec162ea314f3b91df94eacb6e32d6ffe361102b3
7
- data.tar.gz: a203a96de2dffc781725bc0d5c749620ddea759e3c09cfc97a249acf5a79d4b541d8ccbb1a2a5fb4c7e869520ed70ca8df1ad1a5eab5fcd54dd9582550b18cfc
6
+ metadata.gz: a7a0f4b87e397f962703a4767210d07d301b565f69b2eba7d2f993e5e7c14813ec371d176159025d86f36ba7cfabd116692d3079e544099b5ccb8644d1147706
7
+ data.tar.gz: ea20e68e17347b6da5380fa85132aab377b30fc4abfc192db3924028fd088b06e2b0bebb2bebcb61b102d2535091236a06ac08efb34bddfbb014e0bee1bed2db
@@ -53,24 +53,28 @@ class PerfCheck
53
53
  end
54
54
  end
55
55
 
56
- opts.on('--verify-responses',
57
- 'Check whether there is a diff between the responses of this and the reference branch') do
58
- options.verify_responses = true
59
- end
60
-
61
56
  opts.on('--brief', '-b') do
62
57
  options.brief = true
63
58
  end
64
59
 
60
+ opts.on('--verify-no-diff',
61
+ 'Check whether there is a diff between the responses of this and the reference branch') do
62
+ options.verify_no_diff = true
63
+ end
64
+
65
65
  opts.on('--diff') do
66
66
  options.diff = true
67
67
  options.brief = true
68
- options.verify_responses = true
68
+ options.verify_no_diff = true
69
69
  options.number_of_requests = 1
70
70
  end
71
71
 
72
- opts.separator ''
73
- opts.separator <<EOF
72
+ opts.on("--diff-option OPT") do |opt|
73
+ options.diff_options << opt
74
+ end
75
+
76
+ opts.separator ''
77
+ opts.separator <<EOF
74
78
  Usage examples:
75
79
  Benchmark PostController#index against master
76
80
  perf_check /user/45/posts
@@ -84,7 +88,7 @@ Usage examples:
84
88
  perf_check /user/45/posts -r HEAD
85
89
 
86
90
  Benchmark and diff the output against master
87
- perf_check /user/45/posts --verify-responses
91
+ perf_check /user/45/posts --verify-no-diff
88
92
 
89
93
  Just diff the output on your branch with master
90
94
  perf_check /user/45/posts --diff
@@ -96,9 +100,4 @@ EOF
96
100
  opts.separator ''
97
101
  end
98
102
  end
99
-
100
- def diff_options
101
- @diff_options ||=
102
- ['-U3', '--ignore-matching-lines=/mini-profiler-resources/includes.js']
103
- end
104
103
  end
@@ -20,7 +20,7 @@ class PerfCheck
20
20
  puts && next if test.reference_profiles.empty?
21
21
 
22
22
  print(sprintf(' (%+5.1fms)', test.latency_difference).bold)
23
- print_diff_results(test.response_diff) if options.verify_responses
23
+ print_diff_results(test.response_diff) if options.verify_no_diff
24
24
  puts
25
25
  end
26
26
  end
@@ -63,7 +63,7 @@ class PerfCheck
63
63
  puts("your branch: ".rjust(15)+ "#{this_latency}")
64
64
  puts(("change: ".rjust(15) + "#{formatted_change}").bold.send(color))
65
65
 
66
- print_diff_results(test.response_diff) if options.verify_responses
66
+ print_diff_results(test.response_diff) if options.verify_no_diff
67
67
  end
68
68
  end
69
69
  end
@@ -103,7 +103,7 @@ class PerfCheck
103
103
 
104
104
  def start
105
105
  ENV['PERF_CHECK'] = '1'
106
- if perf_check.options.verify_responses
106
+ if perf_check.options.verify_no_diff
107
107
  ENV['PERF_CHECK_VERIFICATION'] = '1'
108
108
  end
109
109
  unless perf_check.options.caching
@@ -25,7 +25,7 @@ class PerfCheck
25
25
  profile = issue_request(server, options)
26
26
  next if i.zero? # first request just warms up the server
27
27
 
28
- if options.verify_responses && i == 1
28
+ if options.verify_no_diff && i == 1
29
29
  response_for_comparison(profile.response_body)
30
30
  end
31
31
 
@@ -82,15 +82,14 @@ class PerfCheck
82
82
  def response_diff
83
83
  diff = Diffy::Diff.new(reference_response, this_response,
84
84
  include_diff_info: true,
85
- diff: perf_check.diff_options)
85
+ diff: perf_check.options.diff_options)
86
86
  if diff.to_s.empty?
87
87
  OpenStruct.new(:changed? => false)
88
88
  else
89
89
  FileUtils.mkdir_p("#{perf_check.app_root}/tmp/perf_check/diffs")
90
90
  file = `mktemp -u "#{perf_check.app_root}/tmp/perf_check/diffs/XXXXXXXXX"`.strip
91
- [:text, :html].each do |format|
92
- ext = {:text => 'diff', :html => 'html'}[format]
93
- File.open("#{file}.#{ext}", 'w'){ |f| f.write(diff.to_s(format)) }
91
+ File.open("#{file}.diff", "w") do |f|
92
+ f.write(diff.to_s(:text).lines[2..-1].join)
94
93
  end
95
94
  OpenStruct.new(:changed? => true, :file => "#{file}.diff")
96
95
  end
data/lib/perf_check.rb CHANGED
@@ -22,7 +22,11 @@ class PerfCheck
22
22
  cookie: nil,
23
23
  headers: {},
24
24
  http_statuses: [200],
25
- verify_responses: false,
25
+ verify_no_diff: false,
26
+ diff: false,
27
+ diff_options: ['-U3',
28
+ '--ignore-matching-lines=/mini-profiler-resources/includes.js'],
29
+ brief: false,
26
30
  caching: true,
27
31
  json: false
28
32
  )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perf_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - rubytune
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: colorize
29
43
  requirement: !ruby/object:Gem::Requirement