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

Improved performance of BindVar() #4

Merged
merged 1 commit into from
Aug 18, 2023

Conversation

k1ng440
Copy link
Contributor

@k1ng440 k1ng440 commented Aug 17, 2023

A simple improvement to the BindVar functions.

benchstat original.bench strconv.bench                                                                                                                                                                                                              k1ng@rog-beast
goos: linux
goarch: amd64
pkg: github.com/keegancsmith/sqlf
cpu: AMD Ryzen 9 5950X 16-Core Processor            
                    │ original.bench │             strconv.bench             │
                    │     sec/op     │    sec/op      vs base                │
PostgresBindVar-32     121.15n ± 17%    47.91n ± 10%  -60.46% (p=0.000 n=10)
OracleBindVar-32       118.60n ± 11%    44.23n ±  5%  -62.71% (p=0.000 n=10)
SQLServerBindVar-32    108.20n ±  7%    45.90n ± 12%  -57.58% (p=0.000 n=10)
SimpleBindVar-32       0.2366n ±  4%   0.2572n ± 10%   +8.75% (p=0.011 n=10)
Sprintf-32             1094.5n ±  8%    930.5n ± 19%  -14.98% (p=0.015 n=10)

                    │ original.bench │            strconv.bench             │
                    │      B/op      │    B/op     vs base                  │
PostgresBindVar-32     17.000 ± 6%     7.000 ± 0%  -58.82% (p=0.000 n=10)
OracleBindVar-32       16.000 ± 0%     7.000 ± 0%  -56.25% (p=0.000 n=10)
SQLServerBindVar-32    23.000 ± 0%     7.000 ± 0%  -69.57% (p=0.000 n=10)
SimpleBindVar-32        0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
Sprintf-32              308.0 ± 0%     308.0 ± 0%        ~ (p=1.000 n=10) ¹

                    │ original.bench │              strconv.bench              │
                    │   allocs/op    │ allocs/op   vs base                     │
PostgresBindVar-32     1.000 ±  0%     0.000 ± 0%  -100.00% (p=0.000 n=10)
OracleBindVar-32       1.000 ±  0%     0.000 ± 0%  -100.00% (p=0.000 n=10)
SQLServerBindVar-32    2.000 ± 50%     0.000 ± 0%  -100.00% (p=0.000 n=10)
SimpleBindVar-32       0.000 ±  0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹
Sprintf-32             12.00 ±  0%     12.00 ± 0%         ~ (p=1.000 n=10) ¹

benchstat original.bench strconv.bench                                                                                                                                                                                                              k1ng@rog-beast
goos: linux
goarch: amd64
pkg: github.com/keegancsmith/sqlf
cpu: AMD Ryzen 9 5950X 16-Core Processor
                    │ original.bench │             strconv.bench             │
                    │     sec/op     │    sec/op      vs base                │
PostgresBindVar-32     121.15n ± 17%    47.91n ± 10%  -60.46% (p=0.000 n=10)
OracleBindVar-32       118.60n ± 11%    44.23n ±  5%  -62.71% (p=0.000 n=10)
SQLServerBindVar-32    108.20n ±  7%    45.90n ± 12%  -57.58% (p=0.000 n=10)
SimpleBindVar-32       0.2366n ±  4%   0.2572n ± 10%   +8.75% (p=0.011 n=10)
Sprintf-32             1094.5n ±  8%    930.5n ± 19%  -14.98% (p=0.015 n=10)

                    │ original.bench │            strconv.bench             │
                    │      B/op      │    B/op     vs base                  │
PostgresBindVar-32     17.000 ± 6%     7.000 ± 0%  -58.82% (p=0.000 n=10)
OracleBindVar-32       16.000 ± 0%     7.000 ± 0%  -56.25% (p=0.000 n=10)
SQLServerBindVar-32    23.000 ± 0%     7.000 ± 0%  -69.57% (p=0.000 n=10)
SimpleBindVar-32        0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
Sprintf-32              308.0 ± 0%     308.0 ± 0%        ~ (p=1.000 n=10) ¹

                    │ original.bench │              strconv.bench              │
                    │   allocs/op    │ allocs/op   vs base                     │
PostgresBindVar-32     1.000 ±  0%     0.000 ± 0%  -100.00% (p=0.000 n=10)
OracleBindVar-32       1.000 ±  0%     0.000 ± 0%  -100.00% (p=0.000 n=10)
SQLServerBindVar-32    2.000 ± 50%     0.000 ± 0%  -100.00% (p=0.000 n=10)
SimpleBindVar-32       0.000 ±  0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹
Sprintf-32             12.00 ±  0%     12.00 ± 0%         ~ (p=1.000 n=10) ¹
Copy link
Owner

@keegancsmith keegancsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! thank you.

@keegancsmith keegancsmith merged commit fb8d6b7 into keegancsmith:master Aug 18, 2023
1 check 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.

2 participants