forked from benlowry/node-geoip-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
executable file
·69 lines (55 loc) · 1.18 KB
/
Copy pathtest.js
File metadata and controls
executable file
·69 lines (55 loc) · 1.18 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var geoip = require('./geoip.js')
// var geoip = require("geoip-lite");
var test1 = true
function test () {
var total = 0
var numtests = 20
var numiterations = 1000000
console.log('starting test: ' + (test1 ? 'geoip-native' : 'geoip-lite'))
for (var t = 0; t < numtests; t++) {
var start = new Date().getTime()
for (var i = 0; i < numiterations; i++) {
var o1 = 1 + Math.round(Math.random() * 254)
var o2 = 1 + Math.round(Math.random() * 254)
var o3 = 1 + Math.round(Math.random() * 254)
var o4 = 1 + Math.round(Math.random() * 254)
var ip = o1 + '.' + o2 + '.' + o3 + '.' + o4
geoip.lookup(ip)
}
var finish = new Date().getTime()
if (t > 4 && t < 15) {
total += finish - start
console.log('time ' + (finish - start))
}
}
console.log('average: ' + total / 10)
if (!test1) {
}
}
setTimeout(test, 3000)
/*
benchmark results:
geoip-native
time 1500
time 1824
time 1526
time 1495
time 1543
time 1509
time 1511
time 1492
time 1505
time 1498
average: 1540.3
geoip-lite
time 8339
time 8335
time 8314
time 8327
time 8631
time 8315
time 8512
time 8303
time 8416
time 8261
average: 8375.3 */