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

optimize parsing common timestamps #26

Merged
merged 1 commit into from
Feb 7, 2025
Merged

Conversation

charlievieth
Copy link
Owner

This commit adds a dedicated function for parsing the two most common timestamps used by sqlite3.

goos: darwin
goarch: arm64
pkg: github.com/charlievieth/go-sqlite3
cpu: Apple M4 Pro
                            │ base.10.txt  │             new.10.txt              │
                            │    sec/op    │   sec/op     vs base                │
Suite/BenchmarkParseTime-14   11.347µ ± 0%   8.044µ ± 0%  -29.11% (p=0.000 n=10)

                            │ base.10.txt  │            new.10.txt            │
                            │     B/op     │     B/op      vs base            │
Suite/BenchmarkParseTime-14   1.713Ki ± 0%   1.713Ki ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

                            │ base.10.txt │           new.10.txt           │
                            │  allocs/op  │ allocs/op   vs base            │
Suite/BenchmarkParseTime-14    64.00 ± 0%   64.00 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

timefmt benchmarks:

goos: darwin
goarch: arm64
pkg: github.com/charlievieth/go-sqlite3/internal/timefmt
cpu: Apple M4 Pro
BenchmarkParse/Stdlib-14         	11050214	       103.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkParse/Timefmt-14        	34134667	        34.45 ns/op	       0 B/op	       0 allocs/op
BenchmarkParse/Timefmt_T-14      	33790362	        33.97 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	github.com/charlievieth/go-sqlite3/internal/timefmt	3.814s

This commit adds a dedicated function for parsing the two most common
timestamps used by sqlite3.

```
goos: darwin
goarch: arm64
pkg: github.com/charlievieth/go-sqlite3
cpu: Apple M4 Pro
                            │ base.10.txt  │             new.10.txt              │
                            │    sec/op    │   sec/op     vs base                │
Suite/BenchmarkParseTime-14   11.347µ ± 0%   8.044µ ± 0%  -29.11% (p=0.000 n=10)

                            │ base.10.txt  │            new.10.txt            │
                            │     B/op     │     B/op      vs base            │
Suite/BenchmarkParseTime-14   1.713Ki ± 0%   1.713Ki ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

                            │ base.10.txt │           new.10.txt           │
                            │  allocs/op  │ allocs/op   vs base            │
Suite/BenchmarkParseTime-14    64.00 ± 0%   64.00 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal
```

timefmt benchmarks:
```
goos: darwin
goarch: arm64
pkg: github.com/charlievieth/go-sqlite3/internal/timefmt
cpu: Apple M4 Pro
BenchmarkParse/Stdlib-14         	11050214	       103.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkParse/Timefmt-14        	34134667	        34.45 ns/op	       0 B/op	       0 allocs/op
BenchmarkParse/Timefmt_T-14      	33790362	        33.97 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	github.com/charlievieth/go-sqlite3/internal/timefmt	3.814s
```
@charlievieth charlievieth merged commit 78b9a4c into master Feb 7, 2025
4 checks passed
@charlievieth charlievieth deleted the cev/parse-time branch February 7, 2025 05:10
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