Changes between Version 43 and Version 44 of ip2c


Ignore:
Timestamp:
Aug 30, 2008, 1:05:31 PM (13 years ago)
Author:
omry
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ip2c

    v43 v44  
    11= IP2C =
    22IP2C is a small library that provides IP to country resolution using a binary file.[[BR]]
    3 The binary file is compiled from [http://ip-to-country.webhosting.info/ ip-to-country] free database and takes only about 500kb (the CSV takes about 3.5mb).[[BR]]
     3IP2C supports the following :
     4 * Webhosting.info : [http://ip-to-country.webhosting.info/ download database]
     5 * Software77 : [http://software77.net/cgi-bin/ip-country/geo-ip.pl download database]
     6The CSV file from those sources is converted into a highly efficient binary format:[[BR]]
     7 * Webhosting.info database is converted from a ~5MB CSV to a ~550k binary.
     8 * Software77 database is converted from a ~5mb CSV to ~250k binary.
    49
    510== License ==
     
    1217
    1318== Performance ==
    14 All tests done on an Athlon XP 3200+.[[BR]]
     19All tests done on an Intel(R) Core(TM)2 Duo CPU E8400  @ 3.00GH[[BR]]
    1520'''PHP:'''
    16  * '''No cache:''' About 1200 searches in a second.
    17  * '''Cache:''' not implemented (Want to help?)
     21 * '''No cache:''' 5000 searches/sec (Fast startup, slow query)
     22 * '''Memory cache:'''  : 5700 searches/sec (Slow startup, fastest query)
    1823'''Java:'''
    19  * '''No cache:''' About 8000 searches/second.
    20  * '''Memory cache:''' About 180,000 searches/second.
     24 * '''No cache:''' 13900 searches/second. (Fast startup, slow query)
     25 * '''Memory mapped file:''' 265k searches/second. (Fast startup, fast query)
     26 * '''Memory cache:''' 281k searches/second. (Slow startup, fastest query)
     27
    2128
    2229== Download ==
    23 [http://admin.firestats.cc/ccount/click.php?id=23 ip2c 1.4.3] (Database version : '''2008.06.09''')[[BR]]
     30[http://admin.firestats.cc/ccount/click.php?id=73 ip2c 2.0.0] (Database version : '''2008.07.21''')[[BR]]
    2431See the [wiki:ip2c-changelog changelog].
    25 
    26 
    2732
    2833== Source ==
    2934[source:/trunk/ip2c Browse source]
    30 
    3135
    3236== Command line (requires java in path) ==
     
    3438To resolve an IP address:
    3539{{{
    36 java -jar ip2c.jar ip-address
     40java -jar ip2c.jar -r ip-address
    3741}}}
    3842Output format:
     
    4549Example:
    4650{{{
    47 java -jar ip2c.jar 85.64.225.159
     51java -jar ip2c.jar -r 85.64.225.159
    4852}}}
    4953Outputs:
     
    5256
    5357To build binary file from CSV:
    54 java -jar ip2c csv_file bin_file
     58{{{
     59java -jar ip2c -c csv_file [bin_file]
     60}}}
     61bin_file is optional, if not specified, file.csv will be converted to file.bin.
     62
    5563
    5664== Java code ==
     
    5866#!java
    5967String ip = 85.64.225.159;
    60 boolean cache = true; // true will load the file into memory, using around 460k ram. (much faster)
    61 IP2Country ip2c = new IP2Country(cache);
     68int caching1 = IP2Country.NO_CACHE;  // Straight on file, Fastest startup, slowest queries
     69int caching2 = IP2Country.MEMORY_MAPPED; // Memory mapped file, fast startup, fast quries.
     70int caching3 = IP2Country.MEMORY_CACHE; // load file into memory, slowerst startup, fastest queries
     71IP2Country ip2c = new IP2Country(caching1);
    6272Country c = ip2c.getCountry(ip);
    6373if (c == null)
     
    7888<?php
    7989require_once('ip2c.php');
    80 
    81 $ip2c = new ip2country();
     90$caching = false;
     91$ip2c = new ip2country($caching);
    8292$res = $ip2c->get_country("85.64.225.159");
    8393if ($res == false)