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

Function main

benchmark/sqlite/sqlite-prepare-insert.js:19–100  ·  view source on GitHub ↗
(conf)

Source from the content-addressed store, hash-verified

17});
18
19function main(conf) {
20 const db = new sqlite.DatabaseSync(':memory:');
21
22 db.exec('CREATE TABLE text_column_type (text_column TEXT)');
23 db.exec('CREATE TABLE integer_column_type (integer_column INTEGER)');
24 db.exec('CREATE TABLE real_column_type (real_column REAL)');
25 db.exec('CREATE TABLE blob_column_type (blob_column BLOB)');
26 db.exec(
27 'CREATE TABLE all_column_types (text_column TEXT, integer_column INTEGER, real_column REAL, blob_column BLOB)',
28 );
29 db.exec('CREATE TABLE large_text (text_8kb_column TEXT)');
30 db.exec('CREATE TABLE missing_required_value (any_value TEXT, required_value TEXT NOT NULL)');
31
32 const insertStatement = db.prepare(conf.statement);
33
34 let i;
35 let deadCodeElimination;
36
37 const stringValue = crypto.randomUUID();
38 const integerValue = Math.floor(Math.random() * 100);
39 const realValue = Math.random();
40 const blobValue = Buffer.from('example blob data');
41
42 const largeText = 'a'.repeat(8 * 1024);
43
44 if (conf.statement.includes('text_column_type')) {
45 bench.start();
46 for (i = 0; i < conf.n; i += 1) {
47 deadCodeElimination = insertStatement.run(stringValue);
48 }
49 bench.end(conf.n);
50 } else if (conf.statement.includes('integer_column_type')) {
51 bench.start();
52 for (i = 0; i < conf.n; i += 1) {
53 deadCodeElimination = insertStatement.run(integerValue);
54 }
55 bench.end(conf.n);
56 } else if (conf.statement.includes('real_column_type')) {
57 bench.start();
58 for (i = 0; i < conf.n; i += 1) {
59 deadCodeElimination = insertStatement.run(realValue);
60 }
61 bench.end(conf.n);
62 } else if (conf.statement.includes('blob_column_type')) {
63 bench.start();
64 for (i = 0; i < conf.n; i += 1) {
65 deadCodeElimination = insertStatement.run(blobValue);
66 }
67 bench.end(conf.n);
68 } else if (conf.statement.includes('INTO all_column_types')) {
69 bench.start();
70 for (i = 0; i < conf.n; i += 1) {
71 deadCodeElimination = insertStatement.run(
72 stringValue,
73 integerValue,
74 realValue,
75 blobValue,
76 );

Callers

nothing calls this directly

Calls 9

randomMethod · 0.80
includesMethod · 0.80
execMethod · 0.45
prepareMethod · 0.45
fromMethod · 0.45
startMethod · 0.45
runMethod · 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…