-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbenchmark.js
More file actions
35 lines (27 loc) · 853 Bytes
/
benchmark.js
File metadata and controls
35 lines (27 loc) · 853 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
30
31
32
33
34
35
// Test script to make sure that speed and garbage collection is as expected
// > yarn build
// > node scripts/postinstall.js
// > node --expose-gc benchmark.js
const { geolocateIp } = require('./dist/src/index')
function printMemoryUsage() {
const used = process.memoryUsage().rss / 1024 / 1024
console.log(`Memory usage: ${Math.round(used * 100) / 100} MB`)
}
async function main() {
printMemoryUsage()
console.time('geolocateIp')
await geolocateIp('217.138.196.20')
console.timeEnd('geolocateIp')
printMemoryUsage()
console.time('geolocateIp')
await geolocateIp('217.138.196.20')
console.timeEnd('geolocateIp')
printMemoryUsage()
console.time('geolocateIp')
await geolocateIp('217.138.196.20')
console.timeEnd('geolocateIp')
printMemoryUsage()
global.gc()
setTimeout(() => printMemoryUsage(), 1000)
}
main()