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

improve Format() performance #32

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

janishorsts
Copy link

This refactoring improves the performance of the Format().

$ go test -bench=. -benchmem -count=10 > a.txt # before changes
$ go test -bench=. -benchmem -count=10 > b.txt # after changes
$ benchstat a.txt b.txt                                 
goos: darwin
goarch: arm64
pkg: github.com/yaa110/go-persian-calendar
cpu: Apple M2 Max
          │    a.txt     │                b.txt                │
          │    sec/op    │   sec/op     vs base                │
Format-12   3440.0n ± 1%   822.5n ± 1%  -76.09% (p=0.000 n=10)

          │    a.txt    │               b.txt                │
          │    B/op     │    B/op     vs base                │
Format-12   5995.0 ± 0%   256.0 ± 3%  -95.73% (p=0.000 n=10)

          │   a.txt    │                b.txt                │
          │ allocs/op  │  allocs/op   vs base                │
Format-12   64.00 ± 2%   10.00 ± 10%  -84.38% (p=0.000 n=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