SAP-BTP-Spielwiese/app1/node_modules/lru-cache/benchmarks/insertion-time.js
Markus Rettig 775ac7b58c completed step 3 from the tutorial
you must login with an BTP account in order to see the app
2024-02-08 16:13:36 +01:00

32 lines
544 B
JavaScript

var LRU = require('../')
var uuid = require("uuid")
var start = Date.now()
var lru = new LRU({
max: 64 * 1024 * 1024, // 64MB
length: function (v) {
return v.key.length + v.value.length
}
})
var total = 0
console.log("Iters\tAvg\tBytes")
for (x = 0; x < 5000000; ++x) {
var d = new Date()
var key = uuid.v4()
lru.set(key, {
key: key,
value: uuid.v4()
})
total += new Date() - d
var length = lru.length
if (x % 10000 === 0) {
console.log(x + "\t" + (total / 10000) + "\t" + length)
total = 0
}
}