Sha256: a10faee07b7df0f7941f33b69dae1c3c3f2cc140c8440d3d34779462e2bbb8e5
Contents?: true
Size: 1.97 KB
Versions: 1
Compression:
Stored size: 1.97 KB
Contents
require 'minitest/autorun' require 'minitest/pride' ENV['RACK_ENV'] = 'test' $TESTING = true require 'bundler/setup' require 'rack/test' require 'sidekiq' require 'sidekiq-benchmark' require 'delorean' require 'pry' Bundler.require Sidekiq.configure_server do |cfg| cfg.redis = {url: "redis://#{ENV['REDIS_HOST'] || 'localhost'}/15"} end Sidekiq.configure_client do |cfg| cfg.redis = {url: "redis://#{ENV['REDIS_HOST'] || 'localhost'}/15"} end module Sidekiq module Benchmark module Test class WorkerMock include Sidekiq::Worker include Sidekiq::Benchmark::Worker attr_reader :bm_obj, :metric_names, :assigned_metric, :counter def initialize @assigned_metric = 0.1 @counter = 0 benchmark do |bm| bm.test_metric do 2.times do |i| bm.send("nested_test_metric_#{i}") do Delorean.jump 1 @counter += 100500 end end end bm.assigned_metric @assigned_metric end @metric_names = [:test_metric, :nested_test_metric_1, :job_time] end end class AlterWorkerMock < WorkerMock def initialize benchmark.test_metric do Delorean.jump 1 end benchmark.other_metric do Delorean.jump 1 end @metric_names = [:test_metric, :other_metric] end def multiply(a, b) a * b end def finish benchmark.finish end end class ContinuingWorkerMock < WorkerMock def initialize benchmark do |bm| bm.continued_metric do Delorean.jump 1 end bm.continued_metric do Delorean.jump 1 end end end end def self.flush_db Sidekiq.redis do |conn| conn.flushdb end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-benchmark-0.7.3 | test/test_helper.rb |