refactor: mem cache puts optimization
This commit is contained in:
committed by
Piotr Pędziwiatr
parent
fd7a63db6d
commit
1f35fe6ce5
27
tools/map-benchmark.ts
Normal file
27
tools/map-benchmark.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/* eslint-disable */
|
||||
import Arweave from 'arweave';
|
||||
import { LoggerFactory } from '../src';
|
||||
import { TsLogFactory } from '../src/logging/node/TsLogFactory';
|
||||
|
||||
async function main() {
|
||||
LoggerFactory.use(new TsLogFactory());
|
||||
|
||||
LoggerFactory.INST.logLevel('debug');
|
||||
|
||||
console.time('benchmark_map');
|
||||
const map = new Map();
|
||||
for (let i = 0; i < 10_000_000; i++) {
|
||||
map.set(i, 'duh');
|
||||
}
|
||||
console.timeEnd('benchmark_map');
|
||||
|
||||
console.time('benchmark_object');
|
||||
const o = {};
|
||||
for (let i = 0; i < 10_000_000; i++) {
|
||||
o[i] = 'duh';
|
||||
}
|
||||
console.timeEnd('benchmark_object');
|
||||
console.log(Object.keys(o).length);
|
||||
}
|
||||
|
||||
main().catch((e) => console.error(e));
|
||||
Reference in New Issue
Block a user