Sha256: 666c379c89d3de6dd7dad2ffe857c293ac24064a7b35d582498417458d4ddcb8

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

require 'coveralls'
Coveralls.wear! do
  add_filter '/test/'
end

require 'minitest/pride'

require 'bundler/setup'
require 'rack/test'

require 'sidekiq'
require 'sidekiq/util'
require 'sidekiq-benchmark'

REDIS = Sidekiq::RedisConnection.create url: "redis://localhost/15", namespace: "testy"

Bundler.require

module Sidekiq
  module Benchmark
    module Test

      class WorkerMock
        include Sidekiq::Worker
        include Sidekiq::Benchmark::Worker

        attr_reader :bm_obj, :metric_names, :assigned_metric

        def initialize
          @assigned_metric = 0.1

          benchmark do |bm|
            bm.test_metric do
              2.times do |i|
                bm.send("nested_test_metric_#{i}") do
                  100500.times do |i|
                  end
                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
            42.times do
            end
          end

          benchmark.other_metric do
            100500.times do
            end
          end

          @metric_names = [:test_metric, :other_metric]
        end

        def finish
          benchmark.finish
        end
      end

      def self.flush_db
        Sidekiq.redis = REDIS
        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.2.0 test/test_helper.rb