test-prof 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +6 -0
- data/lib/test_prof/cops/rspec/aggregate_failures.rb +2 -2
- data/lib/test_prof/event_prof/custom_events/factory_create.rb +5 -1
- data/lib/test_prof/event_prof/custom_events/sidekiq_inline.rb +5 -1
- data/lib/test_prof/event_prof/custom_events/sidekiq_jobs.rb +5 -1
- data/lib/test_prof/event_prof/rspec.rb +5 -3
- data/lib/test_prof/ext/array_bsearch_index.rb +15 -0
- data/lib/test_prof/ext/string_strip_heredoc.rb +15 -0
- data/lib/test_prof/factory_doctor.rb +2 -2
- data/lib/test_prof/factory_doctor/rspec.rb +4 -2
- data/lib/test_prof/factory_prof/printers/simple.rb +4 -1
- data/lib/test_prof/recipes/rspec/any_fixture.rb +1 -1
- data/lib/test_prof/rspec_stamp/parser.rb +4 -4
- data/lib/test_prof/rspec_stamp/rspec.rb +4 -1
- data/lib/test_prof/ruby_prof.rb +5 -2
- data/lib/test_prof/stack_prof.rb +7 -4
- data/lib/test_prof/tag_prof/rspec.rb +3 -1
- data/lib/test_prof/utils/sized_ordered_set.rb +5 -0
- data/lib/test_prof/version.rb +1 -1
- metadata +6 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0df1119b6d47cf2641984fe6bcc7387c228353ff
|
4
|
+
data.tar.gz: d472861344964d895fc964afb099f3d3a35dbfae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccde20ed06a18ff23b85ee1d2b42269214d8ea8dbaf88fda55a78093bd76c99cafef050b3db70e76f98570709b7adfec46d45e9cbb1140233f688c80bc158115
|
7
|
+
data.tar.gz: 2bda30e78808f8edfa279b88abafa617d416fa6f1bc9f235c883ab106a18d9619c8a5f4db3c412ede368307eade325db0d3559788e2015f2a7aeac6445cdeaed
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -24,6 +24,12 @@ Of course, we have some [solutions](#tips-and-tricks) for common performance iss
|
|
24
24
|
|
25
25
|
See [Table of Contents](#table-of-contents) for more.
|
26
26
|
|
27
|
+
Supported Ruby versions:
|
28
|
+
|
29
|
+
- Ruby (MRI) >= 2.2.0
|
30
|
+
|
31
|
+
- JRuby >= 9.1.0.0
|
32
|
+
|
27
33
|
<a href="https://evilmartians.com/">
|
28
34
|
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
|
29
35
|
|
@@ -39,7 +39,7 @@ module RuboCop
|
|
39
39
|
|
40
40
|
def on_block(node)
|
41
41
|
method, _args, body = *node
|
42
|
-
return unless body
|
42
|
+
return unless body && body.begin_type?
|
43
43
|
|
44
44
|
_receiver, method_name, _object = *method
|
45
45
|
return unless GROUP_BLOCKS.include?(method_name)
|
@@ -109,7 +109,7 @@ module RuboCop
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def oneliner?(node)
|
112
|
-
node
|
112
|
+
node && node.block_type? &&
|
113
113
|
(node.source.lines.size == 1) &&
|
114
114
|
example_node?(node)
|
115
115
|
end
|
@@ -1,5 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "test_prof/ext/string_strip_heredoc"
|
4
|
+
|
5
|
+
using TestProf::StringStripHeredoc
|
6
|
+
|
3
7
|
module TestProf::EventProf::CustomEvents
|
4
8
|
module FactoryCreate # :nodoc: all
|
5
9
|
module RunnerPatch
|
@@ -42,7 +46,7 @@ end
|
|
42
46
|
TestProf.activate('EVENT_PROF', 'factory.create') do
|
43
47
|
if TestProf.require(
|
44
48
|
'factory_girl',
|
45
|
-
|
49
|
+
<<-MSG.strip_heredoc
|
46
50
|
Failed to load FactoryGirl.
|
47
51
|
|
48
52
|
Make sure that "factory_girl" gem is in your Gemfile.
|
@@ -1,5 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "test_prof/ext/string_strip_heredoc"
|
4
|
+
|
5
|
+
using TestProf::StringStripHeredoc
|
6
|
+
|
3
7
|
module TestProf::EventProf::CustomEvents
|
4
8
|
module SidekiqInline # :nodoc: all
|
5
9
|
module ClientPatch
|
@@ -39,7 +43,7 @@ end
|
|
39
43
|
TestProf.activate('EVENT_PROF', 'sidekiq.inline') do
|
40
44
|
if TestProf.require(
|
41
45
|
'sidekiq/testing',
|
42
|
-
|
46
|
+
<<-MSG.strip_heredoc
|
43
47
|
Failed to load Sidekiq.
|
44
48
|
|
45
49
|
Make sure that "sidekiq" gem is in your Gemfile.
|
@@ -1,5 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "test_prof/ext/string_strip_heredoc"
|
4
|
+
|
5
|
+
using TestProf::StringStripHeredoc
|
6
|
+
|
3
7
|
module TestProf::EventProf::CustomEvents
|
4
8
|
module SidekiqJobs # :nodoc: all
|
5
9
|
module ClientPatch
|
@@ -26,7 +30,7 @@ end
|
|
26
30
|
TestProf.activate('EVENT_PROF', 'sidekiq.jobs') do
|
27
31
|
if TestProf.require(
|
28
32
|
'sidekiq/testing',
|
29
|
-
|
33
|
+
<<-MSG.strip_heredoc
|
30
34
|
Failed to load Sidekiq.
|
31
35
|
|
32
36
|
Make sure that "sidekiq" gem is in your Gemfile.
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "test_prof/ext/float_duration"
|
4
4
|
require "test_prof/ext/string_truncate"
|
5
|
+
require "test_prof/ext/string_strip_heredoc"
|
5
6
|
|
6
7
|
module TestProf
|
7
8
|
module EventProf
|
@@ -9,6 +10,7 @@ module TestProf
|
|
9
10
|
include Logging
|
10
11
|
using FloatDuration
|
11
12
|
using StringTruncate
|
13
|
+
using StringStripHeredoc
|
12
14
|
|
13
15
|
NOTIFICATIONS = %i[
|
14
16
|
example_group_started
|
@@ -45,7 +47,7 @@ module TestProf
|
|
45
47
|
msgs = []
|
46
48
|
|
47
49
|
msgs <<
|
48
|
-
|
50
|
+
<<-MSG.strip_heredoc
|
49
51
|
EventProf results for #{@profiler.event}
|
50
52
|
|
51
53
|
Total time: #{@profiler.total_time.duration}
|
@@ -60,7 +62,7 @@ module TestProf
|
|
60
62
|
location = group[:id].metadata[:location]
|
61
63
|
|
62
64
|
msgs <<
|
63
|
-
|
65
|
+
<<-GROUP.strip_heredoc
|
64
66
|
#{description.truncate} (#{location}) – #{group[:time].duration} (#{group[:count]} / #{group[:examples]})
|
65
67
|
GROUP
|
66
68
|
end
|
@@ -72,7 +74,7 @@ module TestProf
|
|
72
74
|
description = example[:id].description
|
73
75
|
location = example[:id].metadata[:location]
|
74
76
|
msgs <<
|
75
|
-
|
77
|
+
<<-GROUP.strip_heredoc
|
76
78
|
#{description.truncate} (#{location}) – #{example[:time].duration} (#{example[:count]})
|
77
79
|
GROUP
|
78
80
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TestProf
|
4
|
+
# Ruby 2.3 #bsearch_index method (for usage with older Rubies)
|
5
|
+
# Straighforward and non-optimal implementation,
|
6
|
+
# just for compatiblity
|
7
|
+
module ArrayBSearchIndex
|
8
|
+
refine Array do
|
9
|
+
def bsearch_index(&block)
|
10
|
+
el = bsearch(&block)
|
11
|
+
index(el)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TestProf
|
4
|
+
# Add #strip_heredoc method to use instead of
|
5
|
+
# squiggly docs (to support older Rubies)
|
6
|
+
module StringStripHeredoc
|
7
|
+
refine String do
|
8
|
+
def strip_heredoc
|
9
|
+
min = scan(/^[ \t]*(?=\S)/).min
|
10
|
+
indent = min ? min.size : 0
|
11
|
+
gsub(/^[ \t]{#{indent}}/, '')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -16,7 +16,7 @@ module TestProf
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def bad?
|
19
|
-
count
|
19
|
+
count > 0 && queries_count.zero?
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -111,7 +111,7 @@ module TestProf
|
|
111
111
|
end
|
112
112
|
|
113
113
|
def within_factory?
|
114
|
-
@depth
|
114
|
+
@depth > 0
|
115
115
|
end
|
116
116
|
|
117
117
|
def ignore?
|
@@ -1,14 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "test_prof/ext/float_duration"
|
4
|
+
require "test_prof/ext/string_strip_heredoc"
|
4
5
|
|
5
6
|
module TestProf
|
6
7
|
module FactoryDoctor
|
7
8
|
class RSpecListener # :nodoc:
|
8
9
|
include Logging
|
9
10
|
using FloatDuration
|
11
|
+
using StringStripHeredoc
|
10
12
|
|
11
|
-
SUCCESS_MESSAGE = 'FactoryDoctor says: "Looks good to me!"'
|
13
|
+
SUCCESS_MESSAGE = 'FactoryDoctor says: "Looks good to me!"'.freeze
|
12
14
|
|
13
15
|
NOTIFICATIONS = %i[
|
14
16
|
example_started
|
@@ -49,7 +51,7 @@ module TestProf
|
|
49
51
|
msgs = []
|
50
52
|
|
51
53
|
msgs <<
|
52
|
-
|
54
|
+
<<-MSG.strip_heredoc
|
53
55
|
FactoryDoctor report
|
54
56
|
|
55
57
|
Total (potentially) bad examples: #{@count}
|
@@ -1,16 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "test_prof/ext/string_strip_heredoc"
|
4
|
+
|
3
5
|
module TestProf::FactoryProf
|
4
6
|
module Printers
|
5
7
|
module Simple # :nodoc: all
|
6
8
|
class << self
|
7
9
|
include TestProf::Logging
|
10
|
+
using TestProf::StringStripHeredoc
|
8
11
|
|
9
12
|
def dump(result)
|
10
13
|
msgs = []
|
11
14
|
|
12
15
|
msgs <<
|
13
|
-
|
16
|
+
<<-MSG.strip_heredoc
|
14
17
|
Factories usage
|
15
18
|
|
16
19
|
total top-level name
|
@@ -12,7 +12,7 @@ RSpec.shared_context "any_fixture:clean", with_clean_fixture: true do
|
|
12
12
|
|
13
13
|
def open_transaction?
|
14
14
|
pool = ActiveRecord::Base.connection_pool
|
15
|
-
pool.active_connection? && pool.connection.open_transactions
|
15
|
+
pool.active_connection? && pool.connection.open_transactions > 0
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
require "ripper"
|
4
4
|
|
5
|
-
# rubocop: disable Metrics/CyclomaticComplexity
|
6
|
-
|
7
5
|
module TestProf
|
8
6
|
module RSpecStamp
|
9
7
|
# Parse examples headers
|
@@ -24,12 +22,13 @@ module TestProf
|
|
24
22
|
end
|
25
23
|
|
26
24
|
def remove_tag(tag)
|
27
|
-
@tags
|
28
|
-
@htags
|
25
|
+
@tags.delete(tag) if @tags
|
26
|
+
@htags.delete_if { |(k, _v)| k == tag } if @htags
|
29
27
|
end
|
30
28
|
end
|
31
29
|
|
32
30
|
class << self
|
31
|
+
# rubocop: disable Metrics/CyclomaticComplexity
|
33
32
|
def parse(code)
|
34
33
|
sexp = Ripper.sexp(code)
|
35
34
|
return unless sexp
|
@@ -77,6 +76,7 @@ module TestProf
|
|
77
76
|
|
78
77
|
res
|
79
78
|
end
|
79
|
+
# rubocop: enable Metrics/CyclomaticComplexity
|
80
80
|
|
81
81
|
private
|
82
82
|
|
@@ -1,9 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "test_prof/ext/string_strip_heredoc"
|
4
|
+
|
3
5
|
module TestProf
|
4
6
|
module RSpecStamp
|
5
7
|
class RSpecListener # :nodoc:
|
6
8
|
include Logging
|
9
|
+
using StringStripHeredoc
|
7
10
|
|
8
11
|
NOTIFICATIONS = %i[
|
9
12
|
example_failed
|
@@ -34,7 +37,7 @@ module TestProf
|
|
34
37
|
msgs = []
|
35
38
|
|
36
39
|
msgs <<
|
37
|
-
|
40
|
+
<<-MSG.strip_heredoc
|
38
41
|
RSpec Stamp results
|
39
42
|
|
40
43
|
Total patches: #{@total}
|
data/lib/test_prof/ruby_prof.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "test_prof/ext/string_strip_heredoc"
|
4
|
+
|
3
5
|
module TestProf
|
4
6
|
# RubyProf wrapper.
|
5
7
|
#
|
@@ -119,6 +121,7 @@ module TestProf
|
|
119
121
|
|
120
122
|
class << self
|
121
123
|
include Logging
|
124
|
+
using StringStripHeredoc
|
122
125
|
|
123
126
|
def config
|
124
127
|
@config ||= Configuration.new
|
@@ -172,7 +175,7 @@ module TestProf
|
|
172
175
|
ENV["RUBY_PROF_MEASURE_MODE"] = config.mode.to_s
|
173
176
|
@initialized = TestProf.require(
|
174
177
|
'ruby-prof',
|
175
|
-
|
178
|
+
<<-MSG.strip_heredoc
|
176
179
|
Please, install 'ruby-prof' first:
|
177
180
|
# Gemfile
|
178
181
|
gem 'ruby-prof', '>= 0.16.0', require: false
|
@@ -184,7 +187,7 @@ module TestProf
|
|
184
187
|
if Utils.verify_gem_version('ruby-prof', at_least: '0.16.0')
|
185
188
|
true
|
186
189
|
else
|
187
|
-
log :error,
|
190
|
+
log :error, <<-MGS.strip_heredoc
|
188
191
|
Please, upgrade 'ruby-prof' to version >= 0.16.0.
|
189
192
|
MGS
|
190
193
|
false
|
data/lib/test_prof/stack_prof.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "test_prof/ext/string_strip_heredoc"
|
4
|
+
|
3
5
|
module TestProf
|
4
6
|
# StackProf wrapper.
|
5
7
|
#
|
@@ -32,6 +34,7 @@ module TestProf
|
|
32
34
|
|
33
35
|
class << self
|
34
36
|
include Logging
|
37
|
+
using StringStripHeredoc
|
35
38
|
|
36
39
|
def config
|
37
40
|
@config ||= Configuration.new
|
@@ -88,7 +91,7 @@ module TestProf
|
|
88
91
|
|
89
92
|
html_path = path.gsub(/\.dump$/, '.html')
|
90
93
|
|
91
|
-
log :info,
|
94
|
+
log :info, <<-MSG.strip_heredoc
|
92
95
|
Run the following command to generate a flame graph report:
|
93
96
|
|
94
97
|
stackprof --flamegraph #{path} > #{html_path} && stackprof --flamegraph-viewer=#{html_path}
|
@@ -111,7 +114,7 @@ module TestProf
|
|
111
114
|
return @initialized if instance_variable_defined?(:@initialized)
|
112
115
|
@initialized = TestProf.require(
|
113
116
|
'stackprof',
|
114
|
-
|
117
|
+
<<-MSG.strip_heredoc
|
115
118
|
Please, install 'stackprof' first:
|
116
119
|
# Gemfile
|
117
120
|
gem 'stackprof', '>= 0.2.9', require: false
|
@@ -123,9 +126,9 @@ module TestProf
|
|
123
126
|
if Utils.verify_gem_version('stackprof', at_least: '0.2.9')
|
124
127
|
true
|
125
128
|
else
|
126
|
-
log :error,
|
129
|
+
log :error, <<-MSG.strip_heredoc
|
127
130
|
Please, upgrade 'stackprof' to version >= 0.2.9.
|
128
|
-
|
131
|
+
MSG
|
129
132
|
false
|
130
133
|
end
|
131
134
|
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "test_prof/ext/float_duration"
|
4
|
+
require "test_prof/ext/string_strip_heredoc"
|
4
5
|
|
5
6
|
module TestProf
|
6
7
|
module TagProf
|
7
8
|
class RSpecListener # :nodoc:
|
8
9
|
include Logging
|
9
10
|
using FloatDuration
|
11
|
+
using StringStripHeredoc
|
10
12
|
|
11
13
|
NOTIFICATIONS = %i[
|
12
14
|
example_started
|
@@ -37,7 +39,7 @@ module TestProf
|
|
37
39
|
msgs = []
|
38
40
|
|
39
41
|
msgs <<
|
40
|
-
|
42
|
+
<<-MSG.strip_heredoc
|
41
43
|
TagProf report for #{@tag}
|
42
44
|
MSG
|
43
45
|
|
@@ -4,6 +4,11 @@ module TestProf
|
|
4
4
|
module Utils
|
5
5
|
# Ordered set with capacity
|
6
6
|
class SizedOrderedSet
|
7
|
+
unless [].respond_to?(:bsearch_index)
|
8
|
+
require "test_prof/ext/array_bsearch_index"
|
9
|
+
using ArrayBSearchIndex
|
10
|
+
end
|
11
|
+
|
7
12
|
include Enumerable
|
8
13
|
|
9
14
|
def initialize(max_size, sort_by: nil)
|
data/lib/test_prof/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-prof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.49'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: pry-byebug
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
83
|
description: "\n Ruby applications tests profiling tools.\n\n Contains tools
|
98
84
|
to anylyze factories usage, integrate with Ruby profilers,\n profile your examples
|
99
85
|
using ActiveSupport notifications (if any) and\n statically analyze your code
|
@@ -140,7 +126,9 @@ files:
|
|
140
126
|
- lib/test_prof/event_prof/instrumentations/active_support.rb
|
141
127
|
- lib/test_prof/event_prof/minitest.rb
|
142
128
|
- lib/test_prof/event_prof/rspec.rb
|
129
|
+
- lib/test_prof/ext/array_bsearch_index.rb
|
143
130
|
- lib/test_prof/ext/float_duration.rb
|
131
|
+
- lib/test_prof/ext/string_strip_heredoc.rb
|
144
132
|
- lib/test_prof/ext/string_truncate.rb
|
145
133
|
- lib/test_prof/factory_default.rb
|
146
134
|
- lib/test_prof/factory_default/factory_girl_patch.rb
|
@@ -183,7 +171,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
183
171
|
requirements:
|
184
172
|
- - ">="
|
185
173
|
- !ruby/object:Gem::Version
|
186
|
-
version: 2.
|
174
|
+
version: 2.2.0
|
187
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
176
|
requirements:
|
189
177
|
- - ">="
|
@@ -191,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
179
|
version: '0'
|
192
180
|
requirements: []
|
193
181
|
rubyforge_project:
|
194
|
-
rubygems_version: 2.6.
|
182
|
+
rubygems_version: 2.6.13
|
195
183
|
signing_key:
|
196
184
|
specification_version: 4
|
197
185
|
summary: Ruby applications tests profiling tools
|