Re: ip-to-country - summary
| From: | Gabor Hojtsy | Date: | Wed, 30 Apr 2003 09:34:28 +0000 |
| Subject: | Re: ip-to-country - summary | ||
| References: | 1 | Groups: | php.mirrors |
| Request: | Send a blank email to php-mirrors+get-17149@lists.php.net to get a copy of this message | ||
> I have uploaded a file in the above format at the following
> location for you'll to try out:
> http://beta.ip-to-country.com/php.net/ip-to-country.zip
>
> The first two fields are 10 bytes each, therefore the fixed
> size of each record is (2*10+3+1) bytes. The file that was
> used to map the 2 letter alpha country codes to 3 letter
> alpha country codes is available at:
> http://beta.ip-to-country.com/php.net/Alpha2_to_Alpha3.txt
Well, I have created some code to index this db,
and search in it. My tests with the search without
index resulted in the 0.1-0.7 seconds time range. The
last Japan entry was found in approx 0.7 seconds.
Unhappy with the results, I have created a simple indexer
(the one I have explained you before), indexing the ip numbers
with 10^6 granularity. It resulted in much better speeds to
search in the index first and then in the db. Then I found
out, that having the index 10^7 granularity produces a very
small index (one kilobyte!), and even better speed results.
I have used simple linear search in both the index and the
db, so this is why a smaller index also means better results,
given that the IP ranges are quite wide.
Now there are 0.03-0.05 seconds needed to find out a
country if an IP address is given. Speed measures were
taken on a windows machine, I'll do the same measures on
Linux when I get home.
Is this speed ok for phpweb?
Goba