test-prof 1.3.0 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/minitest/test_prof_plugin.rb +3 -0
- data/lib/test_prof/factory_prof/printers/json.rb +41 -0
- data/lib/test_prof/factory_prof.rb +3 -0
- data/lib/test_prof/tag_prof/minitest.rb +74 -0
- data/lib/test_prof/tag_prof/result.rb +2 -2
- data/lib/test_prof/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed617176a00461b30a96b07f086b52ea89d28fff7d1e4b085110e1b2333b6c60
|
4
|
+
data.tar.gz: c2e425a439407505f4ac1ecbfe25d84517343d7e9d7f1260ce675382f3ee6f1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3548abd19a6f283dd230e340a0651fc2196b7253bc4fcf4f5115d53a3e55b35e43ece87a875d4267a00edfa5105c303365bc1b7e9f787a0fcd5d3d8ffd86634b
|
7
|
+
data.tar.gz: 911ed9f79a48b4fd72b1ea7885f2eb5d3f75410421946cdd61966b9ffc50a245bb1f0c88b93b256ec5b06159267b16ccfcf129c06fde3d021605f1b15375c7cf
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 1.3.2 (2024-03-08) 🌷
|
6
|
+
|
7
|
+
- Add Minitest support for TagProf. ([@lioneldebauge][])
|
8
|
+
|
9
|
+
## 1.3.1 (2023-12-12)
|
10
|
+
|
11
|
+
- Add support for dumping FactoryProf results in JSON format. ([@uzushino][])
|
12
|
+
|
5
13
|
## 1.3.0 (2023-11-21)
|
6
14
|
|
7
15
|
- Add Vernier integration. ([@palkan][])
|
@@ -376,3 +384,5 @@ See [changelog](https://github.com/test-prof/test-prof/blob/v0.8.0/CHANGELOG.md)
|
|
376
384
|
[@peret]: https://github.com/peret
|
377
385
|
[@bf4]: https://github.com/bf4
|
378
386
|
[@Vankiru]: https://github.com/Vankiru
|
387
|
+
[@uzushino]: https://github.com/uzushino
|
388
|
+
[@lioneldebauge]: https://github.com/lioneldebauge
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require "test_prof/event_prof/minitest"
|
4
4
|
require "test_prof/factory_doctor/minitest"
|
5
5
|
require "test_prof/memory_prof/minitest"
|
6
|
+
require "test_prof/tag_prof/minitest"
|
6
7
|
|
7
8
|
module Minitest # :nodoc:
|
8
9
|
module TestProf # :nodoc:
|
@@ -16,6 +17,7 @@ module Minitest # :nodoc:
|
|
16
17
|
opts[:sample] = true if ENV["SAMPLE"] || ENV["SAMPLE_GROUPS"]
|
17
18
|
opts[:mem_prof_mode] = ENV["TEST_MEM_PROF"] if ENV["TEST_MEM_PROF"]
|
18
19
|
opts[:mem_prof_top_count] = ENV["TEST_MEM_PROF_COUNT"] if ENV["TEST_MEM_PROF_COUNT"]
|
20
|
+
opts[:tag_prof] = true if ENV["TAG_PROF"] == "type"
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
@@ -50,6 +52,7 @@ module Minitest # :nodoc:
|
|
50
52
|
reporter << TestProf::EventProfReporter.new(options[:io], options) if options[:event]
|
51
53
|
reporter << TestProf::FactoryDoctorReporter.new(options[:io], options) if options[:fdoc]
|
52
54
|
reporter << TestProf::MemoryProfReporter.new(options[:io], options) if options[:mem_prof_mode]
|
55
|
+
reporter << Minitest::TestProf::TagProfReporter.new(options[:io], options) if options[:tag_prof]
|
53
56
|
|
54
57
|
::TestProf::MinitestSample.call if options[:sample]
|
55
58
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_prof/ext/float_duration"
|
4
|
+
|
5
|
+
module TestProf::FactoryProf
|
6
|
+
module Printers
|
7
|
+
module Json # :nodoc: all
|
8
|
+
class << self
|
9
|
+
using TestProf::FloatDuration
|
10
|
+
include TestProf::Logging
|
11
|
+
|
12
|
+
def dump(result, start_time:)
|
13
|
+
return log(:info, "No factories detected") if result.raw_stats == {}
|
14
|
+
|
15
|
+
outpath = TestProf.artifact_path("test-prof.result.json")
|
16
|
+
File.write(outpath, convert_stats(result, start_time).to_json)
|
17
|
+
|
18
|
+
log :info, "Profile results to JSON: #{outpath}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def convert_stats(result, start_time)
|
22
|
+
total_run_time = TestProf.now - start_time
|
23
|
+
total_count = result.stats.sum { |stat| stat[:total_count] }
|
24
|
+
total_top_level_count = result.stats.sum { |stat| stat[:top_level_count] }
|
25
|
+
total_time = result.stats.sum { |stat| stat[:top_level_time] }
|
26
|
+
total_uniq_factories = result.stats.map { |stat| stat[:name] }.uniq.count
|
27
|
+
|
28
|
+
{
|
29
|
+
total_count: total_count,
|
30
|
+
total_top_level_count: total_top_level_count,
|
31
|
+
total_time: total_time.duration,
|
32
|
+
total_run_time: total_run_time.duration,
|
33
|
+
total_uniq_factories: total_uniq_factories,
|
34
|
+
|
35
|
+
stats: result.stats
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require "test_prof/factory_prof/printers/simple"
|
4
4
|
require "test_prof/factory_prof/printers/flamegraph"
|
5
5
|
require "test_prof/factory_prof/printers/nate_heckler"
|
6
|
+
require "test_prof/factory_prof/printers/json"
|
6
7
|
require "test_prof/factory_prof/factory_builders/factory_bot"
|
7
8
|
require "test_prof/factory_prof/factory_builders/fabrication"
|
8
9
|
|
@@ -25,6 +26,8 @@ module TestProf
|
|
25
26
|
Printers::Flamegraph
|
26
27
|
when "nate_heckler"
|
27
28
|
Printers::NateHeckler
|
29
|
+
when "json"
|
30
|
+
Printers::Json
|
28
31
|
else
|
29
32
|
Printers::Simple
|
30
33
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Minitest
|
4
|
+
module TestProf
|
5
|
+
class TagProfReporter < BaseReporter # :nodoc:
|
6
|
+
attr_reader :results
|
7
|
+
|
8
|
+
def initialize(io = $stdout, _options = {})
|
9
|
+
super
|
10
|
+
@results = ::TestProf::TagProf::Result.new("type")
|
11
|
+
|
12
|
+
if event_prof_activated?
|
13
|
+
require "test_prof/event_prof"
|
14
|
+
@current_group_id = nil
|
15
|
+
@events_profiler = configure_profiler
|
16
|
+
@results = ::TestProf::TagProf::Result.new("type", @events_profiler.events)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def prerecord(group, example)
|
21
|
+
return unless event_prof_activated?
|
22
|
+
|
23
|
+
# enable event profiling
|
24
|
+
@events_profiler.group_started(true)
|
25
|
+
end
|
26
|
+
|
27
|
+
def record(result)
|
28
|
+
results.track(main_folder_path(result), time: result.time, events: fetch_events_data)
|
29
|
+
@events_profiler.group_started(nil) if event_prof_activated? # reset and disable event profilers
|
30
|
+
end
|
31
|
+
|
32
|
+
def report
|
33
|
+
printer = (ENV["TAG_PROF_FORMAT"] == "html") ? ::TestProf::TagProf::Printers::HTML : ::TestProf::TagProf::Printers::Simple
|
34
|
+
printer.dump(results)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def main_folder_path(result)
|
40
|
+
return :__unknown__ if absolute_path_from(result).nil?
|
41
|
+
|
42
|
+
absolute_path_from(result)
|
43
|
+
end
|
44
|
+
|
45
|
+
def absolute_path_from(result)
|
46
|
+
absolute_path = File.expand_path(result.source_location.first)
|
47
|
+
absolute_path.slice(/(?<=(?:spec|test)\/)\w*/)
|
48
|
+
end
|
49
|
+
|
50
|
+
def configure_profiler
|
51
|
+
::TestProf::EventProf::CustomEvents.activate_all(tag_prof_event)
|
52
|
+
::TestProf::EventProf.build(tag_prof_event)
|
53
|
+
end
|
54
|
+
|
55
|
+
def event_prof_activated?
|
56
|
+
return false if tag_prof_event.nil?
|
57
|
+
|
58
|
+
!tag_prof_event.empty?
|
59
|
+
end
|
60
|
+
|
61
|
+
def tag_prof_event
|
62
|
+
ENV["TAG_PROF_EVENT"]
|
63
|
+
end
|
64
|
+
|
65
|
+
def fetch_events_data
|
66
|
+
return {} unless @events_profiler
|
67
|
+
|
68
|
+
@events_profiler.profilers.map do |profiler|
|
69
|
+
[profiler.event, profiler.time || 0.0]
|
70
|
+
end.to_h
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
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.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- lib/test_prof/factory_prof/factory_builders/factory_bot.rb
|
178
178
|
- lib/test_prof/factory_prof/nate_heckler.rb
|
179
179
|
- lib/test_prof/factory_prof/printers/flamegraph.rb
|
180
|
+
- lib/test_prof/factory_prof/printers/json.rb
|
180
181
|
- lib/test_prof/factory_prof/printers/nate_heckler.rb
|
181
182
|
- lib/test_prof/factory_prof/printers/simple.rb
|
182
183
|
- lib/test_prof/logging.rb
|
@@ -212,6 +213,7 @@ files:
|
|
212
213
|
- lib/test_prof/stack_prof.rb
|
213
214
|
- lib/test_prof/stack_prof/rspec.rb
|
214
215
|
- lib/test_prof/tag_prof.rb
|
216
|
+
- lib/test_prof/tag_prof/minitest.rb
|
215
217
|
- lib/test_prof/tag_prof/printers/html.rb
|
216
218
|
- lib/test_prof/tag_prof/printers/simple.rb
|
217
219
|
- lib/test_prof/tag_prof/result.rb
|