Class: RSpec::Core::Notifications::ProfileNotification
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/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
-
#duration ⇒ Float
the time taken (in seconds) to run the suite.
-
#example_groups ⇒ Array<RSpec::Core::Profiler>
example groups run.
-
#examples ⇒ Array<RSpec::Core::Example>
the examples run.
-
#number_of_examples ⇒ Fixnum
the number of examples to profile.
Instance Method Summary collapse
-
#initialize(duration, examples, number_of_examples, example_groups) ⇒ ProfileNotification
constructor
A new instance of ProfileNotification.
-
#percentage ⇒ String
The percentage of total time taken.
-
#slow_duration ⇒ Float
The time taken (in seconds) to run the slowest examples.
-
#slowest_examples ⇒ Array<RSpec::Core::Example>
The slowest examples.
-
#slowest_groups ⇒ Array<RSpec::Core::Example>
The slowest example groups.
Constructor Details
#initialize(duration, examples, number_of_examples, example_groups) ⇒ ProfileNotification
Returns a new instance of ProfileNotification.
428 429 430 431 432 433 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/notifications.rb', line 428 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
#duration ⇒ Float
the time taken (in seconds) to run the suite
427 428 429 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/notifications.rb', line 427 def duration @duration end |
#example_groups ⇒ Array<RSpec::Core::Profiler>
example groups run
427 428 429 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/notifications.rb', line 427 def example_groups @example_groups end |
#examples ⇒ Array<RSpec::Core::Example>
the examples run
427 428 429 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/notifications.rb', line 427 def examples @examples end |
#number_of_examples ⇒ Fixnum
the number of examples to profile
427 428 429 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/notifications.rb', line 427 def number_of_examples @number_of_examples end |
Instance Method Details
#percentage ⇒ String
Returns the percentage of total time taken.
453 454 455 456 457 458 459 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/notifications.rb', line 453 def percentage @percentage ||= begin time_taken = slow_duration / duration '%.1f' % ((time_taken.nan? ? 0.0 : time_taken) * 100) end end |
#slow_duration ⇒ Float
Returns the time taken (in seconds) to run the slowest examples.
445 446 447 448 449 450 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/notifications.rb', line 445 def slow_duration @slow_duration ||= slowest_examples.inject(0.0) do |i, e| i + e.execution_result.run_time end end |
#slowest_examples ⇒ Array<RSpec::Core::Example>
Returns the slowest examples.
437 438 439 440 441 442 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/notifications.rb', line 437 def slowest_examples @slowest_examples ||= examples.sort_by do |example| -example.execution_result.run_time end.first(number_of_examples) end |
#slowest_groups ⇒ Array<RSpec::Core::Example>
Returns the slowest example groups.
462 463 464 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/notifications.rb', line 462 def slowest_groups @slowest_groups ||= calculate_slowest_groups end |