Skip to content

Instantly share code, notes, and snippets.

@LTe
Created August 14, 2012 10:33
Show Gist options
  • Save LTe/3348067 to your computer and use it in GitHub Desktop.
Save LTe/3348067 to your computer and use it in GitHub Desktop.
require 'benchmark'
require 'exoteric'
counter = Exoteric.new(:url => 'http://github.com/')
Benchmark.bm do |x|
x.report { 10.times { counter.count(:twitter, :facebook, :plusone) } }
end
def count(*counters)
if counters.size == 0 || counters.first == :all
counters = self.class.counters
end
res = {}
threads = []
counters.each do |name|
threads << Thread.new do
res[name] = send("#{name}_count")
end
end
threads.map(&:join)
res
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment