Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tkluck/fizzbuzz
High-throughput FizzBuzz in Julia
https://github.com/tkluck/fizzbuzz
Last synced: about 1 month ago
JSON representation
High-throughput FizzBuzz in Julia
- Host: GitHub
- URL: https://github.com/tkluck/fizzbuzz
- Owner: tkluck
- Created: 2022-12-28T14:48:19.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-11-19T00:18:31.000Z (12 months ago)
- Last Synced: 2023-11-19T01:27:05.328Z (12 months ago)
- Language: Julia
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# High-throughput FizzBuzz in Julia
This is a submission for [high-througput FizzBuzz codegolf][codegolf]. The
objective is to generate the highest throughput for FizzBuzz possible. On my
personal laptop, this julia script reaches ~10GiB/s, or about triple the
throughput of```sh
cat /dev/zero | pv > /dev/null
```It supports at most 16 digits, which theoretically takes about a day to reach.
At that point, the script terminates with an error.## Usage
```bash
# For seeing it in action:
julia --threads 4 fizzbuzz.jl
# For benchmarking the throughput:
julia --threads 4 fizzbuzz.jl | pv > /dev/null
# For checking correctness:
diff <( julia --threads 4 fizzbuzz.jl | head -n 10000) <(
seq 10000 | perl -nle'
$_ % 15 or print "FizzBuzz" and next;
$_ % 5 or print "Buzz" and next;
$_ % 3 or print "Fizz" and next;
print'
)
```## Credit
I should credit ais523 for the idea to use the `vmsplice` syscall. Theirs is
currently (December 2022) the fastest submission. I also took inspiration from
other solutions to unroll the main loop by 15. The rest of the ideas are my
own, although I'm obviously standing on the shoulders of the giants who created
Julia.[codegolf]: https://codegolf.stackexchange.com/questions/215216/high-throughput-fizz-buzz/236630#236630