Class: RSpec::Core::Notifications::ProfileNotification
- Inherits:
-
Object
- Object
- RSpec::Core::Notifications::ProfileNotification
- Defined in:
- lib/rspec/core/notifications.rb
Overview
The ProfileNotification
holds information about the results of running a
test suite when profiling is enabled. It is used by formatters to provide
information at the end of the test run for profiling information.
Instance Attribute Summary (collapse)
-
- (Float) duration
the time taken (in seconds) to run the suite.
-
- (Array<RSpec::Core::Profiler>) example_groups
example groups run.
-
- (Array<RSpec::Core::Example>) examples
the examples run.
-
- (Fixnum) number_of_examples
the number of examples to profile.
Instance Method Summary (collapse)
-
- (ProfileNotification) initialize(duration, examples, number_of_examples, example_groups)
constructor
A new instance of ProfileNotification.
-
- (String) percentage
The percentage of total time taken.
-
- (Float) slow_duration
The time taken (in seconds) to run the slowest examples.
-
- (Array<RSpec::Core::Example>) slowest_examples
The slowest examples.
-
- (Array<RSpec::Core::Example>) slowest_groups
The slowest example groups.
Constructor Details
- (ProfileNotification) initialize(duration, examples, number_of_examples, example_groups)
Returns a new instance of ProfileNotification
406 407 408 409 410 411 |
# File 'lib/rspec/core/notifications.rb', line 406 def initialize(duration, examples, number_of_examples, example_groups) @duration = duration @examples = examples @number_of_examples = number_of_examples @example_groups = example_groups end |
Instance Attribute Details
- (Float) duration
the time taken (in seconds) to run the suite
405 406 407 |
# File 'lib/rspec/core/notifications.rb', line 405 def duration @duration end |
- (Array<RSpec::Core::Profiler>) example_groups
example groups run
405 406 407 |
# File 'lib/rspec/core/notifications.rb', line 405 def example_groups @example_groups end |
- (Array<RSpec::Core::Example>) examples
the examples run
405 406 407 |
# File 'lib/rspec/core/notifications.rb', line 405 def examples @examples end |
- (Fixnum) number_of_examples
the number of examples to profile
405 406 407 |
# File 'lib/rspec/core/notifications.rb', line 405 def number_of_examples @number_of_examples end |
Instance Method Details
- (String) percentage
Returns the percentage of total time taken
431 432 433 434 435 436 437 |
# File 'lib/rspec/core/notifications.rb', line 431 def percentage @percentage ||= begin time_taken = slow_duration / duration '%.1f' % ((time_taken.nan? ? 0.0 : time_taken) * 100) end end |
- (Float) slow_duration
Returns the time taken (in seconds) to run the slowest examples
423 424 425 426 427 428 |
# File 'lib/rspec/core/notifications.rb', line 423 def slow_duration @slow_duration ||= slowest_examples.inject(0.0) do |i, e| i + e.execution_result.run_time end end |
- (Array<RSpec::Core::Example>) slowest_examples
Returns the slowest examples
415 416 417 418 419 420 |
# File 'lib/rspec/core/notifications.rb', line 415 def slowest_examples @slowest_examples ||= examples.sort_by do |example| -example.execution_result.run_time end.first(number_of_examples) end |
- (Array<RSpec::Core::Example>) slowest_groups
Returns the slowest example groups
440 441 442 |
# File 'lib/rspec/core/notifications.rb', line 440 def slowest_groups @slowest_groups ||= calculate_slowest_groups end |