{"id":19258846,"url":"https://github.com/lucascompython/speed-comparison","last_synced_at":"2026-01-22T12:08:29.803Z","repository":{"id":107554339,"uuid":"465871738","full_name":"lucascompython/speed-comparison","owner":"lucascompython","description":"This project compares the speed of different languages.","archived":false,"fork":false,"pushed_at":"2022-06-06T00:30:22.000Z","size":9110,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T15:00:05.868Z","etag":null,"topics":["benchmark","cpp","csharp","deno","dotnet","golang","java","javascript","lua","php","powershell","programming-languages","python","ruby","rust","sieve-of-eratosthenes","speed","speed-comparison","typescript"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lucascompython.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-03-03T20:20:03.000Z","updated_at":"2025-02-01T18:58:48.000Z","dependencies_parsed_at":"2023-06-08T12:00:15.809Z","dependency_job_id":null,"html_url":"https://github.com/lucascompython/speed-comparison","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lucascompython/speed-comparison","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucascompython%2Fspeed-comparison","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucascompython%2Fspeed-comparison/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucascompython%2Fspeed-comparison/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucascompython%2Fspeed-comparison/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucascompython","download_url":"https://codeload.github.com/lucascompython/speed-comparison/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucascompython%2Fspeed-comparison/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28662938,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"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":["benchmark","cpp","csharp","deno","dotnet","golang","java","javascript","lua","php","powershell","programming-languages","python","ruby","rust","sieve-of-eratosthenes","speed","speed-comparison","typescript"],"created_at":"2024-11-09T19:14:33.544Z","updated_at":"2026-01-22T12:08:29.788Z","avatar_url":"https://github.com/lucascompython.png","language":"Python","readme":"# Speed comparison of programming languages \n\nThis project compares the speed and memory of different programming/scripting languages.\n\nIt calculates prime and composite numbers with a very basic algorithm and an more advanced one, from any given interval to do this comparisom.\u003cbr\u003e\nAll languages use the same algorithms.\n\u003c!-- and it uses an implementation of the [Leibniz formula for π](https://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80) to do the comparison. --\u003e\n\n\n\u003c!-- Here is a video which explains how it works: [Calculating π by hand](https://www.youtube.com/watch?v=HrRMnzANHHs) --\u003e\n---\n\n# Preview\n\n\u003cdiv align=\"center\"\u003e\n\n![plot](https://cdn.discordapp.com/attachments/795277227423301643/978406323182002236/Results.png \"Speed comparison of programming languages\")\n![table](https://cdn.discordapp.com/attachments/795277227423301643/980566875064905748/unknown.png \"Table\") \n\n![lines](https://img.shields.io/tokei/lines/github/lucascompython/speed-comparison)\n\u003cp\u003e\n  \u003ca href=\"https://github.com/lucascompython/speed-comparison/graphs/contributors\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/contributors/lucascompython/speed-comparison\" alt=\"contributors\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/last-commit/lucascompython/speed-comparison\" alt=\"last update\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/lucascompython/speed-comparison/network/members\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/forks/lucascompython/speed-comparison\" alt=\"forks\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/lucascompython/speed-comparison/stargazers\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/stars/lucascompython/speed-comparison\" alt=\"stars\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/lucascompython/speed-comparison/issues/\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/issues/lucascompython/speed-comparison\" alt=\"open issues\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/lucascompython/speed-comparison/blob/master/LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/lucascompython/speed-comparison.svg\" alt=\"license\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n[See more](All_Results_Preview.md)\n\u003c/div\u003e\n\n---\n\n\n\n\n\n## Methods\n\nThe code below is a Python code snippet of the not optimal but not bad algorithm used for counting prime and composite numbers to a given range, that is used for the different languages.\n\n```python\nfor num in range(rounds):\n    ctr = 0\n\n    for i in range(2, num // 2):\n        if num % i == 0:\n            ctr += 1\n            composites += 1\n            break\n\n    if ctr == 0 and num != 1:\n        primes += 1\n```\n\nThe code below is an implemation of the [Sieve of Eratosthenes](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes) in Python\n\n```python\nprimes = [True for _ in range(rounds + 1)]\n\nfor i in range(2, round(sqrt(rounds)) + 1):\n    if primes[i]:\n        for j in range(i ** 2, rounds, i):\n            primes[j] = False\n\ntotal = 0\nfor k in range(2, rounds):\n    if primes[k]:\n        total += 1\ncomposites = rounds - total\n```\n\n\n## Disclaimer\n\nI'm no expert in all these languages, so take my results with a grain of salt.\u003cbr\u003e\nThe speed of the language does not determine its quality.\n\u003c!-- Also the findings just show how good the languages can handle floating point operations, which is only one aspect of a programming language. --\u003e\n\nYou are also more than welcome to contribute and help me.\u003cbr\u003e\nSee [Known Bugs](#known-bugs-because-im-too-lazy-to-fix-them).\n\nThe results shown in [preview](#preview) may vary A LOT because im running this tests on a potato :(\n\n## Languages used in this comparison\n\nIn total there are available 14 languages in this comparison which are:\n\n- [Python](https://www.python.org/) - interpreted\n- [C++](https://isocpp.org/) - compiled\n- [JavaScript](https://www.ecma-international.org/publications-and-standards/standards/ecma-402/) using [Node](https://nodejs.org/en/) - interpreted; JIT\n- [TypeScript](https://www.typescriptlang.org) using [Deno](https://deno.land) - interpreted; JIT\n- [Java](http://www.oracle.com/technetwork/java/index.html) - compiled, VM\n- [C#](https://docs.microsoft.com/en-us/dotnet/csharp/) - compiled\n- [Lua](https://www.lua.org) - interpreted, JIT\n- [PHP](https://www.php.net) - interpreted, JIT\n- [Ruby](www.ruby-lang.org) - interpreted\n- [Go](https://golang.org/) - compiled\n- [Rust](https://www.rust-lang.org/) - compiled\n- [Powershell](https://docs.microsoft.com/en-us/powershell/) - interpreted\n- [Swift](https://www.swift.org) - interpreted / compiled\n- [Dart](https://dart.dev) - compiled, JIT\n\u003c!---\n\n- [Javascript](https://www.ecma-international.org/publications/standards/Ecma-402.htm) using [Node.js](https://nodejs.org/) - interpreted, JIT\n---\u003e\n\n\n\n## Features\n\n- Graphs\n- Tables\n- Advanced but simple command line integration with multiple options for comparing (E.g: choosing with languages to compare and changing the values of the iterations).\n- All languages will read from a txt file.\n- The program will get and display the memory usage.\n- It also has two modes, one for running native and other for running inside a docker container.\n- Can choose to run in sequence or in parallel.\n- Saves results in various formats.\n\u003c!---- Install all the requirements by itself.\n--\u003e\n\n\u003c!-- ## Results\nasdd --\u003e\n## Run it yourself\n\u003c!--\nEverything is run by a Docker container and a bash script which envokes the programs.\n--\u003e\n\nTo measure the execution time, in each language is implemented a timer.\nTo measure the compilation / interpretation time and peak memory usage, before each measurement the GNU time command is invoked. \nThe plots are made with [MatPlotLib](https://matplotlib.org).\nEverything can be ran inside a Docker container.\n\n### Requirements\n\n- `Docker`\n- `Makefile` support\n\n### Instalation and Execution\n\n```bash\ngit clone https://github.com/lucascompython/speed-comparison.git\ncd speed-comparison\nmake run-native #to run natively must have all requirements, to run inside docker use make build \u0026\u0026 make run-docker \n```\n\n## FAQ\n\n\u003e Does it work on Windows?\n\nYes, I think...\n\n\u003e Are the compile/interpret times included in the comparison?\n\nYes, it's measured by the GNU time command!\n\n\u003e Why do you also count reading a file and printing the ouput?\n\nBecause I think this is a more realistic scenario to compare speeds.\n\n## TODO (Mostly by Order)\n\n- [X] Add TypeScript with [Deno](https://deno.land)\n- [X] Add JavaScript with [Node](https://nodejs.org)\n- [X] Add Java\n- [X] Finish adding an optimized version for each language using compiler optimizations and using the [Sieve of Eratosthenes](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes)\n- [X] Add an option to run the comparisons in parallel\n- [X] Add an option to run natively \n- [X] Add C#\n- [X] Add Lua\n- [X] Add Php\n- [X] Add Ruby\n- [X] Add Golang\n- [X] Add Rust\n- [X] Add Terminal graphs\n- [X] Add Powershell\n- [X] Add Swift\n- [X] Add Dart\n- [X] Add the ability to run the comparison multiple times and then show the mean, best and worst time.\n- [ ] Add Bash\n- [ ] Add Zig\n- [ ] Add Julia\n- [ ] Add V\n- [ ] Add other methods of comparing E.g: [Leibniz formula for π](https://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80) to compare the floating point operations\n- [ ] Add full Docker Support\n- [ ] Add Kotlin\n- [ ] Add F#\n- [ ] Add Haskell\n- [ ] Add Scala\n- [ ] Add Nix\n- [ ] Add R\n- [ ] Add R plots instead of MatPlotLib\n- [ ] Add Elixir\n- [ ] Add Raku (Perl6)\n- [ ] Add Nim\n- [ ] And many others...\n\n\n\n## Known Bugs (Because im too lazy to fix them...)\n\n* For the first time running the comparison you might need to to run it twice because deno shows some extra information at the first compilation of a file.\n* Docker doesn't support graphical graphs for now. \n\n\u003cdetails\u003e\n  \u003csummary\u003eSuper top Secret :shushing_face:\u003c/summary\u003e\n  \n\u003c!--START_SECTION:activity--\u003e\n1. **Most** languages are good, use whatever you want.\n2. Execpt HTML\n3. Fuck HTML\n\u003c!--END_SECTION:activity--\u003e\n\n\u003c/details\u003e\n\n\u003c!-- \n## Thanks\n\nThis projects takes inspiration from [Thomas](https://www.thomaschristlieb.de) who did a similar comparison [on his blog](https://www.thomaschristlieb.de/performance-vergleich-zwischen-verschiedenen-programmiersprachen-und-systemen/). --\u003e","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucascompython%2Fspeed-comparison","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucascompython%2Fspeed-comparison","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucascompython%2Fspeed-comparison/lists"}