forked from runk/node-maxmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark.js
More file actions
29 lines (23 loc) · 774 Bytes
/
benchmark.js
File metadata and controls
29 lines (23 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var fs = require('fs');
var ls = require('./lib/lookup_service');
function randip() {
return [
Math.floor(Math.random() * 255),
Math.floor(Math.random() * 255),
Math.floor(Math.random() * 255),
Math.floor(Math.random() * 255)
].join('.');
}
ls.init('./test/dbs/GeoIPCity.dat', { memoryCache: true });
var ips = fs.readFileSync('./test/dbs/full/ips.txt');
ips = ips.toString().split("\n").map(function(line) {
return line.trim();
});
var n = ips.length;
var s = new Date().getTime();
for (var i = ips.length - 1; i >= 0; i--) {
ls.getLocation(ips[i]);
};
console.log('n: ', n);
console.log('time:', (new Date().getTime() - s), "msec");
console.log('speed:', Math.round(n / (new Date().getTime() - s) * 1000), 'per sec');