sqids / sqids-go

Official Go port of Sqids. Generate short unique IDs from numbers.
https://sqids.org/go
MIT License
492 stars 8 forks source link

Algorithm change #23

Closed 4kimov closed 10 months ago

4kimov commented 10 months ago

@peterhellberg Just a heads up: I pushed the algorithm change from https://github.com/sqids/sqids-spec/issues/11 to main. Thanks for all the changes you've been making, I can see it's a lot. Hopefully, I didn't mess up any of your improvements.

peterhellberg commented 10 months ago

Good morning, thank you for this. All good.

I ran the EncodeDecode benchmark again, and the numbers are shaping up nicely:

$ time go test -bench=. -run=BenchmarkEncodeDecode -benchmem -cpuprofile profile.out
goos: linux
goarch: amd64
pkg: github.com/sqids/sqids-go
cpu: Intel(R) Core(TM) i7-10700T CPU @ 2.00GHz
BenchmarkEncodeDecode-16           51102         23151 ns/op        6775 B/op         76 allocs/op
PASS
ok      github.com/sqids/sqids-go   1.610s

real    0m1.668s
user    0m1.570s
sys 0m0.102s

(In contrast with the commit before your changes where we were at ~40k ns/op and 132 allocs/op)

peterhellberg commented 10 months ago

I pushed the v0.4.0 tag now, since it was a fairly substantial update.