Skip to content

Instantly share code, notes, and snippets.

@splattael
Last active December 16, 2015 08:18
Show Gist options
  • Save splattael/5404417 to your computer and use it in GitHub Desktop.
Save splattael/5404417 to your computer and use it in GitHub Desktop.
Benchmark lograge.
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