Skip to content

animehunter/erlang-geoip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GeoIP by Hunter

How to build the driver:
Open up VC command prompt
type in makevc.bat

Makefiles for other platforms are welcomed :)

download latest geoip (GeoIP.dat) country database from http://www.maxmind.com/app/geolitecountry

This driver offers high performance for ip to country lookup in Erlang.

Currently it's able to do ~1,200,000 (1.2 million) lookups per second on an AMD 2ghz cpu.

%%
%% Basic Usage:
%%
%% > Geoip = geoip:new("GeoIP.dat").
%% #Port<0.2755>
%%
%% > geoip:get_country_by_ip(Geoip, "24.24.24.24").
%% "United States"
%%
%% > geoip:get_country_by_ip(Geoip, <<"80.24.24.80">>).
%% "Spain"
%%
%% > geoip:delete(Geoip).
%% ok
%%

%%
%% Advanced usage:
%%
%% > Geoip = geoip:new("GeoIP.dat").
%% #Port<0.2755>
%%
%% > geoip:use_binary(Geoip).
%% []
%%
%% > geoip:get_country_by_ip(Geoip, "24.24.24.24").
%% <<"United States">>
%%
%% > geoip:get_country_by_ip(Geoip, "invalidip").
%% []
%%
%% > geoip:use_string(Geoip).                      
%% []
%%
%% > geoip:get_country_by_ip(Geoip, "24.24.24.24").
%% "United States"
%%
%% > geoip:get_country_by_ip(Geoip, "invalidip").
%% []
%%
%% > geoip:delete(Geoip).
%% ok
%%

%%
%% Erlang benchmark
%%
%% > geoip:benchmark().
%% 100000 lookups for "? GEOIP_STANDARD": (2556 ms) 
%% 100000 lookups for "? GEOIP_CHECK_CACHE": (2435 ms) 
%% 1000000 lookups for "? GEOIP_MEMORY_CACHE": (890 ms) 
%% 1000000 lookups for "? GEOIP_MEMORY_CACHE bor ? GEOIP_CHECK_CACHE": (903 ms) 
%% 

%%
%% C Benchmark
%%
%% >benchmark.exe
%%
%% GeoIP Country
%% 120000 lookups made in 2.769962 seconds
%%
%% GeoIP Country with GEOIP_CHECK_CACHE
%% 120000 lookups made in 2.684795 seconds
%%
%% GeoIP Country with GEOIP_MEMORY_CACHE
%% 1200000 lookups made in 0.409928 seconds
%%
%% GeoIP Country with GEOIP_MEMORY_CACHE and GEOIP_CHECK_CACHE
%% 1200000 lookups made in 0.414053 seconds
%%

About

Erlang port driver for GeoIP Lite / GeoLite

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published