test-prof 1.3.1 → 1.3.3
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 +9 -0
- data/lib/minitest/test_prof_plugin.rb +3 -0
- data/lib/test_prof/before_all.rb +1 -1
- data/lib/test_prof/memory_prof/printer.rb +2 -0
- data/lib/test_prof/memory_prof/rspec.rb +7 -4
- data/lib/test_prof/memory_prof/tracker/linked_list.rb +8 -6
- data/lib/test_prof/memory_prof/tracker.rb +14 -10
- 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 +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a719a17544a705f447aeefc448f75bb2ffc11c268661735c11095b593e0d9417
|
4
|
+
data.tar.gz: 3d461a0c4573a0a7c43a7db57b8ecce96baf2c1a60998f56019c437a20ad1f60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0549376752f1b0e6d718333f2e378c2d0cd3bee94a18f52440c0110710f9ab9bc1a23aaaadcd84e1cbf1171402d11cd4eaa98718bbc736cfdcc3f50740cc7e89'
|
7
|
+
data.tar.gz: 3f6546e3d091b6c0aba067d94c12bfd1bf8542d0725b851f06cac81b8507685de4ef7ca25bd38b2bec9b2a98f21c99cfddd68997dca90ab739bbc3f19820fef6
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 1.3.3 (2024-04-19)
|
6
|
+
|
7
|
+
- Fix MemProf bugs. ([@palkan][])
|
8
|
+
|
9
|
+
## 1.3.2 (2024-03-08) 🌷
|
10
|
+
|
11
|
+
- Add Minitest support for TagProf. ([@lioneldebauge][])
|
12
|
+
|
5
13
|
## 1.3.1 (2023-12-12)
|
6
14
|
|
7
15
|
- Add support for dumping FactoryProf results in JSON format. ([@uzushino][])
|
@@ -381,3 +389,4 @@ See [changelog](https://github.com/test-prof/test-prof/blob/v0.8.0/CHANGELOG.md)
|
|
381
389
|
[@bf4]: https://github.com/bf4
|
382
390
|
[@Vankiru]: https://github.com/Vankiru
|
383
391
|
[@uzushino]: https://github.com/uzushino
|
392
|
+
[@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
|
data/lib/test_prof/before_all.rb
CHANGED
@@ -16,23 +16,26 @@ module TestProf
|
|
16
16
|
@tracker = MemoryProf.tracker
|
17
17
|
@printer = MemoryProf.printer(tracker)
|
18
18
|
|
19
|
+
@current_group = nil
|
20
|
+
@current_example = nil
|
21
|
+
|
19
22
|
@tracker.start
|
20
23
|
end
|
21
24
|
|
22
25
|
def example_started(notification)
|
23
|
-
tracker.example_started(example(notification))
|
26
|
+
tracker.example_started(notification.example, example(notification))
|
24
27
|
end
|
25
28
|
|
26
29
|
def example_finished(notification)
|
27
|
-
tracker.example_finished(example
|
30
|
+
tracker.example_finished(notification.example)
|
28
31
|
end
|
29
32
|
|
30
33
|
def example_group_started(notification)
|
31
|
-
tracker.group_started(group(notification))
|
34
|
+
tracker.group_started(notification.group, group(notification))
|
32
35
|
end
|
33
36
|
|
34
37
|
def example_group_finished(notification)
|
35
|
-
tracker.group_finished(group
|
38
|
+
tracker.group_finished(notification.group)
|
36
39
|
end
|
37
40
|
|
38
41
|
def report
|
@@ -52,19 +52,20 @@ module TestProf
|
|
52
52
|
attr_reader :head
|
53
53
|
|
54
54
|
def initialize(memory_at_start)
|
55
|
-
add_node(:total, memory_at_start)
|
55
|
+
add_node(:total, :total, memory_at_start)
|
56
56
|
end
|
57
57
|
|
58
|
-
def add_node(item, memory_at_start)
|
58
|
+
def add_node(id, item, memory_at_start)
|
59
59
|
@head = LinkedListNode.new(
|
60
|
+
id: id,
|
60
61
|
item: item,
|
61
62
|
previous: head,
|
62
63
|
memory_at_start: memory_at_start
|
63
64
|
)
|
64
65
|
end
|
65
66
|
|
66
|
-
def remove_node(
|
67
|
-
return if head.
|
67
|
+
def remove_node(id, memory_at_finish)
|
68
|
+
return if head.id != id
|
68
69
|
head.finish(memory_at_finish)
|
69
70
|
|
70
71
|
current = head
|
@@ -75,9 +76,10 @@ module TestProf
|
|
75
76
|
end
|
76
77
|
|
77
78
|
class LinkedListNode
|
78
|
-
attr_reader :item, :previous, :memory_at_start, :memory_at_finish, :nested_memory
|
79
|
+
attr_reader :id, :item, :previous, :memory_at_start, :memory_at_finish, :nested_memory
|
79
80
|
|
80
|
-
def initialize(item:, memory_at_start:, previous:)
|
81
|
+
def initialize(id:, item:, memory_at_start:, previous:)
|
82
|
+
@id = id
|
81
83
|
@item = item
|
82
84
|
@previous = previous
|
83
85
|
|
@@ -36,22 +36,26 @@ module TestProf
|
|
36
36
|
@total_memory = node.total_memory
|
37
37
|
end
|
38
38
|
|
39
|
-
def example_started(example)
|
40
|
-
list.add_node(example, track)
|
39
|
+
def example_started(id, example = id)
|
40
|
+
list.add_node(id, example, track)
|
41
41
|
end
|
42
42
|
|
43
|
-
def example_finished(
|
44
|
-
node = list.remove_node(
|
45
|
-
|
43
|
+
def example_finished(id)
|
44
|
+
node = list.remove_node(id, track)
|
45
|
+
return unless node
|
46
|
+
|
47
|
+
examples << {**node.item, memory: node.total_memory}
|
46
48
|
end
|
47
49
|
|
48
|
-
def group_started(group)
|
49
|
-
list.add_node(group, track)
|
50
|
+
def group_started(id, group = id)
|
51
|
+
list.add_node(id, group, track)
|
50
52
|
end
|
51
53
|
|
52
|
-
def group_finished(
|
53
|
-
node = list.remove_node(
|
54
|
-
|
54
|
+
def group_finished(id)
|
55
|
+
node = list.remove_node(id, track)
|
56
|
+
return unless node
|
57
|
+
|
58
|
+
groups << {**node.item, memory: node.hooks_memory}
|
55
59
|
end
|
56
60
|
end
|
57
61
|
|
@@ -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.3
|
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:
|
11
|
+
date: 2024-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -213,6 +213,7 @@ files:
|
|
213
213
|
- lib/test_prof/stack_prof.rb
|
214
214
|
- lib/test_prof/stack_prof/rspec.rb
|
215
215
|
- lib/test_prof/tag_prof.rb
|
216
|
+
- lib/test_prof/tag_prof/minitest.rb
|
216
217
|
- lib/test_prof/tag_prof/printers/html.rb
|
217
218
|
- lib/test_prof/tag_prof/printers/simple.rb
|
218
219
|
- lib/test_prof/tag_prof/result.rb
|
@@ -234,7 +235,7 @@ metadata:
|
|
234
235
|
homepage_uri: https://test-prof.evilmartians.io/
|
235
236
|
source_code_uri: https://github.com/test-prof/test-prof
|
236
237
|
funding_uri: https://github.com/sponsors/test-prof
|
237
|
-
post_install_message:
|
238
|
+
post_install_message:
|
238
239
|
rdoc_options: []
|
239
240
|
require_paths:
|
240
241
|
- lib
|
@@ -249,8 +250,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
249
250
|
- !ruby/object:Gem::Version
|
250
251
|
version: '0'
|
251
252
|
requirements: []
|
252
|
-
rubygems_version: 3.4.
|
253
|
-
signing_key:
|
253
|
+
rubygems_version: 3.4.19
|
254
|
+
signing_key:
|
254
255
|
specification_version: 4
|
255
256
|
summary: Ruby applications tests profiling tools
|
256
257
|
test_files: []
|