# class Benchmark::Suite

### Attributes

report[R]
reports[R]

### Public Class Methods

create() { |s| ... } click to toggle source

    # File lib/benchmark/suite.rb, line 11
    def self.create
      if block_given?
        old = @current

        begin
          s = new
          @current = s
          yield s
          return s
        ensure
          @current = old
        end
      else
        @current = new
      end
    end

current() click to toggle source

    # File lib/benchmark/suite.rb, line 7
    def self.current
      @current
    end

new() click to toggle source

    # File lib/benchmark/suite.rb, line 37
    def initialize
      @report = nil
      @reports = {}
      @order = []
      @quiet = false
      @verbose = false
    end

### Public Instance Methods

add_report(rep, location) click to toggle source

    # File lib/benchmark/suite.rb, line 70
    def add_report(rep, location)
      if @report
        @report << rep
      else
        @report = [rep]
      end

      @report_location = location
    end

display() click to toggle source

    # File lib/benchmark/suite.rb, line 107
    def display
      if @report
        file = @report_location ? @report_location.split(":").first : "<unknown.rb>"
        @order << file
        @reports[file] = [@report]
      end

      @order.each do |file|
        STDOUT.puts "#{file}:"
        reports = @reports[file]

        if reports.empty?
          STDOUT.puts "  NO REPORTS FOUND"
        else
          reports.each do |rep|
            STDOUT.puts "  #{rep}"
          end
        end
      end
    end

quiet!() click to toggle source

    # File lib/benchmark/suite.rb, line 47
    def quiet!
      @quiet = true
    end

quiet?() click to toggle source

    # File lib/benchmark/suite.rb, line 51
    def quiet?
      @quiet
    end

run(file) click to toggle source

    # File lib/benchmark/suite.rb, line 80
    def run(file)
      start = Time.now

      begin
        load file
      rescue Exception => e
        STDOUT.puts "\nError in #{file}:"
        if e.respond_to? :render
          e.render
        else
          STDOUT.puts e.backtrace
        end
        return
      end

      fin = Time.now

      if @report
        @reports[file] = @report
        @report = nil
      else
        @reports[file] = SimpleReport.new(start, fin)
      end

      @order << file
    end

running(label, sec) click to toggle source

    # File lib/benchmark/suite.rb, line 65
    def running(label, sec)
      return unless @verbose
      STDOUT.puts " running: #{sec}s..."
    end

warming(label, sec) click to toggle source

    # File lib/benchmark/suite.rb, line 55
    def warming(label, sec)
      return unless @verbose
      STDOUT.print "#{label.rjust(20)} warmup: #{sec}s"
    end

warmup_stats(time, cycles) click to toggle source

    # File lib/benchmark/suite.rb, line 60
    def warmup_stats(time, cycles)
      return unless @verbose
      STDOUT.print " time=#{time}us, cycles=#{cycles}."
    end