Jake Bauer
379b6bb67c
It turns out that doing math on f64 types (either comparisons or @mod, not sure which since I don't know how to profile zig) is very expensive and caused this code to be as slow as the Python version. Doing type conversions so the math can be done on integer types makes this way, way faster. |
||
---|---|---|

LICENSE | ||

README.md | ||

prime.c | ||

prime.go | ||

prime.lua | ||

prime.py | ||

prime.raku | ||

prime.rb | ||

prime.rs | ||

prime.zig |

####
**README.md**

**README.md**

# Primemark

A simple microbenchmark to test how fast a programming language is at determining which of the numbers 1 to 1,000,000 are prime numbers.

These tests are written in a way that mimics how most software developers would use a given language to solve this problem. I'm not interested in hand-optimizing a given solution for a given language (no SIMD or multithreaded tricks or other stuff like that), so some languages which do have a built-in, optimized function for determining whether a number is prime may have an advantage over languages where a developer would have to write their own.

!!NOTE!! Keep in mind the definition of a microbenchmark. This test does not necessarily "prove" that one programming language is faster than another for any given usecase. This only tests which programming language is faster at this specific task.

## Running

Makefile coming soon™, but for now I compile executables for the
languages which need that, then run the benchmark using `hyperfine -w 1 ...`

with all of the tests.

## Languages with Tests

A * after a language indicates that the test uses a language's built-in function for determining whether a number is prime.

### Compiled

- C
- Rust
- Go
- Zig

### Interpreted

- Python
- Lua
- Ruby*
- Raku*

## Contributing

I'm only experienced with a handful of the languages on this list, so if you know a better (but still "how-most-software-devs-would-do-it") way to solve this problem in a given language, feel free to email me a patch.