test-prof 0.10.0 → 0.10.1
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 +12 -0
- data/README.md +3 -1
- data/lib/test_prof.rb +5 -5
- data/lib/test_prof/any_fixture/dsl.rb +4 -5
- data/lib/test_prof/before_all.rb +1 -1
- data/lib/test_prof/before_all/isolator.rb +5 -3
- data/lib/test_prof/event_prof.rb +1 -2
- data/lib/test_prof/event_prof/profiler.rb +1 -1
- data/lib/test_prof/ext/array_bsearch_index.rb +2 -2
- data/lib/test_prof/factory_doctor.rb +2 -1
- data/lib/test_prof/factory_prof/printers/simple.rb +4 -2
- data/lib/test_prof/recipes/rspec/let_it_be.rb +15 -13
- data/lib/test_prof/rspec_dissect.rb +1 -2
- data/lib/test_prof/rspec_stamp.rb +0 -1
- data/lib/test_prof/ruby_prof.rb +3 -5
- data/lib/test_prof/stack_prof.rb +1 -2
- data/lib/test_prof/tag_prof.rb +0 -2
- data/lib/test_prof/version.rb +1 -1
- metadata +7 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccd09eb7997710ebeda54cadf25fa4f9bc4f3d9fce1a180113b29c5d92b22ea8
|
4
|
+
data.tar.gz: 32f50fb3af431b6d33622e03e0dcf720a3dfbcf34f52391be421753c8dede348
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f22b272e49c8423c1b3270202a4594b8acc082082f98418dc4ff781fa9711ea8c1dd2c89097bd8bdda972619a720bfc9c0258534fed80dd5c112186f02c254a4
|
7
|
+
data.tar.gz: f64bd5dbdd363d37346fe56eb3c2fb8223d38596a327b5b32408b5a13c9fd0649d3ebe4b25783923e41974e3eb5f6af69e260501d56c124f8fb05c6bcffaf3dd
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 0.10.1 (2019-10-17)
|
6
|
+
|
7
|
+
- Fix AnyFixture DSL when using with Rails 6.1+. ([@palkan][])
|
8
|
+
|
9
|
+
- Fix loading `let_it_be` without ActiveRecord present. ([@palkan][])
|
10
|
+
|
11
|
+
- Fix compatibility of `before_all` with [`isolator`](https://github.com/palkan/isolator) gem to handle correct usages of non-atomic interactions outside DB transactions. ([@Envek][])
|
12
|
+
|
13
|
+
- Updates FactoryProf to show the amount of time taken per factory call. ([@tyleriguchi][])
|
14
|
+
|
5
15
|
## 0.10.0 (2019-08-19)
|
6
16
|
|
7
17
|
- Use RSpec example ID instead of full description for RubyProf/Stackprof report names. ([@palkan][])
|
@@ -498,3 +508,5 @@ Fixes [#10](https://github.com/palkan/test-prof/issues/10).
|
|
498
508
|
[@mkldon]: https://github.com/mkldon
|
499
509
|
[@dmagro]: https://github.com/dmagro
|
500
510
|
[@danielwaterworth]: https://github.com/danielwaterworth
|
511
|
+
[@Envek]: https://github.com/Envek
|
512
|
+
[@tyleriguchi]: https://github.com/tyleriguchi
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
[](http://cultofmartians.com)
|
2
|
-
[](https://rubygems.org/gems/test-prof) [](https://rubygems.org/gems/test-prof) [](https://github.com/palkan/test-prof/actions)
|
3
|
+
[](https://github.com/palkan/test-prof/actions)
|
4
|
+
[](https://www.codetriage.com/palkan/test-prof)
|
3
5
|
[](https://test-prof.evilmartians.io)
|
4
6
|
|
5
7
|
# Ruby Tests Profiling Toolbox
|
data/lib/test_prof.rb
CHANGED
@@ -7,7 +7,7 @@ require "test_prof/utils"
|
|
7
7
|
|
8
8
|
# Ruby applications tests profiling tools.
|
9
9
|
#
|
10
|
-
# Contains tools to
|
10
|
+
# Contains tools to analyze factories usage, integrate with Ruby profilers,
|
11
11
|
# profile your examples using ActiveSupport notifications (if any) and
|
12
12
|
# statically analyze your code with custom RuboCop cops.
|
13
13
|
#
|
@@ -131,10 +131,10 @@ module TestProf
|
|
131
131
|
# TestProf configuration
|
132
132
|
class Configuration
|
133
133
|
attr_accessor :output, # IO to write output messages.
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
134
|
+
:color, # Whether to colorize output or not
|
135
|
+
:output_dir, # Directory to store artifacts
|
136
|
+
:timestamps, # Whether to use timestamped names for artifacts,
|
137
|
+
:report_suffix # Custom suffix for reports/artifacts
|
138
138
|
|
139
139
|
def initialize
|
140
140
|
@output = $stdout
|
@@ -4,15 +4,14 @@ module TestProf
|
|
4
4
|
module AnyFixture
|
5
5
|
# Adds "global" `fixture` method (through refinement)
|
6
6
|
module DSL
|
7
|
-
|
7
|
+
# Refine object, 'cause refining modules (Kernel) is vulnerable to prepend:
|
8
|
+
# - https://bugs.ruby-lang.org/issues/13446
|
9
|
+
# - Rails added `Kernel.prepend` in 6.1: https://github.com/rails/rails/commit/3124007bd674dcdc9c3b5c6b2964dfb7a1a0733c
|
10
|
+
refine ::Object do
|
8
11
|
def fixture(id, &block)
|
9
12
|
::TestProf::AnyFixture.register(:"#{id}", &block)
|
10
13
|
end
|
11
14
|
end
|
12
|
-
|
13
|
-
refine Kernel do
|
14
|
-
include Ext
|
15
|
-
end
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
data/lib/test_prof/before_all.rb
CHANGED
@@ -5,11 +5,13 @@ module TestProf
|
|
5
5
|
# Disable Isolator within before_all blocks
|
6
6
|
module Isolator
|
7
7
|
def begin_transaction(*)
|
8
|
-
::Isolator.
|
8
|
+
::Isolator.transactions_threshold += 1
|
9
|
+
super
|
9
10
|
end
|
10
11
|
|
11
|
-
def
|
12
|
-
|
12
|
+
def rollback_transaction(*)
|
13
|
+
super
|
14
|
+
::Isolator.transactions_threshold -= 1
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
data/lib/test_prof/event_prof.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "test_prof"
|
4
3
|
require "test_prof/rspec_stamp"
|
5
4
|
require "test_prof/event_prof/profiler"
|
6
5
|
require "test_prof/event_prof/instrumentations/active_support"
|
@@ -35,7 +34,7 @@ module TestProf
|
|
35
34
|
}.freeze
|
36
35
|
|
37
36
|
attr_accessor :instrumenter, :top_count, :per_example,
|
38
|
-
|
37
|
+
:rank_by, :event
|
39
38
|
|
40
39
|
def initialize
|
41
40
|
@event = ENV["EVENT_PROF"]
|
@@ -4,7 +4,7 @@ module TestProf
|
|
4
4
|
module EventProf
|
5
5
|
class Profiler # :nodoc:
|
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 per_example? per_example
|
10
10
|
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
module TestProf
|
4
4
|
# Ruby 2.3 #bsearch_index method (for usage with older Rubies)
|
5
|
-
#
|
6
|
-
# just for
|
5
|
+
# Straightforward and non-optimal implementation,
|
6
|
+
# just for compatibility
|
7
7
|
module ArrayBSearchIndex
|
8
8
|
refine Array do
|
9
9
|
def bsearch_index(&block)
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "test_prof"
|
4
3
|
require "test_prof/factory_bot"
|
5
4
|
require "test_prof/factory_doctor/factory_bot_patch"
|
6
5
|
require "test_prof/factory_doctor/fabrication_patch"
|
@@ -67,6 +66,8 @@ module TestProf
|
|
67
66
|
def init
|
68
67
|
reset!
|
69
68
|
|
69
|
+
@running = false
|
70
|
+
|
70
71
|
log :info, "FactoryDoctor enabled (event: \"#{config.event}\", threshold: #{config.threshold})"
|
71
72
|
|
72
73
|
# Monkey-patch FactoryBot / FactoryGirl
|
@@ -24,11 +24,13 @@ module TestProf::FactoryProf
|
|
24
24
|
Total time: #{format("%.4f", total_time)}s
|
25
25
|
Total uniq factories: #{total_uniq_factories}
|
26
26
|
|
27
|
-
total top-level
|
27
|
+
total top-level total time time per call top-level time name
|
28
28
|
MSG
|
29
29
|
|
30
30
|
result.stats.each do |stat|
|
31
|
-
|
31
|
+
time_per_call = stat[:total_time] / stat[:total_count]
|
32
|
+
|
33
|
+
msgs << format("%8d %11d %13.4fs %17.4fs %18.4fs %18s", stat[:total_count], stat[:top_level_count], stat[:total_time], time_per_call, stat[:top_level_time], stat[:name])
|
32
34
|
end
|
33
35
|
|
34
36
|
log :info, msgs.join("\n")
|
@@ -127,20 +127,22 @@ module TestProf
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
130
|
+
if defined?(::ActiveRecord)
|
131
|
+
require "test_prof/ext/active_record_refind"
|
132
|
+
using TestProf::Ext::ActiveRecordRefind
|
133
|
+
|
134
|
+
TestProf::LetItBe.configure do |config|
|
135
|
+
config.register_modifier :reload do |record, val|
|
136
|
+
next record unless val
|
137
|
+
next record unless record.is_a?(::ActiveRecord::Base)
|
138
|
+
record.reload
|
139
|
+
end
|
139
140
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
141
|
+
config.register_modifier :refind do |record, val|
|
142
|
+
next record unless val
|
143
|
+
next record unless record.is_a?(::ActiveRecord::Base)
|
144
|
+
record.refind
|
145
|
+
end
|
144
146
|
end
|
145
147
|
end
|
146
148
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "test_prof"
|
4
3
|
require "test_prof/rspec_stamp"
|
5
4
|
require "test_prof/logging"
|
6
5
|
|
@@ -37,7 +36,7 @@ module TestProf
|
|
37
36
|
MODES = %w[all let before].freeze
|
38
37
|
|
39
38
|
attr_accessor :top_count, :let_stats_enabled,
|
40
|
-
|
39
|
+
:let_top_count
|
41
40
|
|
42
41
|
alias let_stats_enabled? let_stats_enabled
|
43
42
|
|
data/lib/test_prof/ruby_prof.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "test_prof"
|
4
|
-
|
5
3
|
module TestProf
|
6
4
|
# RubyProf wrapper.
|
7
5
|
#
|
@@ -48,9 +46,9 @@ module TestProf
|
|
48
46
|
LOGFILE_PREFIX = "ruby-prof-report"
|
49
47
|
|
50
48
|
attr_accessor :printer, :mode, :min_percent,
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
:include_threads, :exclude_common_methods,
|
50
|
+
:test_prof_exclusions_enabled,
|
51
|
+
:custom_exclusions
|
54
52
|
|
55
53
|
def initialize
|
56
54
|
@printer = ENV["TEST_RUBY_PROF"].to_sym if PRINTERS.key?(ENV["TEST_RUBY_PROF"])
|
data/lib/test_prof/stack_prof.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "test_prof"
|
4
|
-
|
5
3
|
module TestProf
|
6
4
|
# StackProf wrapper.
|
7
5
|
#
|
@@ -133,6 +131,7 @@ module TestProf
|
|
133
131
|
|
134
132
|
def init_stack_prof
|
135
133
|
return @initialized if instance_variable_defined?(:@initialized)
|
134
|
+
@locked = false
|
136
135
|
@initialized = TestProf.require(
|
137
136
|
"stackprof",
|
138
137
|
<<~MSG
|
data/lib/test_prof/tag_prof.rb
CHANGED
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.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.16'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.16'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,33 +81,19 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '5.9'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubocop
|
84
|
+
name: rubocop
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 0.72.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: standard
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 0.1.0
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 0.1.0
|
96
|
+
version: 0.72.0
|
111
97
|
description: "\n Ruby applications tests profiling tools.\n\n Contains tools
|
112
98
|
to analyze factories usage, integrate with Ruby profilers,\n profile your examples
|
113
99
|
using ActiveSupport notifications (if any) and\n statically analyze your code
|