Relax City and Country database checks

The strict database checks broke the per-continent City databases,
and adding all of those to an array is a bit much (and slow).

Closes #23.
This commit is contained in:
Gregory Oschwald
2014-09-12 07:06:12 -07:00
parent 920a92f352
commit 2f9746c32b
2 changed files with 39 additions and 29 deletions
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env php
<?php
require_once '../vendor/autoload.php';
use GeoIp2\Database\Reader;
use GeoIp2\Exception\AddressNotFoundException;
$reader = new Reader('GeoLite2-City.mmdb');
$count = 40000;
$startTime = microtime(true);
for ($i = 0; $i < $count; $i++) {
$ip = long2ip(rand(0, pow(2, 32) -1));
try {
$t = $reader->city($ip);
} catch (AddressNotFoundException $e) {
}
if ($i % 1000 == 0) {
print($i . ' ' . $ip . "\n");
}
}
$endTime = microtime(true);
$duration = $endTime - $startTime;
print('Requests per second: ' . $count / $duration . "\n");