PaddeK / node-maxmind-db

This is the pure Node API for reading MaxMind DB files. MaxMind DB is a binary file format that stores data indexed by IP address subnets (IPv4 or IPv6).
GNU Lesser General Public License v2.1
88 stars 25 forks source link

Is it really async? #19

Open msukhotin opened 8 years ago

msukhotin commented 8 years ago

Hi

I'm trying the following code:

var log = require('debug')('app:maxmind'),
    mmdbreader = require('maxmind-db-reader');

log('preparing');
var cities = mmdbreader.openSync('./data/GeoIP2-City.mmdb');
log('ready');
for (i=1; i<250; i++) {
    cities.getGeoData('5.'+i+'.143.20', function(err,geodata){
        if (!err && geodata && geodata.city)
            log(geodata.city.geoname_id);
    });
}
  app:maxmind preparing +0ms
  app:maxmind ready +81ms
  app:maxmind 677697 +181ms
  app:maxmind 680963 +1ms
  app:maxmind 287286 +1ms
  app:maxmind 745044 +0ms
  app:maxmind 745044 +0ms
  app:maxmind 295548 +0ms
  app:maxmind 294071 +0ms
  app:maxmind 292223 +0ms
  app:maxmind 287286 +1ms
  app:maxmind 3186886 +0ms
etc...

How could I explain why it took 181 ms to find first ip? Also results order is always the same.

knoxcard commented 5 years ago

https://github.com/runk/node-maxmind