-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
sqlite: create options benchmarks #61401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+101
−0
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| 'use strict'; | ||
| const common = require('../common.js'); | ||
| const sqlite = require('node:sqlite'); | ||
| const assert = require('assert'); | ||
|
|
||
| const bench = common.createBenchmark(main, { | ||
| n: [1e5], | ||
| tableSeedSize: [1e5], | ||
| statement: [ | ||
| 'SELECT 1', | ||
| 'SELECT * FROM foo LIMIT 1', | ||
| 'SELECT * FROM foo LIMIT 100', | ||
| 'SELECT text_column FROM foo LIMIT 1', | ||
| 'SELECT text_column FROM foo LIMIT 100', | ||
| 'SELECT text_column, integer_column FROM foo LIMIT 1', | ||
| 'SELECT text_column, integer_column FROM foo LIMIT 100', | ||
| 'SELECT text_column, integer_column, real_column FROM foo LIMIT 1', | ||
| 'SELECT text_column, integer_column, real_column FROM foo LIMIT 100', | ||
| 'SELECT text_column, integer_column, real_column, blob_column FROM foo LIMIT 1', | ||
| 'SELECT text_column, integer_column, real_column, blob_column FROM foo LIMIT 100', | ||
| 'SELECT text_8kb_column FROM foo_large LIMIT 1', | ||
| 'SELECT text_8kb_column FROM foo_large LIMIT 100', | ||
| ], | ||
| }); | ||
|
|
||
| function main(conf) { | ||
| const db = new sqlite.DatabaseSync(':memory:', { | ||
| returnArrays: true, | ||
| }); | ||
|
|
||
| // Create only the necessary table for the benchmark type. | ||
| // If the statement includes 'foo_large', create the foo_large table; otherwise, create the foo table. | ||
| if (conf.statement.includes('foo_large')) { | ||
| db.exec('CREATE TABLE foo_large (text_8kb_column TEXT)'); | ||
| const fooLargeInsertStatement = db.prepare( | ||
| 'INSERT INTO foo_large (text_8kb_column) VALUES (?)', | ||
| ); | ||
| const largeText = 'a'.repeat(8 * 1024); | ||
| for (let i = 0; i < conf.tableSeedSize; i++) { | ||
| fooLargeInsertStatement.run(largeText); | ||
| } | ||
| } else { | ||
| db.exec( | ||
| 'CREATE TABLE foo (text_column TEXT, integer_column INTEGER, real_column REAL, blob_column BLOB)', | ||
| ); | ||
| const fooInsertStatement = db.prepare( | ||
| 'INSERT INTO foo (text_column, integer_column, real_column, blob_column) VALUES (?, ?, ?, ?)', | ||
| ); | ||
|
|
||
| for (let i = 0; i < conf.tableSeedSize; i++) { | ||
| fooInsertStatement.run( | ||
| crypto.randomUUID(), | ||
| Math.floor(Math.random() * 100), | ||
| Math.random(), | ||
| Buffer.from('example blob data'), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| let i; | ||
| let deadCodeElimination; | ||
|
|
||
| const stmt = db.prepare(conf.statement); | ||
|
|
||
| bench.start(); | ||
| for (i = 0; i < conf.n; i += 1) deadCodeElimination = stmt.all(); | ||
| bench.end(conf.n); | ||
|
|
||
| assert.ok(deadCodeElimination !== undefined); | ||
| } |
71 changes: 71 additions & 0 deletions
71
benchmark/sqlite/sqlite-prepare-select-all-bigint-arrays.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| 'use strict'; | ||
| const common = require('../common.js'); | ||
| const sqlite = require('node:sqlite'); | ||
| const assert = require('assert'); | ||
|
|
||
| const bench = common.createBenchmark(main, { | ||
| n: [1e5], | ||
| tableSeedSize: [1e5], | ||
| statement: [ | ||
| 'SELECT 1', | ||
| 'SELECT * FROM foo LIMIT 1', | ||
| 'SELECT * FROM foo LIMIT 100', | ||
| 'SELECT text_column FROM foo LIMIT 1', | ||
| 'SELECT text_column FROM foo LIMIT 100', | ||
| 'SELECT text_column, integer_column FROM foo LIMIT 1', | ||
| 'SELECT text_column, integer_column FROM foo LIMIT 100', | ||
| 'SELECT text_column, integer_column, real_column FROM foo LIMIT 1', | ||
| 'SELECT text_column, integer_column, real_column FROM foo LIMIT 100', | ||
| 'SELECT text_column, integer_column, real_column, blob_column FROM foo LIMIT 1', | ||
| 'SELECT text_column, integer_column, real_column, blob_column FROM foo LIMIT 100', | ||
| 'SELECT text_8kb_column FROM foo_large LIMIT 1', | ||
| 'SELECT text_8kb_column FROM foo_large LIMIT 100', | ||
| ], | ||
| }); | ||
|
|
||
| function main(conf) { | ||
| const db = new sqlite.DatabaseSync(':memory:', { | ||
| returnArrays: true, | ||
| readBigInts: true, | ||
| }); | ||
|
|
||
| // Create only the necessary table for the benchmark type. | ||
| // If the statement includes 'foo_large', create the foo_large table; otherwise, create the foo table. | ||
| if (conf.statement.includes('foo_large')) { | ||
| db.exec('CREATE TABLE foo_large (text_8kb_column TEXT)'); | ||
| const fooLargeInsertStatement = db.prepare( | ||
| 'INSERT INTO foo_large (text_8kb_column) VALUES (?)', | ||
| ); | ||
| const largeText = 'a'.repeat(8 * 1024); | ||
| for (let i = 0; i < conf.tableSeedSize; i++) { | ||
| fooLargeInsertStatement.run(largeText); | ||
| } | ||
| } else { | ||
| db.exec( | ||
| 'CREATE TABLE foo (text_column TEXT, integer_column INTEGER, real_column REAL, blob_column BLOB)', | ||
| ); | ||
| const fooInsertStatement = db.prepare( | ||
| 'INSERT INTO foo (text_column, integer_column, real_column, blob_column) VALUES (?, ?, ?, ?)', | ||
| ); | ||
|
|
||
| for (let i = 0; i < conf.tableSeedSize; i++) { | ||
| fooInsertStatement.run( | ||
| crypto.randomUUID(), | ||
| Math.floor(Math.random() * 100), | ||
| Math.random(), | ||
| Buffer.from('example blob data'), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| let i; | ||
| let deadCodeElimination; | ||
|
|
||
| const stmt = db.prepare(conf.statement); | ||
|
|
||
| bench.start(); | ||
| for (i = 0; i < conf.n; i += 1) deadCodeElimination = stmt.all(); | ||
| bench.end(conf.n); | ||
|
|
||
| assert.ok(deadCodeElimination !== undefined); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| 'use strict'; | ||
| const common = require('../common.js'); | ||
| const sqlite = require('node:sqlite'); | ||
| const assert = require('assert'); | ||
|
|
||
| const bench = common.createBenchmark(main, { | ||
| n: [1e5], | ||
| tableSeedSize: [1e5], | ||
| statement: [ | ||
| 'SELECT 1', | ||
| 'SELECT * FROM foo LIMIT 1', | ||
| 'SELECT * FROM foo LIMIT 100', | ||
| 'SELECT integer_column FROM foo LIMIT 1', | ||
| 'SELECT integer_column FROM foo LIMIT 100', | ||
| ], | ||
| }); | ||
|
|
||
| function main(conf) { | ||
| const db = new sqlite.DatabaseSync(':memory:', { | ||
| readBigInts: true, | ||
| }); | ||
|
|
||
| db.exec('CREATE TABLE foo (integer_column INTEGER)'); | ||
|
|
||
| const fooInsertStatement = db.prepare( | ||
| 'INSERT INTO foo (integer_column) VALUES (?)', | ||
| ); | ||
|
|
||
| for (let i = 0; i < conf.tableSeedSize; i++) { | ||
| fooInsertStatement.run(Math.floor(Math.random() * 100)); | ||
| } | ||
|
|
||
| let i; | ||
| let deadCodeElimination; | ||
|
|
||
| const stmt = db.prepare(conf.statement); | ||
|
|
||
| bench.start(); | ||
| for (i = 0; i < conf.n; i += 1) deadCodeElimination = stmt.all(); | ||
| bench.end(conf.n); | ||
|
|
||
| assert.ok(deadCodeElimination !== undefined); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.