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