Skip to content

Instantly share code, notes, and snippets.

@yoppi
Created July 15, 2015 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoppi/d6bd1402968fddc1bc69 to your computer and use it in GitHub Desktop.
Save yoppi/d6bd1402968fddc1bc69 to your computer and use it in GitHub Desktop.
geoip and geoip-c benchmark
require 'geoip'
require 'benchmark'
n = 1000000
# geoip-c C extended library
Benchmark.bm do |x|
geoip = GeoIP::City.new("/usr/share/GeoIP/GeoLiteCity.dat", :memory, false)
x.report { n.times { geoip.look_up("144.206.125.148") } }
# user system total real
# 10.480000 0.070000 10.550000 ( 10.604084)
end
# geoip pure Ruby implement
Benchmark.bm do |x|
geoip = GeoIP.new("/usr/share/GeoIP/GeoLiteCity.dat")
x.report { n.times { geoip.city("144.206.125.148") } }
# user system total real
# 104.030000 25.760000 129.790000 (132.106001)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment