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

Function main

benchmark/sqlite/sqlite-prepare-select-get.js:20–62  ·  view source on GitHub ↗
(conf)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 10

includesMethod · 0.80
randomMethod · 0.80
getMethod · 0.65
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…