@@ -6,36 +6,15 @@ module Formatters
6
6
# @api private
7
7
# Formatter for providing profile output.
8
8
class ProfileFormatter
9
- Formatters . register self , :dump_profile , :example_group_started , :example_group_finished , :example_started
9
+ Formatters . register self , :dump_profile
10
10
11
11
def initialize ( output )
12
- @example_groups = { } #todo rename, maybe groups_data, groups_information or profile_information
13
12
@output = output
14
13
end
15
14
16
15
# @private
17
16
attr_reader :output
18
17
19
- # @private
20
- def example_group_started ( notification )
21
- @example_groups [ notification . group . id ] = Hash . new ( 0 )
22
- @example_groups [ notification . group . id ] [ :start ] = Time . now
23
- @example_groups [ notification . group . id ] [ :description ] = notification . group . top_level_description
24
- end
25
-
26
- # @private
27
- def example_group_finished ( notification )
28
- @example_groups [ notification . group . id ] [ :total_time ] = Time . now - @example_groups [ notification . group . id ] [ :start ]
29
- end
30
-
31
- # @private
32
- def example_started ( notification )
33
- #todo: maybe move example_group.parent_groups.last to an example or notification method like example.last_anscestor_group
34
- group = notification . example . example_group . parent_groups . last . id
35
- @example_groups [ group ] [ :count ] += 1
36
- end
37
-
38
-
39
18
# @api public
40
19
#
41
20
# This method is invoked after the dumping the summary if profiling is
@@ -63,11 +42,10 @@ def dump_profile_slowest_examples(profile)
63
42
end
64
43
65
44
def dump_profile_slowest_example_groups ( profile )
66
- slowest_groups = profile . calculate_slowest_groups ( @example_groups )
67
- return if slowest_groups . empty?
45
+ return if profile . slowest_groups . empty?
68
46
69
- @output . puts "\n Top #{ slowest_groups . size } slowest example groups:"
70
- slowest_groups . each do |loc , hash |
47
+ @output . puts "\n Top #{ profile . slowest_groups . size } slowest example groups:"
48
+ profile . slowest_groups . each do |loc , hash |
71
49
average = "#{ bold ( Helpers . format_seconds ( hash [ :average ] ) ) } #{ bold ( "seconds" ) } average"
72
50
total = "#{ Helpers . format_seconds ( hash [ :total_time ] ) } seconds"
73
51
count = Helpers . pluralize ( hash [ :count ] , "example" )
0 commit comments