Last active
December 16, 2015 08:18
-
-
Save splattael/5404417 to your computer and use it in GitHub Desktop.
Benchmark lograge.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark/ips' | |
class FakeEvent | |
attr_reader :payload, :duration | |
def initialize | |
@payload = { | |
path: '', | |
params: { | |
'controller' => 'foo', | |
'action' => 'bar' | |
} | |
} | |
@duration = 0.0 | |
end | |
end | |
class FakeLogger | |
def self.info(*) | |
end | |
def self.presence(*) | |
self | |
end | |
end | |
require 'action_pack' | |
require 'lograge' | |
Lograge.logger = FakeLogger | |
Lograge.formatter = Lograge::Formatters::KeyValue.new | |
subscriber = Lograge::RequestLogSubscriber.new | |
event = FakeEvent.new | |
# warm up | |
subscriber.process_action(event) | |
ips = 5.times.map do | |
# benchmark! | |
ips = Benchmark.ips do |x| | |
x.report 'process_action' do | |
subscriber.process_action(event) | |
end | |
end.entries.map(&:ips).min | |
end.min | |
puts "Result: #{ips}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment