File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,9 @@ func TestRegister_covariance(t *testing.T) {
180
180
}
181
181
182
182
func Benchmark_average (b * testing.B ) {
183
+ sqlite3 .Initialize ()
184
+ b .ResetTimer ()
185
+
183
186
db , err := sqlite3 .Open (":memory:" )
184
187
if err != nil {
185
188
b .Fatal (err )
@@ -211,6 +214,9 @@ func Benchmark_average(b *testing.B) {
211
214
}
212
215
213
216
func Benchmark_variance (b * testing.B ) {
217
+ sqlite3 .Initialize ()
218
+ b .ResetTimer ()
219
+
214
220
db , err := sqlite3 .Open (":memory:" )
215
221
if err != nil {
216
222
b .Fatal (err )
Original file line number Diff line number Diff line change 28
28
RuntimeConfig wazero.RuntimeConfig
29
29
)
30
30
31
+ // Initialize decodes and compiles the SQLite Wasm binary.
32
+ // This is called implicitly when the first connection is openned,
33
+ // but is potentially slow, so you may want to call it at a more convenient time.
34
+ func Initialize () error {
35
+ instance .once .Do (compileSQLite )
36
+ return instance .err
37
+ }
38
+
31
39
var instance struct {
32
40
runtime wazero.Runtime
33
41
compiled wazero.CompiledModule
@@ -79,9 +87,8 @@ type sqlite struct {
79
87
}
80
88
81
89
func instantiateSQLite () (sqlt * sqlite , err error ) {
82
- instance .once .Do (compileSQLite )
83
- if instance .err != nil {
84
- return nil , instance .err
90
+ if err := Initialize (); err != nil {
91
+ return nil , err
85
92
}
86
93
87
94
sqlt = new (sqlite )
Original file line number Diff line number Diff line change @@ -141,6 +141,9 @@ func TestChildProcess(t *testing.T) {
141
141
}
142
142
143
143
func Benchmark_memdb (b * testing.B ) {
144
+ sqlite3 .Initialize ()
145
+ b .ResetTimer ()
146
+
144
147
memdb .Delete ("test.db" )
145
148
name := "file:/test.db?vfs=memdb"
146
149
testParallel (b , name , b .N )
You can’t perform that action at this time.
0 commit comments