test-prof 1.5.0 → 1.6.0

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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/lib/{test_prof → rubocop/test_prof}/cops/rspec/aggregate_examples/matchers_with_side_effects.rb +1 -1
  4. data/lib/{test_prof → rubocop/test_prof}/cops/rspec/aggregate_examples/node_matchers.rb +1 -1
  5. data/lib/{test_prof → rubocop/test_prof}/cops/rspec/aggregate_examples.rb +5 -5
  6. data/lib/{test_prof/cops → rubocop/test_prof}/plugin.rb +2 -2
  7. data/lib/rubocop/test_prof.rb +9 -0
  8. data/lib/test-prof.rb +5 -0
  9. data/lib/test_prof/event_prof/custom_events/sidekiq_inline.rb +1 -1
  10. data/lib/test_prof/event_prof/custom_events/sidekiq_jobs.rb +1 -1
  11. data/lib/test_prof/memory_prof/printer.rb +31 -0
  12. data/lib/test_prof/memory_prof/rspec.rb +2 -0
  13. data/lib/test_prof/memory_prof/tracker.rb +11 -1
  14. data/lib/test_prof/memory_prof.rb +8 -3
  15. data/lib/test_prof/recipes/rspec/let_it_be.rb +1 -1
  16. data/lib/test_prof/rspec_dissect/collector.rb +58 -0
  17. data/lib/test_prof/rspec_dissect/rspec.rb +13 -21
  18. data/lib/test_prof/rspec_dissect.rb +45 -51
  19. data/lib/test_prof/rspec_stamp/parser/prism.rb +75 -0
  20. data/lib/test_prof/rspec_stamp/parser/ripper.rb +128 -0
  21. data/lib/test_prof/rspec_stamp/parser.rb +8 -120
  22. data/lib/test_prof/rspec_stamp.rb +1 -0
  23. data/lib/test_prof/rubocop.rb +10 -9
  24. data/lib/test_prof/tps_prof/profiler.rb +52 -15
  25. data/lib/test_prof/tps_prof/reporter/text.rb +27 -7
  26. data/lib/test_prof/tps_prof/rspec.rb +25 -2
  27. data/lib/test_prof/tps_prof.rb +69 -4
  28. data/lib/test_prof/version.rb +1 -1
  29. metadata +14 -13
  30. data/lib/test_prof/rspec_dissect/collectors/base.rb +0 -70
  31. data/lib/test_prof/rspec_dissect/collectors/before.rb +0 -19
  32. data/lib/test_prof/rspec_dissect/collectors/let.rb +0 -39
  33. /data/lib/{test_prof → rubocop/test_prof}/cops/rspec/aggregate_examples/its.rb +0 -0
  34. /data/lib/{test_prof → rubocop/test_prof}/cops/rspec/aggregate_examples/line_range_helpers.rb +0 -0
  35. /data/lib/{test_prof → rubocop/test_prof}/cops/rspec/aggregate_examples/metadata_helpers.rb +0 -0
  36. /data/lib/{test_prof → rubocop/test_prof}/cops/rspec/language.rb +0 -0
@@ -1,70 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "test_prof/utils/sized_ordered_set"
4
- require "test_prof/ext/float_duration"
5
- require "test_prof/ext/string_truncate"
6
-
7
- module TestProf # :nodoc: all
8
- using FloatDuration
9
- using StringTruncate
10
-
11
- module RSpecDissect
12
- module Collectors
13
- class Base
14
- attr_reader :results, :name, :top_count
15
-
16
- def initialize(name:, top_count:)
17
- @name = name
18
- @top_count = top_count
19
- @results = Utils::SizedOrderedSet.new(
20
- top_count, sort_by: name
21
- )
22
- end
23
-
24
- def populate!(data)
25
- data[name] = RSpecDissect.time_for(name)
26
- end
27
-
28
- def <<(data)
29
- results << data
30
- end
31
-
32
- def total_time
33
- RSpecDissect.total_time_for(name)
34
- end
35
-
36
- def total_time_message
37
- "\nTotal `#{print_name}` time: #{total_time.duration}"
38
- end
39
-
40
- def print_name
41
- name
42
- end
43
-
44
- def print_result_header
45
- <<~MSG
46
-
47
- Top #{top_count} slowest suites (by `#{print_name}` time):
48
-
49
- MSG
50
- end
51
-
52
- def print_group_result(group)
53
- <<~GROUP
54
- #{group[:desc].truncate} (#{group[:loc]}) – #{group[name].duration} of #{group[:total].duration} (#{group[:count]})
55
- GROUP
56
- end
57
-
58
- def print_results
59
- msgs = [print_result_header]
60
-
61
- results.each do |group|
62
- msgs << print_group_result(group)
63
- end
64
-
65
- msgs.join
66
- end
67
- end
68
- end
69
- end
70
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "test_prof/rspec_dissect/collectors/base"
4
-
5
- module TestProf
6
- module RSpecDissect
7
- module Collectors # :nodoc: all
8
- class Before < Base
9
- def initialize(params)
10
- super(name: :before, **params)
11
- end
12
-
13
- def print_name
14
- "before(:each)"
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "test_prof/rspec_dissect/collectors/base"
4
-
5
- module TestProf
6
- module RSpecDissect
7
- module Collectors # :nodoc: all
8
- class Let < Base
9
- def initialize(params)
10
- super(name: :let, **params)
11
- end
12
-
13
- def populate!(data)
14
- super
15
- data[:let_calls] = RSpecDissect.meta_for(name)
16
- end
17
-
18
- def print_results
19
- return unless RSpecDissect.memoization_available?
20
- super
21
- end
22
-
23
- def print_group_result(group)
24
- return super unless RSpecDissect.config.let_stats_enabled?
25
- msgs = [super]
26
- group[:let_calls]
27
- .group_by(&:itself)
28
- .map { |id, calls| [id, -calls.size] }
29
- .sort_by(&:last)
30
- .take(RSpecDissect.config.let_top_count)
31
- .each do |(id, size)|
32
- msgs << " ↳ #{id} – #{-size}\n"
33
- end
34
- msgs.join
35
- end
36
- end
37
- end
38
- end
39
- end