Files
notification-elements-demo/node_modules/weak-lru-cache/tests/benchmark.js
Giuliano Silvestro 5d0c9ec7eb Initial commit: notification-elements-demo app
Interactive Angular 19 demo for @sda/notification-elements-ui with
6 sections: Bell & Feed, Notification Center, Inbox, Comments &
Threads, Mention Input, and Full-Featured layout. Includes mock
data, dark mode toggle, and real-time event log.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 21:49:19 +10:00

47 lines
1.0 KiB
JavaScript

var inspector = require('inspector')
//inspector.open(9330, null, true)
var benchmark = require('benchmark')
const { WeakLRUCache } = require('..')
var suite = new benchmark.Suite();
let cache = new WeakLRUCache()
cache.loadValue = function() {
return {}
}
let strongObject = cache.getValue(1)
function hit() {
let o = cache.getValue(1)
}
let i = 0
let time = 0
function miss(deferred) {
i++
cache.getValue(i)
if (i % 30000== 0) {
let lastTime = time
time = Date.now()
sizes.push(cache.size, time-lastTime)
return setImmediate(() => deferred.resolve(), 10)
}
if (i % 100 == 0)
return Promise.resolve().then(() => deferred.resolve())
deferred.resolve()
}
let sizes = []
//suite.add('hit', hit);
suite.add('miss', {
defer: true,
fn: miss,
})
suite.on('cycle', function (event) {
console.log(String(event.target));
});
suite.on('complete', function () {
console.log('Fastest is ' + this.filter('fastest').map('name'));
console.log(JSON.stringify(sizes))
});
suite.run({ async: true });