Class Spec::Runner::Formatter::ProfileFormatter

  1. lib/spec/runner/formatter/profile_formatter.rb

Methods

public class

  1. new

public instance

  1. example_passed
  2. example_started
  3. method_missing
  4. start
  5. start_dump

Public class methods

new (options, where)
[show source]
# File lib/spec/runner/formatter/profile_formatter.rb, line 8
        def initialize(options, where)
          super
          @example_times = []
        end

Public instance methods

example_passed (example)
[show source]
# File lib/spec/runner/formatter/profile_formatter.rb, line 21
        def example_passed(example)
          super
          @example_times << [
            example_group.description,
            example.description,
            Time.now - @time
          ]
        end
example_started (example)
[show source]
# File lib/spec/runner/formatter/profile_formatter.rb, line 17
        def example_started(example)
          @time = Time.now
        end
method_missing (sym, *args)
[show source]
# File lib/spec/runner/formatter/profile_formatter.rb, line 45
        def method_missing(sym, *args)
          # ignore
        end
start (count)
[show source]
# File lib/spec/runner/formatter/profile_formatter.rb, line 13
        def start(count)
          @output.puts "Profiling enabled."
        end
start_dump ()
[show source]
# File lib/spec/runner/formatter/profile_formatter.rb, line 30
        def start_dump
          super
          @output.puts "\n\nTop 10 slowest examples:\n"
          
          @example_times = @example_times.sort_by do |description, example, time|
            time
          end.reverse
          
          @example_times[0..9].each do |description, example, time|
            @output.print red(sprintf("%.7f", time))
            @output.puts " #{description} #{example}"
          end
          @output.flush
        end