{"id":26502893,"url":"https://github.com/grassator/compile-time-execution-benchmark","last_synced_at":"2026-04-22T23:34:49.532Z","repository":{"id":66098738,"uuid":"343173258","full_name":"grassator/compile-time-execution-benchmark","owner":"grassator","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-14T23:17:55.000Z","size":199,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-28T16:51:07.347Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","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/grassator.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}},"created_at":"2021-02-28T17:52:08.000Z","updated_at":"2021-10-21T19:16:38.000Z","dependencies_parsed_at":"2023-04-21T10:36:46.812Z","dependency_job_id":null,"html_url":"https://github.com/grassator/compile-time-execution-benchmark","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/grassator/compile-time-execution-benchmark","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grassator%2Fcompile-time-execution-benchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grassator%2Fcompile-time-execution-benchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grassator%2Fcompile-time-execution-benchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grassator%2Fcompile-time-execution-benchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grassator","download_url":"https://codeload.github.com/grassator/compile-time-execution-benchmark/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grassator%2Fcompile-time-execution-benchmark/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32159959,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T17:06:48.269Z","status":"ssl_error","status_checked_at":"2026-04-22T17:06:19.037Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2025-03-20T18:36:16.476Z","updated_at":"2026-04-22T23:34:49.517Z","avatar_url":"https://github.com/grassator.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Completely Unscientific Compile Time Execution Benchmark\n\n## Methodology\n\nAll test are performed on Windows 10.\n\nTo measure just the compiled time execution and not the rest of the compiler the code is first compiled with the constant hard-coded, then with the compile-time execution and get the difference.\n\nAll code is compiled without any optimization to minimize the non-relevant time spent in the compiler. Below you can find the version of the compiler and commands used.\n\n### MSVC\n\n    cl /nologo /Od SOURCE_FILE\n\n### Clang (Windows)\n\n    clang-cl -Od SOURCE_FILE\n\n### [Zig](http://ziglang.org)\n\n\u003e *This is non-self-hosted version that is known to be quite slow.\n\n    zig build-exe -ODebug SOURCE_FILE\n\nCompile time execution is run with @setEvalBranchQuota(10000000);\n\nZig does very aggressive caching, so make sure to remove all artifacts and `zig-cache` folder between the builds. Since we are measuring the delta, the time it takes to compile standard libraries should not affect the result (much).\n\n### [Mass](https://github.com/grassator/mass)\n\n    .\\build\\mass.exe ..\\compile-time-benchmark\\SOURCE_FILE\n\n## Counter\n\nIn this benchmark the goal is count from 0 to 1 000 000 integer in a loop at compile time. It should give an indication on the overhead of the interpretation inside the compiler.\n\n### Results:\n\nAll times are provided in milliseconds.\n\nLanguage     | Hardcoded | Compile Time | Delta (ms) | X Times Slower\n------------ | ----------|--------------|------------|----------------\nMass         | 12        | 16           | 4          | baseline\nC++ (MSVC)   | 330       | 2270         | 1940       | 485x\nC++ (CLang)  | 1065      | 1874         | 809        | 202x\nZig          | 1220      | 11714        | 10494      | 2623x\n\nResults are pretty much what you would expect considering that both C++ and Zig do interpretation while Mass does a single-pass JIT. CLang seems to do reasonably well for an interpreter although doing anything computationally expensive would still slow down your compilation time dramatically.\n\n## Constant Folding\n\nThe goal is to constant fold 1000 definitions each computing the sum of 1000 `1` integers.\n\nBecause of the large amount of source code, the test not only measures the speed of constant folding itself, but also parsing, as there is almost 2mb of the source code.\n\nThis test does not require compile-time machinery and should work in any language, but for consistency I'm sticking with C++, Zig and Mass.\n\n### Results:\n\n\u003e Hardcoded times are same as in the loop test as the rest of the code besides the constant folding is also identical.\n\nLanguage     | Hardcoded | Constant Folding | Delta (ms) | X Times Slower\n------------ | ----------|------------------|------------|----------------\nMass         | 12        | 2880             | 2868       | 7.61x\nC++ (MSVC)   | 330       | 1190             | 860        | 2.28x\nC++ (CLang)  | 1065      | 1442             | 377        | baseline\nZig          | 1220      | 3818             | 2598       | 6.89x\n\nThere are two big bottlenecks for Mass in this code:\n  - Each `+` operator is first text-expanded via a macro\n  - There is overload resolution happening for each `+` operator\n\n## One Million Calls\n\nThe goal is to compile a file that contains 1 000 000 calls to a `print` function defined in the same value.\n\n### Results:\n\n\u003e Hardcoded times are same as in the loop test as the rest of the code besides the constant folding is also identical.\n\nLanguage     | Compilation, ms  | X Times Slower | Throughput (mb / sec)\n------------ | -----------------|----------------|----------------------\nMass         | 1609             | baseline       | 5.33\nC++ (MSVC)   | 19510            | 12.13x         | 0.44\nC++ (CLang)  | 9712             | 6.04x          | 0.88\nZig*         | 19258            | 11.97x         | 0.45\n\nMass has an unfair advantage here as it does not support debug symbols.\n\n\u003e *Self-hosted version of Zig that is in development at the time of writing is reported to be able to complete this test in less than one second which would make it a clear winner.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrassator%2Fcompile-time-execution-benchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrassator%2Fcompile-time-execution-benchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrassator%2Fcompile-time-execution-benchmark/lists"}