Java: On my 11th gen intel laptop
- The OP's simple C version: 25 MiB/s
- My simple Java version: 140 MiB/s
- python neil+kamila: 8 MiB/s
- python ksoua chunking: 4.33 MiB/s
- Jan's C version: 1.0 GiB/s
Sometimes simple is better!
To the guy that did a threaded C++ version: wow!
public class FizzBuzz {
public static void main(String[] args) {
long maxBufLen=4096<<3;
var sb=new StringBuilder((int)maxBufLen + 10);
for (long i = 1; ; i+=1) {
if ((i % 3 == 0) && (i % 5 == 0)) {
sb.append("FizzBuzz\n");
} else if (i % 3 == 0) {
sb.append("Fizz\n");
} else if (i % 5 == 0) {
sb.append("Buzz\n");
} else {
sb.append(i).append("\n");
}
if(sb.length()>maxBufLen) {
System.out.print(sb);
sb.setLength(0);
}
}
}
}
```