{"id":19321358,"url":"https://github.com/leshow/haskell-filter-map-reduce-bench","last_synced_at":"2026-02-14T01:37:13.151Z","repository":{"id":34387717,"uuid":"38314600","full_name":"leshow/haskell-filter-map-reduce-bench","owner":"leshow","description":null,"archived":false,"fork":false,"pushed_at":"2015-06-30T20:35:37.000Z","size":12180,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-26T09:44:07.053Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","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/leshow.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}},"created_at":"2015-06-30T14:41:02.000Z","updated_at":"2015-06-30T14:54:44.000Z","dependencies_parsed_at":"2022-09-14T04:41:36.285Z","dependency_job_id":null,"html_url":"https://github.com/leshow/haskell-filter-map-reduce-bench","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/leshow/haskell-filter-map-reduce-bench","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leshow%2Fhaskell-filter-map-reduce-bench","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leshow%2Fhaskell-filter-map-reduce-bench/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leshow%2Fhaskell-filter-map-reduce-bench/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leshow%2Fhaskell-filter-map-reduce-bench/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leshow","download_url":"https://codeload.github.com/leshow/haskell-filter-map-reduce-bench/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leshow%2Fhaskell-filter-map-reduce-bench/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273854461,"owners_count":25180008,"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","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-10T01:36:51.594Z","updated_at":"2026-02-14T01:37:13.111Z","avatar_url":"https://github.com/leshow.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"##Haskell filter/map/fold benchmark\n\nI had written this in Rust and used cargo to benchmark [here](https://github.com/leshow/rust-filter-map-reduce-bench)\n\nThe execution time was very fast in rust on my machine (500k ns), which got me\nwondering how fast it might be in Haskell.\n\nI'm no expert in Haskell, but I've written two implementations with only a\nslight variation that I think are idiomatic.\n\nEDIT: after talking with some people in the Haskell IRC, I've added an additional\nimplementation that runs significantly faster with only a slight variation. See\n`fun3` in fold.hs.\n\nCriterion was used to benchmark. To build this project:\n\n```\ngit clone https://github.com/leshow/haskell-filter-map-reduce-bench\ncd haskell-filter-map-reduce-bench\ncabal sandbox init\ncabal update\ncabal install criterion\n```\n\ncompile with:\n```\nghc -O2 -package-db .cabal-sandbox/x86_64-linux-ghc-7.6.3-packages.conf.d/ fold.hs\n```\n\nthen run:\n```\n./fold\n```\n\nyou can also generate a pretty web page with graphs of the benchmark test\n(after you've compiled) with:\n\n```\n./fold --output fold.html\n```\n\n##Results\non my machine:\n```\nbenchmarking fun1/1000\ntime                 34.84 μs   (34.65 μs .. 35.01 μs)\n                     1.000 R²   (1.000 R² .. 1.000 R²)\nmean                 34.91 μs   (34.83 μs .. 35.01 μs)\nstd dev              289.6 ns   (223.0 ns .. 368.6 ns)\n\nbenchmarking fun1/1000000\ntime                 34.82 ms   (34.52 ms .. 35.17 ms)\n                     1.000 R²   (1.000 R² .. 1.000 R²)\nmean                 34.82 ms   (34.72 ms .. 34.95 ms)\nstd dev              239.0 μs   (169.7 μs .. 331.2 μs)\n\nbenchmarking fun2/1000\ntime                 37.69 μs   (37.38 μs .. 38.01 μs)\n                     0.987 R²   (0.978 R² .. 0.993 R²)\nmean                 45.95 μs   (43.00 μs .. 49.19 μs)\nstd dev              12.01 μs   (9.914 μs .. 13.17 μs)\nvariance introduced by outliers: 98% (severely inflated)\n\nbenchmarking fun2/1000000\ntime                 38.27 ms   (38.05 ms .. 38.42 ms)\n                     1.000 R²   (1.000 R² .. 1.000 R²)\nmean                 38.32 ms   (38.23 ms .. 38.41 ms)\nstd dev              185.4 μs   (141.7 μs .. 235.6 μs)\n\nbenchmarking fun3/1000\ntime                 10.05 μs   (10.00 μs .. 10.11 μs)\n                     1.000 R²   (1.000 R² .. 1.000 R²)\nmean                 10.03 μs   (10.00 μs .. 10.07 μs)\nstd dev              106.1 ns   (88.71 ns .. 129.9 ns)\n\nbenchmarking fun3/1000000\ntime                 12.65 ms   (9.922 ms .. 15.20 ms)\n                     0.886 R²   (0.839 R² .. 1.000 R²)\nmean                 10.48 ms   (10.05 ms .. 11.61 ms)\nstd dev              1.613 ms   (417.0 μs .. 3.110 ms)\nvariance introduced by outliers: 75% (severely inflated)\n\n```\nMy quickest Haskell implementation ran in ~35 ms, much slower than my Rust\nimplementation. I decided to ask in the haskell irc channel on freenode if\nanyone had a faster implementation.\n\ndwins in the Haskell IRC suggested I replace `filter even [0 .. x]` with\n`[0, 2 .. x]`. This significantly speeds up the execution time on my machine to\n~10 ms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleshow%2Fhaskell-filter-map-reduce-bench","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleshow%2Fhaskell-filter-map-reduce-bench","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleshow%2Fhaskell-filter-map-reduce-bench/lists"}