jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
class Logger {
constructor(batchSize = 500, interval = 1000) {
this.cache = [];
this.batchSize = batchSize;
this.interval = interval;
this.startConsuming();
}
log(message) {
this.cache.push({
timestamp: new Date().toISOString(),
message: message
});
if (this.cache.length >= this.batchSize) {
this.consumeCache();
}
}
startConsuming() {
setInterval(() => {
if (this.cache.length > 0) {
this.consumeCache();
}
}, this.interval);
}
consumeCache() {
const batch = this.cache.splice(0, this.batchSize);
this.processBatch(batch);
}
processBatch(batch) {
console.log(`Processing batch of ${batch.length} records`);
// simulating write logs into rust-sdk
let logs_ = JSON.stringify(batch);
console.log(logs_);
}
}
// Usage example
const logger = new Logger(500, 1000);
const customLog = function(log) {
logger.log(log)
}
Ready to run.
Test | Ops/sec | |
---|---|---|
customLogger |
| ready |
Console.log |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.