Sha256: 2b5e4177724f740a0c149aeb49daaef512df36a4282c7b2c677a1e8dac82b529

Contents?: true

Size: 690 Bytes

Versions: 2

Compression:

Stored size: 690 Bytes

Contents

module ActionLogic
  module ActionBenchmark

    module ClassMethods
      def with_benchmark(class_context, &block)
        if ActionConfiguration.benchmark?
          context = nil
          benchmark_result = Benchmark.measure { context = block.call }
          ActionConfiguration.benchmark_log.printf("%60s: %15s %15s %15s %15s\n", "Context", "User Time", "System Time", "Total Time", "Real Time")
          ActionConfiguration.benchmark_log.printf("%60s: %15f %15f %15f %15f\n\n", class_context, benchmark_result.utime, benchmark_result.stime, benchmark_result.total, benchmark_result.real)
          context
        else
          block.call
        end
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
action_logic-0.2.3 lib/action_logic/action_benchmark.rb
action_logic-0.2.2 lib/action_logic/action_benchmark.rb