You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This directory contains benchmark scripts to measure and compare the performance of different SQLite operations in `@homeofthings/sqlite3`.
3
+
This directory contains benchmark scripts to measure and compare the performance of different SQLite operations in `@homeofthings/sqlite3` using [tinybench](https://github.com/tinylibs/tinybench).
4
+
5
+
## Key Features
6
+
7
+
-**Proper setup/teardown separation**: Database creation, table creation, and data population happen in `beforeEach` (not measured)
8
+
-**Only actual operations measured**: The benchmark functions contain only the INSERT/SELECT operations
9
+
-**Warmup support**: tinybench includes warmup iterations to allow V8 optimization
10
+
-**Statistical accuracy**: Multiple iterations with mean, variance, and margin of error
4
11
5
12
## Running Benchmarks
6
13
7
14
### Quick Start
8
15
9
-
Install the benchmark dependencies:
16
+
Install dependencies (from project root):
10
17
11
18
```bash
12
-
cd tools/benchmark
13
-
npm install
19
+
yarn install
14
20
```
15
21
16
22
Run all benchmarks:
17
23
18
24
```bash
19
-
node run.js
25
+
node tools/benchmark/run.js
20
26
```
21
27
22
-
### Manual Execution
23
-
24
-
You can also run individual benchmark scripts directly:
28
+
Or from the benchmark directory:
25
29
26
30
```bash
27
-
node insert.js
28
-
node select.js
31
+
cd tools/benchmark
32
+
node run.js
29
33
```
30
34
31
35
## Benchmark Scripts
32
36
33
37
### run.js (Recommended)
34
38
35
39
The main runner script executes all benchmarks and provides detailed timing statistics including:
36
-
-.ops/sec (operations per second)
40
+
-ops/sec (operations per second)
37
41
- Mean and margin of error
38
42
- Sample variance
39
43
@@ -42,22 +46,24 @@ The main runner script executes all benchmarks and provides detailed timing stat
42
46
Measures performance of different data insertion approaches.
43
47
44
48
**Benchmark tests:**
45
-
-`insert literal file`: Executes SQL from a file using `db.exec()`
46
-
-`insert with transaction and two statements`: Uses parallelized statements within a transaction
47
-
-`insert with transaction`: Uses a single statement within a transaction
48
-
-`insert without transaction`: Uses a single statement without explicit transaction
49
+
-`insert: literal file`: Executes SQL from a file using `db.exec()`
50
+
-`insert: transaction with two statements`: Uses parallelized statements within a transaction
51
+
-`insert: with transaction`: Uses a single statement within a transaction
52
+
-`insert: without transaction`: Uses a single statement without explicit transaction
0 commit comments