{"id":29470033,"url":"https://github.com/rust-dd/probability-benchmark","last_synced_at":"2026-04-13T01:36:28.043Z","repository":{"id":303485834,"uuid":"1015644116","full_name":"rust-dd/probability-benchmark","owner":"rust-dd","description":"🦀 Scientific Computing Benchmark: Rust 🦀 vs Zig ⚡ vs the father C 👴","archived":false,"fork":false,"pushed_at":"2025-07-07T22:28:23.000Z","size":12384,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-07T23:36:34.714Z","etag":null,"topics":["c","ornstein-uhlenbeck-process","rust","stochastic-processes","zig"],"latest_commit_sha":null,"homepage":"https://rust-dd.com/post/crab-scientific-computing-benchmark-rust-crab-vs-zig-zap-vs-the-father-c-older_man","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rust-dd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-07T20:22:40.000Z","updated_at":"2025-07-07T23:18:56.000Z","dependencies_parsed_at":"2025-07-07T23:47:39.583Z","dependency_job_id":null,"html_url":"https://github.com/rust-dd/probability-benchmark","commit_stats":null,"previous_names":["rust-dd/probability-benchmark"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rust-dd/probability-benchmark","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-dd%2Fprobability-benchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-dd%2Fprobability-benchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-dd%2Fprobability-benchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-dd%2Fprobability-benchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rust-dd","download_url":"https://codeload.github.com/rust-dd/probability-benchmark/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-dd%2Fprobability-benchmark/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265288497,"owners_count":23741194,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","ornstein-uhlenbeck-process","rust","stochastic-processes","zig"],"created_at":"2025-07-14T12:01:18.375Z","updated_at":"2026-04-13T01:36:22.995Z","avatar_url":"https://github.com/rust-dd.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🦀 Probability Benchmark: Rust vs Zig vs C\n\nThis repository benchmarks three languages — **Rust**, **Zig**, and **C** — for generating Ornstein–Uhlenbeck (OU) stochastic processes, commonly used in stochastic calculus and mathematical finance.\n\n## 💡 What is it about?\n\nWe simulate **1,000 trajectories**, each of length **500,000**, using a simple Euler scheme. Each trajectory uses normally distributed increments to generate a mean-reverting process.\n\nMathematically, the OU process is given by:\n\n\\[\ndX_t = \\theta (\\mu - X_t)\\,dt + \\sigma\\,dW_t\n\\]\n\nwhere:\n- \\(\\theta\\) = mean reversion speed\n- \\(\\mu\\) = long-term mean\n- \\(\\sigma\\) = volatility\n- \\(dW_t\\) = standard Brownian motion increment\n\n---\n\n## ⚡ Motivation\n\nAs the maintainer of [stochastic-rs](https://github.com/dancixx/stochastic-rs), I'm a big fan of low-level, hardware-oriented programming languages, especially for scientific computing.\n\nI’m not an expert in Zig or C, so this benchmark represents what might happen if a \"regular Rust user\" tries to quickly hack together similar code in other languages after a bit of Googling and reading docs.\n\n---\n\n## 💻 Code snippets\n\n### Rust (🦀)\n\n- Uses `rand` and `rand_distr`\n- Run with: `cargo run --release`\n\n[See code here](./rust_version.rs)\n\n---\n\n### Zig (⚡)\n\n- Uses [zprob](https://github.com/pblischak/zprob)\n- Run with: `zig build run -Doptimize=ReleaseFast`\n\n[See code here](./zig_version.zig)\n\n---\n\n### C (👴)\n\n- Simple Box-Muller method for normal sampling\n- Compile with: `gcc -O3 -march=native -o main main.c -lm`\n\n[See code here](./c_version.c)\n\n---\n\nTermészetesen! Íme **vesszők nélkül**, szépen formázva:\n\n---\n\n## 📊 Results\n\n| Language    | Avg (ms) | Total (ms)          |\n| ----------- | -------- | ------------------- |\n| **Rust** 🦀 | 3.08 ms  | 3077 ms (\\~3.1 sec) |\n| **Zig** ⚡   | 3.58 ms  | 3584 ms (\\~3.6 sec) |\n| **C** 👴    | 3.61 ms  | 3611 ms (\\~3.6 sec) |\n\n---\n\n## 🗣️ Discussion\n\nThis benchmark is not intended to be a definitive performance proof, but rather a fun exploration. Contributions, improvements, or corrections are highly welcome!\n\n👉 [Join the discussion](https://github.com/rust-dd/probability-benchmark/discussions/1)\n\n---\n\n## 📎 License\n\nMIT\n\n---\n\n**Enjoy, and happy benchmarking! 🚀**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-dd%2Fprobability-benchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frust-dd%2Fprobability-benchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-dd%2Fprobability-benchmark/lists"}