test-prof 1.0.0.rc2 → 1.0.4
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/CHANGELOG.md +38 -0
- data/README.md +2 -2
- data/lib/test_prof.rb +6 -2
- data/lib/test_prof/any_fixture.rb +6 -6
- data/lib/test_prof/any_fixture/dump.rb +12 -7
- data/lib/test_prof/before_all.rb +2 -2
- data/lib/test_prof/before_all/adapters/active_record.rb +1 -0
- data/lib/test_prof/event_prof/custom_events.rb +1 -1
- data/lib/test_prof/event_prof/instrumentations/active_support.rb +1 -1
- data/lib/test_prof/event_prof/profiler.rb +3 -4
- data/lib/test_prof/factory_prof.rb +24 -4
- data/lib/test_prof/factory_prof/nate_heckler.rb +16 -0
- data/lib/test_prof/factory_prof/printers/flamegraph.rb +1 -1
- data/lib/test_prof/factory_prof/printers/nate_heckler.rb +26 -0
- data/lib/test_prof/factory_prof/printers/simple.rb +6 -2
- data/lib/test_prof/logging.rb +18 -12
- data/lib/test_prof/recipes/logging.rb +1 -1
- data/lib/test_prof/recipes/minitest/before_all.rb +2 -2
- data/lib/test_prof/recipes/rspec/any_fixture.rb +1 -1
- data/lib/test_prof/recipes/rspec/before_all.rb +1 -1
- data/lib/test_prof/recipes/rspec/let_it_be.rb +3 -6
- data/lib/test_prof/rspec_dissect.rb +2 -2
- data/lib/test_prof/rspec_stamp.rb +1 -1
- data/lib/test_prof/ruby_prof.rb +11 -9
- data/lib/test_prof/tag_prof/result.rb +1 -1
- data/lib/test_prof/tag_prof/rspec.rb +3 -5
- data/lib/test_prof/utils/sized_ordered_set.rb +2 -2
- data/lib/test_prof/version.rb +1 -1
- metadata +13 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c90e1ef55e15100f84c70ca251e27113353a7998735966f56401fea543a43d1f
|
4
|
+
data.tar.gz: c91c7e49b98bb8904dcb18805bf38d8b9c1f29ea80559c037626dd5439929c32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d983f2986f990eb2a81064604dbd5f488bd34ffb80d74f2450cdf265601583062ba6eddc0746b6e10fa168b5aafe8c987350deb427198e011d937e27f210865e
|
7
|
+
data.tar.gz: 6c391a64e5d34ea094d81854bd03b142ae1e6bdf8040f9e3273430a26d7f92190e4455c2acb5db8ee6741b37b5a6529c0b2bee1fb871a884b0cf6e4bb1126b9e
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,44 @@
|
|
2
2
|
|
3
3
|
## master (unrealeased)
|
4
4
|
|
5
|
+
## 1.0.4 (2021-05-12)
|
6
|
+
|
7
|
+
- Add ability to use custom logger. ([@palkan][])
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
TestProf.configure do |config|
|
11
|
+
config.logger = Logger.new($stdout, level: Logger::WARN)
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
- Add `nate_heckler` mode for FactoryProf. ([@palkan][])
|
16
|
+
|
17
|
+
Drop this into your `rails_helper.rb` or `test_helper.rb`:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
require "test_prof/factory_prof/nate_heckler"
|
21
|
+
```
|
22
|
+
|
23
|
+
And for every test run see the overall factories usage:
|
24
|
+
|
25
|
+
```sh
|
26
|
+
[TEST PROF INFO] Time spent in factories: 04:31.222 (54% of total time)
|
27
|
+
```
|
28
|
+
|
29
|
+
## 1.0.3 (2021-04-30)
|
30
|
+
|
31
|
+
- Minor fixes.
|
32
|
+
|
33
|
+
## 1.0.2 (2021-02-26)
|
34
|
+
|
35
|
+
- Make `before_all(setup_fixtures: true)` compatible with Rails 6.1. ([@palkan][])
|
36
|
+
|
37
|
+
## 1.0.1 (2021-02-12)
|
38
|
+
|
39
|
+
- Fixed AnyFixture deprecation warning.
|
40
|
+
|
41
|
+
## 1.0.0 (2021-01-21)
|
42
|
+
|
5
43
|
## 1.0.0.rc2 (2021-01-06)
|
6
44
|
|
7
45
|
- Make Rails fixtures accesible in `before_all`. ([@palkan][])
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ TestProf toolbox aims to help you identify bottlenecks in your test suite. It co
|
|
32
32
|
📑 [Documentation](https://test-prof.evilmartians.io)
|
33
33
|
|
34
34
|
<p align="center">
|
35
|
-
<a href="http://bit.ly/test-prof-map">
|
35
|
+
<a href="http://bit.ly/test-prof-map-v1">
|
36
36
|
<img src="./docs/assets/images/coggle.png" alt="TestProf map" width="738">
|
37
37
|
</a>
|
38
38
|
</p>
|
@@ -75,7 +75,7 @@ Add `test-prof` gem to your application:
|
|
75
75
|
|
76
76
|
```ruby
|
77
77
|
group :test do
|
78
|
-
gem "test-prof"
|
78
|
+
gem "test-prof", "~> 1.0"
|
79
79
|
end
|
80
80
|
```
|
81
81
|
|
data/lib/test_prof.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "fileutils"
|
4
|
+
require "logger"
|
5
|
+
|
4
6
|
require "test_prof/version"
|
5
7
|
require "test_prof/logging"
|
6
8
|
require "test_prof/utils"
|
@@ -130,7 +132,8 @@ module TestProf
|
|
130
132
|
|
131
133
|
# TestProf configuration
|
132
134
|
class Configuration
|
133
|
-
attr_accessor :output, # IO to write
|
135
|
+
attr_accessor :output, # IO to write logs
|
136
|
+
:logger, # Logger instance to write to the output io
|
134
137
|
:color, # Whether to colorize output or not
|
135
138
|
:output_dir, # Directory to store artifacts
|
136
139
|
:timestamps, # Whether to use timestamped names for artifacts,
|
@@ -138,6 +141,7 @@ module TestProf
|
|
138
141
|
|
139
142
|
def initialize
|
140
143
|
@output = $stdout
|
144
|
+
@logger = Logger.new(@output, formatter: Logging::Formatter.new)
|
141
145
|
@color = true
|
142
146
|
@output_dir = "tmp/test_prof"
|
143
147
|
@timestamps = false
|
@@ -161,5 +165,5 @@ require "test_prof/factory_doctor"
|
|
161
165
|
require "test_prof/factory_prof"
|
162
166
|
require "test_prof/rspec_stamp"
|
163
167
|
require "test_prof/tag_prof"
|
164
|
-
require "test_prof/rspec_dissect"
|
168
|
+
require "test_prof/rspec_dissect" if TestProf.rspec?
|
165
169
|
require "test_prof/factory_all_stub"
|
@@ -6,7 +6,7 @@ require "test_prof/any_fixture/dump"
|
|
6
6
|
module TestProf
|
7
7
|
# Make DB fixtures from blocks.
|
8
8
|
module AnyFixture
|
9
|
-
INSERT_RXP = /^INSERT INTO (
|
9
|
+
INSERT_RXP = /^INSERT INTO (\S+)/.freeze
|
10
10
|
|
11
11
|
using FloatDuration
|
12
12
|
|
@@ -16,8 +16,8 @@ module TestProf
|
|
16
16
|
:import_dump_via_cli, :dump_matching_queries, :force_matching_dumps
|
17
17
|
attr_reader :default_dump_watch_paths
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
alias_method :reporting_enabled?, :reporting_enabled
|
20
|
+
alias_method :import_dump_via_cli?, :import_dump_via_cli
|
21
21
|
|
22
22
|
def initialize
|
23
23
|
@reporting_enabled = ENV["ANYFIXTURE_REPORT"] == "1"
|
@@ -42,7 +42,7 @@ module TestProf
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def before_dump(&block)
|
45
|
-
if
|
45
|
+
if block
|
46
46
|
@before_dump << block
|
47
47
|
else
|
48
48
|
@before_dump
|
@@ -50,7 +50,7 @@ module TestProf
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def after_dump(&block)
|
53
|
-
if
|
53
|
+
if block
|
54
54
|
@after_dump << block
|
55
55
|
else
|
56
56
|
@after_dump
|
@@ -112,7 +112,7 @@ module TestProf
|
|
112
112
|
config.reporting_enabled
|
113
113
|
end
|
114
114
|
|
115
|
-
|
115
|
+
alias_method :reporting_enabled?, :reporting_enabled
|
116
116
|
|
117
117
|
# Register a block of code as a fixture,
|
118
118
|
# returns the result of the block execution
|
@@ -6,9 +6,9 @@ require "set"
|
|
6
6
|
|
7
7
|
module TestProf
|
8
8
|
module AnyFixture
|
9
|
-
MODIFY_RXP = /^(INSERT INTO|UPDATE|DELETE FROM) (
|
10
|
-
ANY_FIXTURE_RXP = /(
|
11
|
-
ANY_FIXTURE_IGNORE_RXP = /(
|
9
|
+
MODIFY_RXP = /^(INSERT INTO|UPDATE|DELETE FROM) (\S+)/i.freeze
|
10
|
+
ANY_FIXTURE_RXP = /(\/\*|--).*\bany_fixture:dump/.freeze
|
11
|
+
ANY_FIXTURE_IGNORE_RXP = /(\/\*|--).*\bany_fixture:ignore/.freeze
|
12
12
|
|
13
13
|
using(Module.new do
|
14
14
|
refine Object do
|
@@ -45,7 +45,6 @@ module TestProf
|
|
45
45
|
@adapter = adapter
|
46
46
|
@tmp_path = path + ".tmp"
|
47
47
|
@reset_pk = Set.new
|
48
|
-
@file = File.open(tmp_path, "w")
|
49
48
|
end
|
50
49
|
|
51
50
|
def start(_event, _id, payload)
|
@@ -70,6 +69,8 @@ module TestProf
|
|
70
69
|
end
|
71
70
|
|
72
71
|
def commit
|
72
|
+
return unless defined?(:@file)
|
73
|
+
|
73
74
|
file.close
|
74
75
|
|
75
76
|
FileUtils.mv(tmp_path, path)
|
@@ -77,7 +78,11 @@ module TestProf
|
|
77
78
|
|
78
79
|
private
|
79
80
|
|
80
|
-
attr_reader :
|
81
|
+
attr_reader :reset_pk, :adapter
|
82
|
+
|
83
|
+
def file
|
84
|
+
@file ||= File.open(tmp_path, "w")
|
85
|
+
end
|
81
86
|
|
82
87
|
def reset_pk!(table_name)
|
83
88
|
return if /sqlite_sequence/.match?(table_name)
|
@@ -97,7 +102,7 @@ module TestProf
|
|
97
102
|
def quoted(val)
|
98
103
|
if val.is_a?(Array)
|
99
104
|
val.map { |v| quoted(v) }
|
100
|
-
elsif val.is_a?(
|
105
|
+
elsif val.is_a?(ActiveModel::Attribute)
|
101
106
|
quoted(val.value_for_database)
|
102
107
|
else
|
103
108
|
ActiveRecord::Base.connection.quote(val)
|
@@ -106,7 +111,7 @@ module TestProf
|
|
106
111
|
end
|
107
112
|
|
108
113
|
attr_reader :name, :digest, :path, :subscriber, :success
|
109
|
-
|
114
|
+
alias_method :success?, :success
|
110
115
|
|
111
116
|
def initialize(name, watch: [], cache_key: nil)
|
112
117
|
@name = name
|
data/lib/test_prof/before_all.rb
CHANGED
@@ -79,7 +79,7 @@ module TestProf
|
|
79
79
|
# config.before(:rollback) { ... }
|
80
80
|
def before(type, &block)
|
81
81
|
validate_hook_type!(type)
|
82
|
-
hooks[type].before << block if
|
82
|
+
hooks[type].before << block if block
|
83
83
|
end
|
84
84
|
|
85
85
|
# Add `after` hook for `begin` or
|
@@ -88,7 +88,7 @@ module TestProf
|
|
88
88
|
# config.after(:begin) { ... }
|
89
89
|
def after(type, &block)
|
90
90
|
validate_hook_type!(type)
|
91
|
-
hooks[type].after << block if
|
91
|
+
hooks[type].after << block if block
|
92
92
|
end
|
93
93
|
|
94
94
|
def run_hooks(type) # :nodoc:
|
@@ -26,7 +26,7 @@ module TestProf::EventProf
|
|
26
26
|
|
27
27
|
class << self
|
28
28
|
def subscribe(event, &block)
|
29
|
-
raise ArgumentError, "Block is required!" unless
|
29
|
+
raise ArgumentError, "Block is required!" unless block
|
30
30
|
|
31
31
|
::ActiveSupport::Notifications.subscribe(event, Subscriber.new(block))
|
32
32
|
end
|
@@ -6,7 +6,7 @@ module TestProf
|
|
6
6
|
attr_reader :event, :total_count, :total_time, :rank_by, :top_count, :per_example,
|
7
7
|
:time, :count, :example_time, :example_count, :absolute_run_time
|
8
8
|
|
9
|
-
|
9
|
+
alias_method :per_example?, :per_example
|
10
10
|
|
11
11
|
def initialize(event:, instrumenter:, rank_by: :time, top_count: 5, per_example: false)
|
12
12
|
@event = event
|
@@ -88,14 +88,13 @@ module TestProf
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def results
|
91
|
-
|
91
|
+
{
|
92
92
|
groups: @groups.to_a
|
93
93
|
}.tap do |data|
|
94
94
|
next unless per_example?
|
95
95
|
|
96
96
|
data[:examples] = @examples.to_a
|
97
97
|
end
|
98
|
-
results
|
99
98
|
end
|
100
99
|
|
101
100
|
def take_time(start_ts)
|
@@ -130,7 +129,7 @@ module TestProf
|
|
130
129
|
end
|
131
130
|
|
132
131
|
def each(&block)
|
133
|
-
if
|
132
|
+
if block
|
134
133
|
@profilers.each(&block)
|
135
134
|
else
|
136
135
|
@profilers.each
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "test_prof/factory_prof/printers/simple"
|
4
4
|
require "test_prof/factory_prof/printers/flamegraph"
|
5
|
+
require "test_prof/factory_prof/printers/nate_heckler"
|
5
6
|
require "test_prof/factory_prof/factory_builders/factory_bot"
|
6
7
|
require "test_prof/factory_prof/factory_builders/fabrication"
|
7
8
|
|
@@ -10,14 +11,23 @@ module TestProf
|
|
10
11
|
# flamegraphs or detect most popular factories
|
11
12
|
module FactoryProf
|
12
13
|
FACTORY_BUILDERS = [FactoryBuilders::FactoryBot,
|
13
|
-
|
14
|
+
FactoryBuilders::Fabrication].freeze
|
14
15
|
|
15
16
|
# FactoryProf configuration
|
16
17
|
class Configuration
|
17
|
-
attr_accessor :mode
|
18
|
+
attr_accessor :mode, :printer
|
18
19
|
|
19
20
|
def initialize
|
20
21
|
@mode = ENV["FPROF"] == "flamegraph" ? :flamegraph : :simple
|
22
|
+
@printer =
|
23
|
+
case ENV["FPROF"]
|
24
|
+
when "flamegraph"
|
25
|
+
Printers::Flamegraph
|
26
|
+
when "nate_heckler"
|
27
|
+
Printers::NateHeckler
|
28
|
+
else
|
29
|
+
Printers::Simple
|
30
|
+
end
|
21
31
|
end
|
22
32
|
|
23
33
|
# Whether we want to generate flamegraphs
|
@@ -74,7 +84,15 @@ module TestProf
|
|
74
84
|
|
75
85
|
log :info, "FactoryProf enabled (#{config.mode} mode)"
|
76
86
|
|
87
|
+
patch!
|
88
|
+
end
|
89
|
+
|
90
|
+
def patch!
|
91
|
+
return if @patched
|
92
|
+
|
77
93
|
FACTORY_BUILDERS.each(&:patch)
|
94
|
+
|
95
|
+
@patched = true
|
78
96
|
end
|
79
97
|
|
80
98
|
# Inits FactoryProf and setups at exit hook,
|
@@ -82,9 +100,11 @@ module TestProf
|
|
82
100
|
def run
|
83
101
|
init
|
84
102
|
|
85
|
-
printer = config.
|
103
|
+
printer = config.printer
|
104
|
+
|
105
|
+
started_at = TestProf.now
|
86
106
|
|
87
|
-
at_exit { printer.dump(result) }
|
107
|
+
at_exit { printer.dump(result, start_time: started_at) }
|
88
108
|
|
89
109
|
start
|
90
110
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_prof/factory_prof"
|
4
|
+
|
5
|
+
# A standalone Factory Prof printer which is meant to be always enabled
|
6
|
+
|
7
|
+
TestProf::FactoryProf.patch!
|
8
|
+
|
9
|
+
started_at = TestProf.now
|
10
|
+
at_exit do
|
11
|
+
TestProf::FactoryProf::Printers::NateHeckler.dump(
|
12
|
+
TestProf::FactoryProf.result, start_time: started_at
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
TestProf::FactoryProf.start
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_prof/ext/float_duration"
|
4
|
+
|
5
|
+
module TestProf::FactoryProf
|
6
|
+
module Printers
|
7
|
+
# See https://twitter.com/nateberkopec/status/1389945187766456333
|
8
|
+
module NateHeckler # :nodoc: all
|
9
|
+
class << self
|
10
|
+
using TestProf::FloatDuration
|
11
|
+
include TestProf::Logging
|
12
|
+
|
13
|
+
def dump(result, start_time:)
|
14
|
+
return if result.raw_stats == {}
|
15
|
+
|
16
|
+
total_time = result.stats.sum { |stat| stat[:top_level_time] }
|
17
|
+
total_run_time = TestProf.now - start_time
|
18
|
+
|
19
|
+
percentage = ((total_time / total_run_time) * 100).round(2)
|
20
|
+
|
21
|
+
log :info, "Time spent in factories: #{total_time.duration} (#{percentage}% of total time)"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,15 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "test_prof/ext/float_duration"
|
4
|
+
|
3
5
|
module TestProf::FactoryProf
|
4
6
|
module Printers
|
5
7
|
module Simple # :nodoc: all
|
6
8
|
class << self
|
9
|
+
using TestProf::FloatDuration
|
7
10
|
include TestProf::Logging
|
8
11
|
|
9
|
-
def dump(result)
|
12
|
+
def dump(result, start_time:)
|
10
13
|
return log(:info, "No factories detected") if result.raw_stats == {}
|
11
14
|
msgs = []
|
12
15
|
|
16
|
+
total_run_time = TestProf.now - start_time
|
13
17
|
total_count = result.stats.sum { |stat| stat[:total_count] }
|
14
18
|
total_top_level_count = result.stats.sum { |stat| stat[:top_level_count] }
|
15
19
|
total_time = result.stats.sum { |stat| stat[:top_level_time] }
|
@@ -21,7 +25,7 @@ module TestProf::FactoryProf
|
|
21
25
|
|
22
26
|
Total: #{total_count}
|
23
27
|
Total top-level: #{total_top_level_count}
|
24
|
-
Total time: #{
|
28
|
+
Total time: #{total_time.duration} (out of #{total_run_time.duration})
|
25
29
|
Total uniq factories: #{total_uniq_factories}
|
26
30
|
|
27
31
|
total top-level total time time per call top-level time name
|
data/lib/test_prof/logging.rb
CHANGED
@@ -4,23 +4,29 @@ module TestProf
|
|
4
4
|
# Helper for output printing
|
5
5
|
module Logging
|
6
6
|
COLORS = {
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
INFO: "\e[34m", # blue
|
8
|
+
WARN: "\e[33m", # yellow
|
9
|
+
ERROR: "\e[31m" # red
|
10
10
|
}.freeze
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
class Formatter
|
13
|
+
def call(severity, _time, progname, msg)
|
14
|
+
colorize(severity.to_sym, "[#{progname} #{severity}] #{msg}")
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
private
|
18
|
+
|
19
|
+
def colorize(level, msg)
|
20
|
+
return msg unless TestProf.config.color?
|
19
21
|
|
20
|
-
|
21
|
-
return msg unless TestProf.config.color?
|
22
|
+
return msg unless COLORS.key?(level)
|
22
23
|
|
23
|
-
|
24
|
+
"#{COLORS[level]}#{msg}\e[0m"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def log(level, msg)
|
29
|
+
TestProf.config.logger.public_send(level, "TEST PROF") { msg }
|
24
30
|
end
|
25
31
|
end
|
26
32
|
end
|
@@ -11,8 +11,8 @@ module TestProf
|
|
11
11
|
attr_reader :active, :block, :captured_ivars, :teardown_block, :current_test_object,
|
12
12
|
:setup_fixtures
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
alias_method :active?, :active
|
15
|
+
alias_method :setup_fixtures?, :setup_fixtures
|
16
16
|
|
17
17
|
def initialize(setup_fixtures: false, &block)
|
18
18
|
@setup_fixtures = setup_fixtures
|
@@ -15,7 +15,7 @@ RSpec.configure do |config|
|
|
15
15
|
config.include_context "any_fixture:clean", with_clean_fixture: true
|
16
16
|
|
17
17
|
config.after(:suite) do
|
18
|
-
TestProf::AnyFixture.report_stats if TestProf::AnyFixture.reporting_enabled?
|
18
|
+
TestProf::AnyFixture.report_stats if TestProf::AnyFixture.config.reporting_enabled?
|
19
19
|
TestProf::AnyFixture.reset
|
20
20
|
end
|
21
21
|
end
|
@@ -7,7 +7,7 @@ module TestProf
|
|
7
7
|
# Helper to wrap the whole example group into a transaction
|
8
8
|
module RSpec
|
9
9
|
def before_all(setup_fixtures: BeforeAll.config.setup_fixtures, &block)
|
10
|
-
raise ArgumentError, "Block is required!" unless
|
10
|
+
raise ArgumentError, "Block is required!" unless block
|
11
11
|
|
12
12
|
if within_before_all?
|
13
13
|
before(:all) do
|
@@ -55,9 +55,7 @@ module TestProf
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def module_for(group)
|
58
|
-
modules[group] ||=
|
59
|
-
Module.new.tap { |mod| group.prepend(mod) }
|
60
|
-
end
|
58
|
+
modules[group] ||= Module.new.tap { |mod| group.prepend(mod) }
|
61
59
|
end
|
62
60
|
|
63
61
|
private
|
@@ -91,8 +89,7 @@ module TestProf
|
|
91
89
|
initializer = proc do
|
92
90
|
instance_variable_set(:"#{TestProf::LetItBe::PREFIX}#{identifier}", instance_exec(&block))
|
93
91
|
rescue FrozenError => e
|
94
|
-
e.message
|
95
|
-
raise
|
92
|
+
raise e.exception("#{e.message}#{TestProf::LetItBe::FROZEN_ERROR_HINT}")
|
96
93
|
end
|
97
94
|
|
98
95
|
default_options = LetItBe.config.default_modifiers.dup
|
@@ -243,7 +240,7 @@ end
|
|
243
240
|
RSpec.configure do |config|
|
244
241
|
config.after(:example) do |example|
|
245
242
|
if example.exception&.is_a?(FrozenError)
|
246
|
-
example.exception.message << TestProf::LetItBe::FROZEN_ERROR_HINT
|
243
|
+
example.exception.message << TestProf::LetItBe::FROZEN_ERROR_HINT unless example.exception.message.frozen?
|
247
244
|
end
|
248
245
|
end
|
249
246
|
end
|
@@ -38,7 +38,7 @@ module TestProf
|
|
38
38
|
attr_accessor :top_count, :let_stats_enabled,
|
39
39
|
:let_top_count
|
40
40
|
|
41
|
-
|
41
|
+
alias_method :let_stats_enabled?, :let_stats_enabled
|
42
42
|
|
43
43
|
attr_reader :mode
|
44
44
|
|
@@ -139,7 +139,7 @@ end
|
|
139
139
|
|
140
140
|
require "test_prof/rspec_dissect/collectors/let"
|
141
141
|
require "test_prof/rspec_dissect/collectors/before"
|
142
|
-
require "test_prof/rspec_dissect/rspec"
|
142
|
+
require "test_prof/rspec_dissect/rspec"
|
143
143
|
|
144
144
|
TestProf.activate("RD_PROF") do
|
145
145
|
TestProf::RSpecDissect.init
|
data/lib/test_prof/ruby_prof.rb
CHANGED
@@ -239,16 +239,18 @@ module TestProf
|
|
239
239
|
end
|
240
240
|
|
241
241
|
def exclude_common_methods(profiler)
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
242
|
+
if defined?(TSort)
|
243
|
+
profiler.exclude_methods!(
|
244
|
+
TSort,
|
245
|
+
:tsort_each
|
246
|
+
)
|
246
247
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
248
|
+
profiler.exclude_methods!(
|
249
|
+
TSort.singleton_class,
|
250
|
+
:tsort_each, :each_strongly_connected_component,
|
251
|
+
:each_strongly_connected_component_from
|
252
|
+
)
|
253
|
+
end
|
252
254
|
|
253
255
|
profiler.exclude_methods!(
|
254
256
|
BasicObject,
|
@@ -53,11 +53,9 @@ module TestProf
|
|
53
53
|
def fetch_events_data
|
54
54
|
return {} unless @events_profiler
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
60
|
-
]
|
56
|
+
@events_profiler.profilers.map do |profiler|
|
57
|
+
[profiler.event, profiler.time]
|
58
|
+
end.to_h
|
61
59
|
end
|
62
60
|
end
|
63
61
|
end
|
@@ -14,7 +14,7 @@ module TestProf
|
|
14
14
|
def initialize(max_size, sort_by: nil, &block)
|
15
15
|
@max_size = max_size
|
16
16
|
@comparator =
|
17
|
-
if
|
17
|
+
if block
|
18
18
|
block
|
19
19
|
elsif !sort_by.nil?
|
20
20
|
->(x, y) { x[sort_by] >= y[sort_by] }
|
@@ -42,7 +42,7 @@ module TestProf
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def each(&block)
|
45
|
-
if
|
45
|
+
if block
|
46
46
|
data.each(&block)
|
47
47
|
else
|
48
48
|
data.each
|
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: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -174,7 +174,9 @@ files:
|
|
174
174
|
- lib/test_prof/factory_prof/factory_bot_patch.rb
|
175
175
|
- lib/test_prof/factory_prof/factory_builders/fabrication.rb
|
176
176
|
- lib/test_prof/factory_prof/factory_builders/factory_bot.rb
|
177
|
+
- lib/test_prof/factory_prof/nate_heckler.rb
|
177
178
|
- lib/test_prof/factory_prof/printers/flamegraph.rb
|
179
|
+
- lib/test_prof/factory_prof/printers/nate_heckler.rb
|
178
180
|
- lib/test_prof/factory_prof/printers/simple.rb
|
179
181
|
- lib/test_prof/logging.rb
|
180
182
|
- lib/test_prof/recipes/logging.rb
|
@@ -214,12 +216,13 @@ homepage: http://github.com/test-prof/test-prof
|
|
214
216
|
licenses:
|
215
217
|
- MIT
|
216
218
|
metadata:
|
217
|
-
bug_tracker_uri:
|
219
|
+
bug_tracker_uri: https://github.com/test-prof/test-prof/issues
|
218
220
|
changelog_uri: https://github.com/test-prof/test-prof/blob/master/CHANGELOG.md
|
219
221
|
documentation_uri: https://test-prof.evilmartians.io/
|
220
222
|
homepage_uri: https://test-prof.evilmartians.io/
|
221
|
-
source_code_uri:
|
222
|
-
|
223
|
+
source_code_uri: https://github.com/test-prof/test-prof
|
224
|
+
funding_uri: https://github.com/sponsors/test-prof
|
225
|
+
post_install_message:
|
223
226
|
rdoc_options: []
|
224
227
|
require_paths:
|
225
228
|
- lib
|
@@ -230,12 +233,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
230
233
|
version: 2.5.0
|
231
234
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
232
235
|
requirements:
|
233
|
-
- - "
|
236
|
+
- - ">="
|
234
237
|
- !ruby/object:Gem::Version
|
235
|
-
version:
|
238
|
+
version: '0'
|
236
239
|
requirements: []
|
237
|
-
rubygems_version: 3.
|
238
|
-
signing_key:
|
240
|
+
rubygems_version: 3.2.15
|
241
|
+
signing_key:
|
239
242
|
specification_version: 4
|
240
243
|
summary: Ruby applications tests profiling tools
|
241
244
|
test_files: []
|