{"id":18076229,"url":"https://github.com/scivision/python-performance","last_synced_at":"2025-04-12T08:12:11.921Z","repository":{"id":22782402,"uuid":"26128501","full_name":"scivision/python-performance","owner":"scivision","description":"Performance benchmarks of Python, Numpy, etc. vs. other languages such as Matlab, Julia, Fortran.","archived":false,"fork":false,"pushed_at":"2024-04-17T17:47:06.000Z","size":725,"stargazers_count":28,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-12T08:12:04.856Z","etag":null,"topics":["benchmark","fortran","gfortran","julia","matlab","microbenchmark","numba","numpy","performance"],"latest_commit_sha":null,"homepage":"https://scivision.dev/speed-of-matlab-vs-python-numpy-numba/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scivision.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-03T16:49:26.000Z","updated_at":"2024-10-11T02:43:09.000Z","dependencies_parsed_at":"2022-08-21T12:31:01.179Z","dependency_job_id":null,"html_url":"https://github.com/scivision/python-performance","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scivision%2Fpython-performance","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scivision%2Fpython-performance/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scivision%2Fpython-performance/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scivision%2Fpython-performance/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scivision","download_url":"https://codeload.github.com/scivision/python-performance/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248537141,"owners_count":21120711,"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":["benchmark","fortran","gfortran","julia","matlab","microbenchmark","numba","numpy","performance"],"created_at":"2024-10-31T11:09:18.580Z","updated_at":"2025-04-12T08:12:11.902Z","avatar_url":"https://github.com/scivision.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python Performance\n\n![Actions Status](https://github.com/scivision/python-performance/workflows/ci/badge.svg)\n\nAll benchmarks are platform-independent (run on any computing device with appropriate hardware).\nCuPy tests require an NVIDIA GPU with CUDA toolkit installed.\n\n## Install\n\nThis command prepares Python prereqs:\n\n```sh\npip install -r requirements.txt\n```\n\nC and Fortran benchmarks requires building first using CMake.\n\n```sh\ncmake --workflow --preset default\n```\n\n## Usage\n\nIterative benchmarks, here using the pisum algorithm:\n\n```sh\npython Pisum.py\n```\n\n![Pi (Machin) benchmark](./gfx/pisum.png)\n\n---\n\nMatrix Multiplication benchmarks:\n\n```sh\npython Matmul.py\n```\n\n![Matrix Multiplication benchmark](./gfx/matmul.png)\n\n### Hypotenuse\n\nFor **Python**,\n[numpy.hypot()](https://numpy.org/doc/stable/reference/generated/numpy.hypot.html)\nis faster up to about a hundred elements, then\n[numpy.sqrt(x**2 + y**2)](https://numpy.org/doc/stable/reference/generated/numpy.sqrt.html)\nbecomes slightly faster.\nThe benefit of `hypot()` is to not overflow for arguments near REALMAX.\n\nFor example, in Python:\n\n```python\nfrom math import sqrt, hypot\n\na=1e154; hypot(a,a); sqrt(a**2+a**2);\n\n1.414213562373095e+154\ninf\n```\n\nFor **Fortran**, observe that with Gfortran compiler that `sqrt(x**2 + y**2)` is slightly faster than `hypot(x,y)` in general across the tested array sizes.\n\nExecute the Hypot speed test by:\n\n```sh\npython Hypot.py\n```\n\n![hypot() vs rsq()](./gfx/hypot.png)\n\n## Notes\n\n### Julia\n\nJulia binaries are often downloaded to a particular directory.\nPython doesn't pickup `.bash_aliases`, which is commonly used to point to Julia.\n\n### MKL selection\n\nhttps://software.intel.com/en-us/articles/intel-mkl-link-line-advisor\n\nWe give a hint to CMake where your MKL libraries on.\nFor example:\n```sh\nMKLROOT=/opt/intel/mkl cmake ..\n```\nOf course this option can be combined with `FC`.\n\nYou can set this environment variable permanently for your convenience\n(normally you always want to use MKL) by adding to your `~/.bashrc` the\nline:\n```sh\nexport MKLROOT=/opt/intel/mkl\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscivision%2Fpython-performance","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscivision%2Fpython-performance","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscivision%2Fpython-performance/lists"}