1BRC in Swift ( ~ 1.7 Sec on Mac Studio) #251
pfy
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I I made a version in swift that runs in ~ 1.7 seconds on a mac studio (the best time observed was 1.633).
The idea is more or less the same as in the other solutions
a. while parsing the name, accumulate the hash for the hashtable as well
b. while parsing, safe the first 8 bytes of the name, since a lot of names are short, we can implement equality for these by a single compare
c. while parsing the number, save it as int, convert it to float, and divide it by 10 later
the code is available on https://github.com/pfy/1brc/tree/main
Beta Was this translation helpful? Give feedback.
All reactions