Fun: High throughput Fizz Buzz

8 views
Skip to first unread message

alex

unread,
Aug 13, 2025, 10:25:56 PMAug 13
to tpot
I came across this thread years ago on Code Golf Stack Exchange


The goal of this code golf challenge is to maximize the output rate of a fizz buzz program. Of course fizz buzz is a pretty fast algorithm so there's not much to optimize other than writing it in C or assembly with optimizations enabled.

A few things people bet on:
1. Not using typical output methods, moving output to stdout as quickly as possible
2. No cloning
3. Surprisingly, not multi threading (for some of the replies) (would likely be hard to sync output)


jo...@jocadbz.xyz

unread,
Aug 17, 2025, 7:53:02 PMAug 17
to tec...@googlegroups.com
Amazing stuff.

I tried it in V, but I think there's only so much you can do to speed up things without writing it directly on low-level languages.

Anyways, if anyone wants to try this, there are some things that are obligatory:

  • Use memcpy to manually copy bytes to the buffer: concatenating strings are a big overhead you can't afford.
  • Use write to manually put stuff on the stdout: Again, converting strings are another overhead you can't afford.
  • Manually do the calculation if bytes on the string itself, instead of converting to int, calculating and converting to string again.

In the end, I got 400MB/s. Didn't dare to try any further lol.

--
You received this message because you are subscribed to the Google Groups "tpot" group.
To unsubscribe from this group and stop receiving emails from it, send an email to techpot+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/techpot/638b18ad-6160-4e77-af84-5e5e68091acen%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages