Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
hosted graphite/statsd performance
require 'benchmark'
require 'hosted_graphite'
HostedGraphite.api_key = 'API-KEY'
HostedGraphite.protocol = HostedGraphite::UDP
require 'hosted_graphite/statsd'
def do_single
HostedGraphite.increment "benchmark.incrementer"
end
def do_double
HostedGraphite.increment "benchmark.incrementer"
HostedGraphite.increment "benchmark.incrementer"
end
def do_gauge
HostedGraphite.gauge "benchmark.gauge", 25
end
n = 1000
Benchmark.bmbm do |x|
x.report("single inc") { n.times do; do_single; end }
x.report("double inc") { n.times do; do_double; end }
x.report("single gauge") { n.times do; do_gauge; end }
end
# user system total real
# single inc 0.110000 0.220000 0.330000 ( 5.949952)
# double inc 0.250000 0.450000 0.700000 ( 13.743122)
# single gauge 0.120000 0.210000 0.330000 ( 6.791644)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment