Git Product home page Git Product logo

fizzbuzz's Introduction

High-throughput FizzBuzz in Julia

This is a submission for high-througput FizzBuzz 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

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

# 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.