Get the latest tech news

Optimizing FizzBuzz in Rust


Optimizing FizzBuzz in Rust for fun and profit. Contribute to nrposner/fizzcrate development by creating an account on GitHub.

He expanded the if-else chain: I asked him to find a way to do it without explosively increasing the number of necessary checks with each new term added. The simple act of removing newlines, printing the entire buffer as one continuous, illegible block instead of allocating a new line to each number reduces our runtime by roughly 80%. Note that the single-threaded version on 100 is slower than the 900ns we time earlier: mainly because this one is actually saving the contents of each loop and collecting them into a vector.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Rust

Rust

Photo of FizzBuzz

FizzBuzz

Related news:

News photo

Closing the Nix gap: From environments to packaged applications for rust

News photo

Io_uring, kTLS and Rust for zero syscall HTTPS server

News photo

The Core of Rust