{"id":13617165,"url":"https://github.com/frol/completely-unscientific-benchmarks","last_synced_at":"2025-10-07T09:52:25.804Z","repository":{"id":38869090,"uuid":"133128231","full_name":"frol/completely-unscientific-benchmarks","owner":"frol","description":"Naive performance comparison of a few programming languages (JavaScript, Kotlin, Rust, Swift, Nim, Python, Go, Haskell, D, C++, Java, C#, Object Pascal, Ada, Lua, Ruby)","archived":false,"fork":false,"pushed_at":"2021-06-22T14:21:55.000Z","size":197,"stargazers_count":550,"open_issues_count":16,"forks_count":69,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-05-25T14:06:08.768Z","etag":null,"topics":["ada","benchmark","cpp","csharp","dlang","golang","haskell","java","javascript","kotlin","lua","luajit","nim","programming-language","python","ruby","rust","scoreboard","swift"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/frol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-12T08:32:39.000Z","updated_at":"2025-05-17T04:56:06.000Z","dependencies_parsed_at":"2022-08-18T14:11:13.431Z","dependency_job_id":null,"html_url":"https://github.com/frol/completely-unscientific-benchmarks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/frol/completely-unscientific-benchmarks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frol%2Fcompletely-unscientific-benchmarks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frol%2Fcompletely-unscientific-benchmarks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frol%2Fcompletely-unscientific-benchmarks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frol%2Fcompletely-unscientific-benchmarks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frol","download_url":"https://codeload.github.com/frol/completely-unscientific-benchmarks/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frol%2Fcompletely-unscientific-benchmarks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278755147,"owners_count":26040034,"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-10-07T02:00:06.786Z","response_time":59,"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":["ada","benchmark","cpp","csharp","dlang","golang","haskell","java","javascript","kotlin","lua","luajit","nim","programming-language","python","ruby","rust","scoreboard","swift"],"created_at":"2024-08-01T20:01:37.637Z","updated_at":"2025-10-07T09:52:25.789Z","avatar_url":"https://github.com/frol.png","language":"C++","funding_links":[],"categories":["HarmonyOS","C++"],"sub_categories":["Windows Manager"],"readme":"# Completely Unscientific Benchmarks\n\n\u003e [There are three kinds of lies: lies, damned lies, and statistics.](https://en.wikipedia.org/wiki/Lies,_damned_lies,_and_statistics)\n\nFor this benchmark we implemented [Treap](https://en.wikipedia.org/wiki/Treap)\nin a few classic (C++, Java, Python) and hyped (JavaScript, Kotlin, Swift, Rust)\nprogramming languages and tested their performance on Linux, Mac OS, and\nWindows (all of them running on different hardware, so the results should not\nbe compared between platforms).\n\nThis turned out to be a good benchmark of memory-intensive operations, which\nshould have been pushed memory management implementations to their edge.\n\nFirst, we tried to play by the rules of the garbage-collected languages, thus\nthere are \"ref-counted\" versions of implementations for C++ and Rust, but then\nwe still wanted to compare the results with idiomatic (a.k.a. common practices)\nimplementations for C++ (\"raw-pointers\") and Rust (\"idiomatic\").\n\nI must say that most of the implementations (except for C++, Haskell, and OCaml)\nwere implemented by mostly adapting the syntax from the very first\nimplementation of the algorithm in Kotlin. Even Rust, which is considered to\nhave the steepest learning curve among the tested languages, didn't require any\n\"black magic\" (the solution does not require either unsafe code or lifetime\nannotations). C++ was implemented separately, so it has a few shortcuts, and\nthus it might be not a completely fair comparison (I will try to implement\n\"fair\" C++ solution and also \"C++\"-like Rust solution to see if the performance\ncan be on par).\n\n\n## Metrics\n\nWe define the \"naive\" implementations as those which a developer with enough\nexperience in a given language would implement as a baseline \"good enough\"\nsolution where correctness is more important than performance.\n\nHowever, experienced developers in system programming languages (e.g. C, C++, D)\ntend to work comfortably with raw pointers, and that makes the comparison of the\nsolutions only by speed and memory consumption unfair. High-level abstractions\ntend to introduce some performance hit in exchange for safety and\nexpressiveness. Thus, we added other metrics: \"Expressiveness\" (1 - pure magic,\n10 - easy to get started and express your intent) and \"Maintenance Complexity\"\n(1 - easy to maintain, 5 - ugly yet safe, 6-10 - hard to keep it right, i.e.\nrisky). The ease of maintenance is estimated for a big project using the given\nlanguage and the given approach.\n\nThus, here are the metrics:\n\n* *Expressiveness (**e12s**)*, scores from 1 to 10 - higher value is better\n  (keep in mind that this is a subjective metric based on the author's\n  experience!)\n* *Maintenance Complexity (**M.C.**)*, scores from 1 to 10 - smaller value is\n  better (keep in mind that this is a subjective metric based on the author's\n  experience!)\n* *Real Time*, seconds - smaller value is better\n* *Slowdown Time* (relative speed compared to the best tuned solution) - smaller\n  value is better\n* *Memory*, megabytes - smaller value is better\n* *Binary Size*, megabytes - smaller value is better\n\n\n## Measurements\n\nTo measure time we used `time` util on Mac OS and Windows (msys2 environment),\nand [`cgmemtime`](https://github.com/gsauthof/cgmemtime) on Linux.\n\nMemory measurement was only available on Linux with `cgmemtime` util, which\nleverages CGroup capabilities to capture the high-water RSS+CACHE memory usage,\nand given the limitations of cgroup subsystem (it counts caches and loaded\nshared objects unless they are already cached or loaded by other processes),\nwe take the lowest memory footprint among all the executions.\n\n\n## Results\n\nOriginally, this benchmark had a goal to implement the same \"natural\" and\n\"naive\" API in all the languages with exception to C++, which would represent\na \"bare metal\" performance. Over time, we received optimized solutions in other\nlanguages, but it doesn't seem fair to put them on the same scoreboard. Thus,\neven though, all the solutions implement the same algorithm, they were created\nwith performance in mind and received quite an intensive profiling and tunning,\nand that is why they will be presented in a separate scoreboard.\n\nAll tables are sorted in an alphabetical order.\n\n### \"Naive\" Implementations Scoreboard\n\n#### Linux (Arch Linux, x64, Intel Core i7-4710HQ CPU)\n\n| Language                                      | e12s            | M.C.           | Real Time, seconds | Slowdown Time | Memory, MB | Binary Size, MB                 | Compiler Version                  |\n| --------------------------------------------- |:---------------:|:--------------:| ------------------ |:-------------:| ---------- | ------------------------------- | --------------------------------- |\n| *Best tuned solution*                         |                 |                | **0.167**          | x1            | **0.25**   |                                 |                                   |\n| Ada \"naive unsafe raw pointers\"               | 💛\u003cbr/\u003e(6)      | 💔\u003cbr/\u003e(8)     | 0.24               | x1.44         | **0.4**    | 0.292                           | GCC Ada 9.3.0                     |\n| C++ \"java-like\" (clang)                       | 💙\u003cbr/\u003e(7)      | 💙\u003cbr/\u003e(5)     | 0.33               | x2            | **0.5**    | 0.018 + libstdc++               | Clang 9.0.1                       |\n| C++ \"java-like\" (gcc)                         | 💙\u003cbr/\u003e(7)      | 💙\u003cbr/\u003e(5)     | 0.35               | x2.1          | **0.5**    | 0.039 + libstdc++               | GCC 9.3.0                         |\n| C++ \"naive unsafe raw pointers\" (clang)       | 💛\u003cbr/\u003e(6)      | 💔\u003cbr/\u003e(8)     | 0.20               | x1.2          | **0.4**    | 0.014 + libstdc++               | Clang 9.0.1                       |\n| **C++ \"naive unsafe raw pointers\" (gcc)**     | 💛\u003cbr/\u003e(6)      | 💔\u003cbr/\u003e(8)     | **0.19**           | x1.14         | **0.4**    | 0.026 + libstdc++               | GCC 9.3.0                         |\n| C++ \"naive `shared_ptr`\" (clang)              | 💛\u003cbr/\u003e(6)      | 💛\u003cbr/\u003e(6)     | 0.36               | x2.1          | **0.5**    | 0.018 + libstdc++               | Clang 9.0.1                       |\n| C++ \"naive `shared_ptr`\" (gcc)                | 💛\u003cbr/\u003e(6)      | 💛\u003cbr/\u003e(6)     | 0.35               | x2.1          | **0.5**    | 0.051 + libstdc++               | GCC 9.3.0                         |\n| C#                                            | 💚\u003cbr/\u003e(9)      | 💚\u003cbr/\u003e(1)     | 0.73\\*             | x4.4          | 10         | N/A                             | .NET Core 3.1                     |\n| Crystal                                       | 💚\u003cbr/\u003e(10)     | 💚\u003cbr/\u003e(1)     | 0.28               | x1.7          | 1.6        | 0.220                           | Crystal 0.33.0                    |\n| D \"garbage collected\"                         | 💚\u003cbr/\u003e(9)      | 💚\u003cbr/\u003e(1)     | 0.26               | x1.5          | 1.6        | 0.026 + D runtime               | LDC 1.20.1                        |\n| D \"naive unsafe raw pointers\"                 | 💙\u003cbr/\u003e(8)      | 💛\u003cbr/\u003e(6)     | 0.23               | x1.4          | 1.6        | 0.019 + D runtime               | LDC 1.20.1                        |\n| F#                                            | ?               | ?              | 2.20               | x13           | 26         | 0.012 + mono runtime            | F# 10.2.3 + Mono 6.4.0            |\n| Go \"with pointers\"                            | 💚\u003cbr/\u003e(9)      | 💛\u003cbr/\u003e(6)     | 0.37               | x2.2          | 6.8        | 1.9 (static)                    | Go 1.14.1                         |\n| Haskell                                       | ?               | ?              | 0.95               | x5.7          | 3.4        | 4.1                             | GHC 8.8.3                         |\n| JavaScript                                    | 💚\u003cbr/\u003e(10)\\*\\* | 💙\u003cbr/\u003e(3)\\*\\* | 1.03               | x6.2          | 49         | N/A                             | Node.js 13.12.0                   |\n| Java (no-limit / `-Xm*50M`)                   | 💚\u003cbr/\u003e(9)      | 💚\u003cbr/\u003e(1)     | 0.68 / 0.64        | x4.1          | 172 / 47   | N/A                             | OpenJDK 13.0.2                    |\n| Kotlin/JVM (no-limit / `-Xm*50M`)             | 💚\u003cbr/\u003e(9)      | 💚\u003cbr/\u003e(1)     | 0.72 / 0.67        | x4.3          | 174 / 49   | N/A                             | Kotlinc 1.3.70 + OpenJDK 13.0.2   |\n| Kotlin/Native                                 | 💚\u003cbr/\u003e(9)      | 💚\u003cbr/\u003e(1)     | 3.08               | x18           | 1.4        | 0.212                           | Kotlinc-native 1.3.71             |\n| Lua                                           | 💚\u003cbr/\u003e(10)\\*\\* | 💙\u003cbr/\u003e(3)\\*\\* | 3.70               | x22           | 2.8        | N/A                             | Lua 5.3.5                         |\n| LuaJIT                                        | 💚\u003cbr/\u003e(10)\\*\\* | 💙\u003cbr/\u003e(3)\\*\\* | 0.94               | x5.6          | 1.9        | N/A                             | LuaJIT 2.0.5                      |\n| Modula-2                                      | ?               | ?              | 0.20               | x1.2          | **0.5**    | 0.1 + libstdc++                 | gm2 GCC 8.2.0                     |\n| Modula-3                                      | ?               | ?              | 0.47               | x2.8          | 1.8        | 1.0                             | Critical Mass Modula-3 d5.10.0    |\n| Nim                                           | 💚\u003cbr/\u003e(9)      | 💚\u003cbr/\u003e(1)     | 0.48               | x2.9          | **0.5**    | 0.059                           | Nim 1.2.0 / GCC 9.3.0              |\n| Oberon-07                                     | ?               | ?              | 0.24               | x1.4          | 1.3        | 0.031                           | OBNC 0.14.0                       |\n| Object Pascal \"naive unsafe raw pointers\"     | 💛\u003cbr/\u003e(6)      | 💔\u003cbr/\u003e(8)     | 0.35               | x2.1          | **0.4**    | 0.192 (static)                  | FPC 3.0.4                         |\n| OCaml                                         | ?               | ?              | 0.72               | x4.3          | 3.5        | N/A                             | OCaml 4.09.1                      |\n| PHP                                           | 💚\u003cbr/\u003e(9)      | 💙\u003cbr/\u003e(3)\\*\\* | 3.60               | x21           | 5          | N/A                             | PHP 7.4.4                         |\n| Python (CPython)                              | 💚\u003cbr/\u003e(10)\\*\\* | 💙\u003cbr/\u003e(3)\\*\\* | 9.10               | x54           | 3.5        | N/A                             | CPython 3.8.2                     |\n| Python (Cython)                               | 💚\u003cbr/\u003e(10)\\*\\* | 💙\u003cbr/\u003e(3)\\*\\* | 5.01               | x30           | 3.5        | N/A                             | Cython 0.29.16                    |\n| Python (PyPy)                                 | 💚\u003cbr/\u003e(10)\\*\\* | 💙\u003cbr/\u003e(3)\\*\\* | 3.40               | x20           | 57         | N/A                             | PyPy3 7.3.0                       |\n| Ruby                                          | 💚\u003cbr/\u003e(10)\\*\\* | 💙\u003cbr/\u003e(3)\\*\\* | 6.05               | x36           | 9          | N/A                             | Ruby 2.7.1                        |\n| Rust \"idiomatic\"                              | 💙\u003cbr/\u003e(8)      | 💚\u003cbr/\u003e(2)     | 0.23\\*\\*\\*         | x1.4          | **0.4**    | 0.207                           | Rustc 1.42.0                      |\n| Rust \"ref-counted\"                            | 💛\u003cbr/\u003e(6)      | 💙\u003cbr/\u003e(5)     | 0.32               | x1.9          | **0.5**    | 0.211                           | Rustc 1.42.0                      |\n| Swift                                         | 💚\u003cbr/\u003e(9)      | 💚\u003cbr/\u003e(1)     | 1.98               | x12           | 1.9        | 0.016 + Swift shared libraries  | Swift 5.1.5                       |\n\n(\\*) C# has a noticeable VM start time (~0.4 seconds), but we still measure real\nexecution time of the whole program.\n\n(\\*\\*) Having no static types leaves the code clean, but makes it less reliable\nfrom the maintenance perspective.\n\n(\\*\\*\\*) With [a minor\nupdate](https://barrielle.cedeela.fr/research_page/dropping-drops.html)\n([PR #52](https://github.com/frol/completely-unscientific-benchmarks/pull/52)),\nRust solution gets a [~significant~](https://github.com/frol/completely-unscientific-benchmarks/pull/84)\nspeedup while still keeping its safety guarantees (see the result in the\n\"Tuned Implementations Scoreboard\" below).\n\n#### Mac OS (Mac OS 10.13, Intel Core i7-4770HQ CPU) (outdated)\n\n\u003cdetails\u003e\n  \u003csummary\u003eThe Scoreboard\u003c/summary\u003e\n  \u003cp\u003e\n\n| Language                          | Real Time, seconds | Slowdown Time | Binary Size, MB                  | Compiler version                              |\n| --------------------------------- | ------------------ |:-------------:| -------------------------------- | --------------------------------------------- |\n| *Best tuned solution*             | **0.25**           | x1            |                                  |                                               |\n| **C++ \"naive unsafe raw pointers\" (clang)** | **0.25** | x1            | 0.009 + libstdc++                | Apple LLVM version 9.1.0 (clang-902.0.39.1)   |\n| C++ \"naive `shared_ptr`\"          | 0.72               | x2.9          | 0.019 + libstdc++                | Apple LLVM version 9.1.0 (clang-902.0.39.1)   |\n| C#                                | 0.79\\*             | x3.2          | 0.006 + .Net                     | .NET Core 2.1.200                             |\n| D \"naive unsafe raw pointers\"     | 0.26               | x1.04         | 0.019 + D runtime                | LDC 1.9.0                                     |\n| Go \"with pointers\"                | 0.39               | x1.6          | 2.1 (static)                     | Go 1.10.2                                     |\n| Haskell                           | 1.15               | x4.6          | 1.3                              | GHC 8.2.2                                     |\n| JavaScript                        | 1.47               | x5.9          | N/A                              | Node.js 6.11.1                                |\n| Java (no-limit / `-Xm*50M`)       | 0.69 / 0.59        | x2.8 / x2.4   | N/A                              | Oracle JDK 1.8.0                              |\n| Kotlin/JVM (no-limit / `-Xm*50M`) | 0.69 / 0.62        | x2.8 / x2.5   | N/A                              | Kotlinc 1.2.41 + Oracle JDK 1.8.0             |\n| Kotlin/Native                     | 8.2                | x32.8         | 0.543                            | Kotlinc-native 0.6.2                          |\n| Nim                               | 1.0                | x4            | 0.293                            | Nim 0.18                                      |\n| Object Pascal                     | 0.36               | x1.4          | 0.272                            | FPC 3.0.4                                     |\n| Python (CPython)                  | 15.9               | x63.6         | N/A                              | CPython 2.7.10                                |\n| Python (PyPy)                     | 3.7                | x14.8         | N/A                              | PyPy 6.0.0                                    |\n| Rust \"idiomatic\"                  | 0.41               | x1.6          | 0.415                            | Rustc 1.26.0                                  |\n| Rust \"ref-counted\"                | 0.40               | x1.6          | 0.415                            | Rustc 1.26.0                                  |\n| Swift                             | 1.72               | x6.9          | 0.019 + Swift shared libraries   | Apple Swift version 4.1                       |\n\u003c/p\u003e\n\u003c/details\u003e\n\n#### Windows (Windows 10, x64, Intel Core i7-6700HQ CPU) (outdated)\n\n\u003cdetails\u003e\n  \u003csummary\u003eThe Scoreboard\u003c/summary\u003e\n  \u003cp\u003e\n\n| Language                          | Real Time, seconds | Slowdown Time | Binary Size, MB                  | Compiler version                              |\n| --------------------------------- | ------------------ |:-------------:| -------------------------------- | --------------------------------------------- |\n| *Best tuned solution*             | **0.28**           | x1            |                                  |                                               |\n| C++ \"naive unsafe raw pointers\" (msvc 2017) | 0.29     | x1.04         | 0.015 + libstdc++                | MSVC 2017 (19.13.26129)                       |\n| C++ \"naive unsafe raw pointers\" (clang)     | 0.29     | x1.04         | 0.254 + libstdc++                | Clang 6.0.0                                   |\n| **C++ \"naive unsafe raw pointers\" (mingw)** | **0.28** | x1            | 0.039 + libstdc++                | GCC 6.3.0                                     |\n| C++ \"naive `shared_ptr`\" (msvc 2017)        | 0.92     | x3.3          | 0.021 + libstdc++                | MSVC 2017 (19.13.26129)                       |\n| C++ \"naive `shared_ptr`\" (clang)            | 0.84     | x3            | 0.258 + libstdc++                | Clang 6.0.0                                   |\n| C++ \"naive `shared_ptr`\" (mingw)            | 0.65     | x2.3          | 0.031 + libstdc++                | GCC 6.3.0                                     |\n| C#                                | 0.56\\*             | x2            | 0.006 + .Net                     | Visual Studio 2017 (Visual C# Compiler 2.7.0) |\n| D \"naive unsafe raw pointers\"     | 0.31               | x1.1          | 0.681 + D runtime                | LDC 1.9.0                                     |\n| Go \"with pointers\"                | 0.43               | x1.5          | 2.0 (static)                     | Go 1.10.2                                     |\n| Haskell                           | 1.2                | x4.3          | 4.1                              | GHC 8.2.2                                     |\n| JavaScript                        | 1.25               | x4.2          | N/A                              | Node.js 8.11.1                                |\n| Java (no-limit / `-Xm*50M`)       | 0.8 / 0.75         | x2.7 / x2.5   | N/A                              | Oracle JDK 10.0.1                             |\n| Kotlin/JVM (no-limit / `-Xm*50M`) | 0.8 / 0.8          | x2.7 / x2.7   | N/A                              | Kotlinc 1.2.41 + Oracle JDK 10.0.1            |\n| Kotlin/Native                     | 7.8                | x26           | 0.46                             | Kotlinc-native 0.7                            |\n| Nim                               | 1.1                | x3.9          | 0.134                            | Nim 0.18                                      |\n| Object Pascal                     | 0.44               | x1.6          | 0.045                            | FPC 3.0.4                                     |\n| Python (CPython)                  | 15.4               | x51.3         | N/A                              | CPython 2.7.13                                |\n| Python (PyPy)                     | 3.4                | x11.3         | N/A                              | PyPy 6.0.0                                    |\n| Rust \"idiomatic\"                  | 0.42               | x1.5          | 0.16                             | Rustc 1.26.0                                  |\n| Rust \"ref-counted\"                | 0.46               | x1.6          | 0.16                             | Rustc 1.26.0                                  |\n| Swift (Swift for Windows)         | 2.1                | x7.5          | 0.019 + Swift shared libraries   | Swift 4.0.3 (Swift for Windows 1.9.1)         |\n\u003c/p\u003e\n\u003c/details\u003e\n\n### Tuned Implementations Scoreboard\n\n#### Linux (Arch Linux, x64, Intel Core i7-4710HQ CPU)\n\n| Language                                          | Real Time, seconds | Slowdown Time | Memory, MB | Binary Size, MB                 | Compiler Version                  |\n| ------------------------------------------------- | ------------------ |:-------------:| ---------- | ------------------------------- | -------------------------------   |\n| C++ \"tuned raw pointers\" (clang)                  | 0.181              | x1.08         | 0.38       | 0.011 + libstdc++               | Clang 9.0.1                       |\n| C++ \"tuned raw pointers\" (gcc)                    | 0.175              | x1.04         | 0.38       | 0.019 + libstdc++               | GCC 9.3.0                         |\n| C++ \"tuned raw pointers\" (gcc \u0026 static)           | 0.175              | x1.04         | **0.25**   | 1.7 (static)                    | GCC 9.3.0                         |\n| C++ \"raw pointers with pool\" (clang)              | 0.176              | x1.05         | 0.38       | 0.011 + libstdc++               | Clang 9.0.1                       |\n| **C++ \"raw pointers with pool\" (gcc)**            | **0.169**          | x1.01         | 0.38       | 0.015 + libstdc++               | GCC 9.3.0                         |\n| **C++ \"raw pointers with pool\" (gcc \u0026 static)**   | **0.167**          | **x1**        | **0.25**   | 1.7 (static)                    | GCC 9.3.0                         |\n| C++ `unique_ptr` (clang)                          | 0.240              | x1.4          | 0.38       | 0.011 + libstdc++               | Clang 9.0.1                       |\n| C++ `unique_ptr` (gcc)                            | 0.246              | x1.4          | 0.38       | 0.043 + libstdc++               | GCC 9.3.0                         |\n| D \"no D runtime\"                                  | 0.183              | x1.09         | 0.38       | 0.011                           | LDC 1.20.1                        |\n| D \"no D runtime\" `-static`                        | 0.187              | x1.12         | **0.25**   | 0.7 (static)                    | LDC 1.20.1                        |\n| Go \"with sync pool\"                               | 0.348              | x2.1          | 1.8        | 1.2 (static)                    | Go 1.14.1                         |\n| Modula-3 \"untraced references\"                    | 0.244              | x1.4          | 0.8        | 1.0                             | Critical Mass Modula-3 d5.10.0    |\n| Nim `--gc:markAndSweep`                           | 0.244              | x1.4          | 0.8        | 0.058                           | Nim 1.2.0 / GCC 9.3.0             |\n| Nim \"fast\"                                        | 0.357              | x2.1          | 0.5        | 0.054                           | Nim 1.2.0 / GCC 9.3.0             |\n| Nim \"fast\" `--gc:markAndSweep`                    | 0.178              | x1.06         | 0.8        | 0.050                           | Nim 1.2.0 / GCC 9.3.0             |\n| Nim \"manual memory management\"                    | 0.177              | x1.06         | 0.5        | 0.046                           | Nim 1.2.0 / GCC 9.3.0             |\n| Nim \"manual\" (static)                             | 0.178              | x1.06         | 0.38       | 0.8 (static)                    | Nim 1.2.0 / GCC 9.3.0             |\n| Object Pascal \"no-heap cheating\"                  | 0.311              | x1.8          | 8          | 0.027 (static)                  | FPC 3.0.4                         |\n| Rust \"unsafe pointers\"                            | 0.202              | x1.21         | 0.38       | 0.207                           | Rustc 1.42.0                      |\n| Rust \"safe mem::forget\"                           | 0.227              | x1.36         | 0.38       | 0.207                           | Rustc 1.42.0                      |\n| Swift \"unmanaged\"                                 | 0.756              | x4.5          | 2          | 0.027 + Swift shared libraries  | Swift 5.1.5                       |\n| Swift \"unsafe-mutable-buffer-pointer\"             | 0.675              | x4            | 17         | 0.016 + Swift shared libraries  | Swift 5.1.5                       |\n\n\n#### Mac OS (Mac OS 10.13, Intel Core i7-4770HQ CPU) (outdated)\n\n\u003cdetails\u003e\n  \u003csummary\u003eThe Scoreboard\u003c/summary\u003e\n  \u003cp\u003e\n\n| Language                          | Real Time, seconds | Slowdown Time | Binary Size, MB                  | Compiler version                              |\n| --------------------------------- | ------------------ |:-------------:| -------------------------------- | --------------------------------------------- |\n| **C++ \"naive unsafe raw pointers\" (clang)** | **0.25** | x1            | 0.009 + libstdc++                | Apple LLVM version 9.1.0 (clang-902.0.39.1)   |\n| C++ `unique_ptr` (clang)          | 0.3                | x1.2          | 0.009 + libstdc++                | Apple LLVM version 9.1.0 (clang-902.0.39.1)   |\n| Nim `--gc:markAndSweep`           | 0.7                | x2.8          | 0.293                            | Nim 0.18                                      |\n\u003c/p\u003e\n\u003c/details\u003e\n\n#### Windows (Windows 10, x64, Intel Core i7-6700HQ CPU) (outdated)\n\n\u003cdetails\u003e\n  \u003csummary\u003eThe Scoreboard\u003c/summary\u003e\n  \u003cp\u003e\n\n| Language                          | Real Time, seconds | Slowdown Time | Binary Size, MB                  | Compiler version                              |\n| --------------------------------- | ------------------ |:-------------:| -------------------------------- | --------------------------------------------- |\n| **C++ \"naive unsafe raw pointers\" (mingw)** | **0.28** | x1            | 0.039 + libstdc++                | GCC 6.3.0                                     |\n| C++ `unique_ptr` (msvc 2017)      | 0.4                | x1.4          | 0.015 + libstdc++                | MSVC 2017 (19.13.26129)                       |\n| C++ `unique_ptr` (clang)          | 0.36               | x1.3          | 0.254 + libstdc++                | Clang 6.0.0                                   |\n| C++ `unique_ptr` (mingw)          | 0.34               | x1.2          | 0.039 + libstdc++                | GCC 6.3.0                                     |\n| Nim `--gc:markAndSweep`           | 0.83               | x3            | 0.143                            | Nim 0.18                                      |\n\u003c/p\u003e\n\u003c/details\u003e\n\n## Observations\n\nD demonstrated the best performance among garbage-collected solutions. It even\nmanaged to outperform Object Pascal solution which used raw pointers and manual\nmemory management, as well as naive C++ `shared_ptr`-based implementations and\nnaive \"ref-counted\" solution in Rust.\n\nC++ \"ref-counted\" (`shared_ptr`) has significant performance hit on non-Linux\nplatforms.\n\nC++ `unique_ptr` has some non-zero runtime overhead over raw pointers.\n\nJVM speeds up if you limit its memory.\n\nKotlin Native is still much slower than the Kotlin running in JVM.\n\nKotlin JS produces JS code which is ~25% slower than the manual Kotlin to JS\ntranslation.\n\nNim, D, and Rust can go as fast as C/C++ can when you switch to \"unsafe\" manual memory management.\n\nWith CPython vs PyPy you trade speed for memory.\n\n\n## Conversations\n\nOn Reddit in 2020: [r/rust](https://www.reddit.com/r/rust/comments/fwynp1/invisible_performance_wins/).\n\nOn Reddit in 2018: [r/programming](https://www.reddit.com/r/programming/comments/8jbfa7/naive_benchmark_treap_implementation_of_c_rust/), [r/rust](https://www.reddit.com/r/rust/comments/8jbjku/naive_benchmark_treap_implementation_of_c_rust/), [r/ada](https://www.reddit.com/r/ada/comments/8jmdko/naive_benchmark_treap_implementation_of_ada_c/), [r/python](https://www.reddit.com/r/Python/comments/8jm3ee/naive_benchmark_treap_implementation_of_python/), [r/swift](https://www.reddit.com/r/swift/comments/8jfte4/naive_benchmark_treap_implementation_of_c_rust/), [r/dlang](https://www.reddit.com/r/dlang/comments/8jjafb/naive_benchmark_treap_implementation_of_d_c_rust/), [r/kotlin](https://www.reddit.com/r/Kotlin/comments/8jg5zf/naive_benchmark_treap_implementation_of_c_rust/), [r/javascript](https://www.reddit.com/r/javascript/comments/8jc2te/naive_benchmark_treap_implementation_of_c_rust/), [r/nim](https://www.reddit.com/r/nim/comments/8jbmml/naive_benchmark_treap_implementation_of_c_rust/), \n\n## License\n\nCompletely Unscientific Benchmarks project is licensed under either of\n\n * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or\n   http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or\n   http://opensource.org/licenses/MIT)\n\nat your option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrol%2Fcompletely-unscientific-benchmarks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrol%2Fcompletely-unscientific-benchmarks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrol%2Fcompletely-unscientific-benchmarks/lists"}