Skip to content
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

only reset sqlite3 statement when necessary #13

Merged
merged 2 commits into from
Dec 18, 2024
Merged

Conversation

charlievieth
Copy link
Owner

This commit changes the bind logic to only reset the sqlite3 statement when necessary, which saves us a call to sqlite3_reset the first time the query is used.

goos: darwin
goarch: arm64
pkg: github.com/charlievieth/go-sqlite3
cpu: Apple M4 Pro
                              │    y1.txt    │               y2.txt               │
                              │    sec/op    │   sec/op     vs base               │
Suite/BenchmarkQuery-14          1.718µ ± 1%   1.634µ ± 0%  -4.89% (p=0.000 n=10)
Suite/BenchmarkQuerySimple-14   1009.0n ± 2%   941.1n ± 0%  -6.73% (p=0.000 n=10)
geomean                          1.317µ        1.240µ       -5.81%

                              │   y1.txt   │               y2.txt                │
                              │    B/op    │    B/op     vs base                 │
Suite/BenchmarkQuery-14         640.0 ± 0%   640.0 ± 0%       ~ (p=1.000 n=10) ¹
Suite/BenchmarkQuerySimple-14   440.0 ± 0%   440.0 ± 0%       ~ (p=1.000 n=10) ¹
geomean                         530.7        530.7       +0.00%
¹ all samples are equal

                              │   y1.txt   │               y2.txt                │
                              │ allocs/op  │ allocs/op   vs base                 │
Suite/BenchmarkQuery-14         22.00 ± 0%   22.00 ± 0%       ~ (p=1.000 n=10) ¹
Suite/BenchmarkQuerySimple-14   13.00 ± 0%   13.00 ± 0%       ~ (p=1.000 n=10) ¹
geomean                         16.91        16.91       +0.00%
¹ all samples are equal

This commit changes the bind logic to only reset the sqlite3 statement
when necessary, which saves us a call to sqlite3_reset the first time
the query is used.

goos: darwin
goarch: arm64
pkg: github.com/charlievieth/go-sqlite3
cpu: Apple M4 Pro
                              │    y1.txt    │               y2.txt               │
                              │    sec/op    │   sec/op     vs base               │
Suite/BenchmarkQuery-14          1.718µ ± 1%   1.634µ ± 0%  -4.89% (p=0.000 n=10)
Suite/BenchmarkQuerySimple-14   1009.0n ± 2%   941.1n ± 0%  -6.73% (p=0.000 n=10)
geomean                          1.317µ        1.240µ       -5.81%

                              │   y1.txt   │               y2.txt                │
                              │    B/op    │    B/op     vs base                 │
Suite/BenchmarkQuery-14         640.0 ± 0%   640.0 ± 0%       ~ (p=1.000 n=10) ¹
Suite/BenchmarkQuerySimple-14   440.0 ± 0%   440.0 ± 0%       ~ (p=1.000 n=10) ¹
geomean                         530.7        530.7       +0.00%
¹ all samples are equal

                              │   y1.txt   │               y2.txt                │
                              │ allocs/op  │ allocs/op   vs base                 │
Suite/BenchmarkQuery-14         22.00 ± 0%   22.00 ± 0%       ~ (p=1.000 n=10) ¹
Suite/BenchmarkQuerySimple-14   13.00 ± 0%   13.00 ± 0%       ~ (p=1.000 n=10) ¹
geomean                         16.91        16.91       +0.00%
¹ all samples are equal
@charlievieth charlievieth merged commit fd4da37 into master Dec 18, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant