Skip to content

Instantly share code, notes, and snippets.

@anoobbava
Created August 12, 2022 07:13
Show Gist options
  • Select an option

  • Save anoobbava/714577ea0a30d712b12e73a9f0f7aebe to your computer and use it in GitHub Desktop.

Select an option

Save anoobbava/714577ea0a30d712b12e73a9f0f7aebe to your computer and use it in GitHub Desktop.

Revisions

  1. anoobbava created this gist Aug 12, 2022.
    18 changes: 18 additions & 0 deletions benchmark_evaluator.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    class BenchmarkEvaluator
    def initialize(count)
    @count = count
    end

    def execute
    results = {}
    Rails.logger.info '===== Enqueuing jobs'
    benchmark = "Enqueuing #{@count} ActiveJob jobs"
    results[benchmark] = Benchmark.measure do
    @count.times do |i|
    SampleJob.perform_later('hello')
    end
    end.real.round(2)
    Rails.logger.info "Duration: #{results[benchmark]} seconds"
    Rails.logger.info "Duration: #{results}"
    end
    end