-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark.rb
38 lines (29 loc) · 949 Bytes
/
benchmark.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true
require "bundler/setup"
require "benchmark"
require "sidekiq"
require_relative "lib/sidekiq/encrypted_args"
class WorkerWithoutEncryption
include Sidekiq::Worker
def perform(arg_1, arg_2, arg_3)
end
end
class WorkerWithEncryption
include Sidekiq::Worker
sidekiq_options encrypted_args: [true, true, true]
def perform(arg_1, arg_2, arg_3)
end
end
middleware = ->(worker_class) {
job = {"args" => ["foo", "bar", "baz"]}
Sidekiq::EncryptedArgs::ClientMiddleware.new.call(worker_class, job, "default") do
worker = worker_class.new
Sidekiq::EncryptedArgs::ServerMiddleware.new.call(worker, job, "default") do
worker.perform(*job["args"])
end
end
}
Benchmark.bm do |benchmark|
benchmark.report("No Encryption: ") { 10000.times { middleware.call(WorkerWithoutEncryption) } }
benchmark.report("With Encryption:") { 10000.times { middleware.call(WorkerWithEncryption) } }
end