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

Function main

benchmark/sqlite/sqlite-prepare-select-all.js:26–68  ·  view source on GitHub ↗
(conf)

Source from the content-addressed store, hash-verified

24});
25
26function main(conf) {
27 const db = new sqlite.DatabaseSync(':memory:');
28
29 // Create only the necessary table for the benchmark type.
30 // If the statement includes 'foo_large', create the foo_large table; otherwise, create the foo table.
31 if (conf.statement.includes('foo_large')) {
32 db.exec('CREATE TABLE foo_large (text_8kb_column TEXT)');
33 const fooLargeInsertStatement = db.prepare(
34 'INSERT INTO foo_large (text_8kb_column) VALUES (?)',
35 );
36 const largeText = 'a'.repeat(8 * 1024);
37 for (let i = 0; i < conf.tableSeedSize; i++) {
38 fooLargeInsertStatement.run(largeText);
39 }
40 } else {
41 db.exec(
42 'CREATE TABLE foo (text_column TEXT, integer_column INTEGER, real_column REAL, blob_column BLOB)',
43 );
44 const fooInsertStatement = db.prepare(
45 'INSERT INTO foo (text_column, integer_column, real_column, blob_column) VALUES (?, ?, ?, ?)',
46 );
47
48 for (let i = 0; i < conf.tableSeedSize; i++) {
49 fooInsertStatement.run(
50 crypto.randomUUID(),
51 Math.floor(Math.random() * 100),
52 Math.random(),
53 Buffer.from('example blob data'),
54 );
55 }
56 }
57
58 let i;
59 let deadCodeElimination;
60
61 const stmt = db.prepare(conf.statement);
62
63 bench.start();
64 for (i = 0; i < conf.n; i += 1) deadCodeElimination = stmt.all();
65 bench.end(conf.n);
66
67 assert.ok(deadCodeElimination !== undefined);
68}

Callers

nothing calls this directly

Calls 10

includesMethod · 0.80
randomMethod · 0.80
allMethod · 0.80
execMethod · 0.45
prepareMethod · 0.45
runMethod · 0.45
fromMethod · 0.45
startMethod · 0.45
endMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…