(conf)
| 18 | }); |
| 19 | |
| 20 | function 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…