MCPcopy Index your code
hub / github.com/nodejs/node / main

Function main

benchmark/misc/freelist.js:11–40  ·  view source on GitHub ↗
({ n })

Source from the content-addressed store, hash-verified

9});
10
11function main({ n }) {
12 let FreeList = require('internal/freelist');
13 if (FreeList.FreeList)
14 FreeList = FreeList.FreeList;
15 const poolSize = 1000;
16 const list = new FreeList('test', poolSize, Object);
17 let j;
18 const used = [];
19
20 // First, alloc `poolSize` items
21 for (j = 0; j < poolSize; j++) {
22 used.push(list.alloc());
23 }
24
25 bench.start();
26
27 for (let i = 0; i < n; i++) {
28 // Return all the items to the pool
29 for (j = 0; j < poolSize; j++) {
30 list.free(used[j]);
31 }
32
33 // Re-alloc from pool
34 for (j = 0; j < poolSize; j++) {
35 list.alloc();
36 }
37 }
38
39 bench.end(n);
40}

Callers

nothing calls this directly

Calls 6

allocMethod · 0.95
freeMethod · 0.95
requireFunction · 0.50
pushMethod · 0.45
startMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…