segmentio / ksuid

K-Sortable Globally Unique IDs
https://segment.com/blog/a-brief-history-of-the-uuid/
MIT License
4.82k stars 174 forks source link

uint128 ops are much faster without loops. #36

Closed Deleplace closed 5 years ago

Deleplace commented 5 years ago

The loops always had exactly 2 iterations. Without the loop, c is computed once instead of twice.

benchmark                              old ns/op     new ns/op     delta
BenchmarkCmp128-12                     4.25          1.52          -64.24%
BenchmarkAdd128-12                     4.61          0.28          -93.93%
BenchmarkSub128-12                     4.72          0.28          -94.07%