{"id":35518654,"url":"https://github.com/attogram/benchmark1","last_synced_at":"2026-01-03T23:01:44.668Z","repository":{"id":325451451,"uuid":"1101217991","full_name":"attogram/benchmark1","owner":"attogram","description":"Benchmark testing system for PHP vs C","archived":false,"fork":false,"pushed_at":"2025-11-21T12:18:36.000Z","size":3,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-21T13:17:18.187Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/attogram.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-21T11:08:42.000Z","updated_at":"2025-11-21T11:33:35.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/attogram/benchmark1","commit_stats":null,"previous_names":["attogram/benchmark1"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/attogram/benchmark1","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/attogram%2Fbenchmark1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/attogram%2Fbenchmark1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/attogram%2Fbenchmark1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/attogram%2Fbenchmark1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/attogram","download_url":"https://codeload.github.com/attogram/benchmark1/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/attogram%2Fbenchmark1/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28195265,"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":"2026-01-03T02:00:06.471Z","response_time":75,"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":"2026-01-03T23:01:43.123Z","updated_at":"2026-01-03T23:01:44.651Z","avatar_url":"https://github.com/attogram.png","language":null,"readme":"# PHP vs. C Benchmarking System\n\nThis project provides a simple framework for benchmarking the performance of various functions in PHP against their equivalents in C.\n\n## Benchmarked Functions\n\nThe following functions are included in this benchmark suite:\n\n- `password_hash()` (using Argon2i, mem=32768, time=2, threads=1)\n- `hash('sha256', ...)`\n- `substr()`\n- `gmp_init()`\n- `gmp_mul()`\n- `gmp_add()`\n- `gmp_div()`\n- `hexdec()`\n- `time()`\n- Date Math: Addition\n- Date Math: Subtraction\n- `microtime(true)`\n\n## Requirements\n\n- Ubuntu 22.04 (or a compatible Debian-based distribution)\n- `git`\n\n## Setup and Installation\n\n1.  **Clone the repository:**\n    ```bash\n    git clone \u003crepository-url\u003e\n    cd \u003crepository-directory\u003e\n    ```\n\n2.  **Run the installer:**\n    The `install.sh` script will update your package manager and install all the required dependencies (`gcc`, `make`, `php`, `php-gmp`, `libgmp-dev`, `libargon2-dev`, `libssl-dev`, and `bc`).\n    ```bash\n    ./install.sh\n    ```\n\n## How to Run the Benchmarks\n\nThe benchmarking process is broken into two main scripts: `compile.sh` and `benchmark.sh`.\n\n1.  **Make the scripts executable:**\n    (This only needs to be done once.)\n    ```bash\n    chmod +x compile.sh\n    chmod +x benchmark.sh\n    ```\n\n2.  **Compile the C code:**\n    This script navigates to the `c/` directory, cleans any old binaries, and compiles all the C source files using the optimized flags specified in the `Makefile`.\n    ```bash\n    ./compile.sh\n    ```\n\n3.  **Run the benchmark suite:**\n    ```bash\n    ./benchmark.sh [crypto_iterations] [fast_func_iterations]\n    ```\n    -   `[crypto_iterations]` is an optional argument for the number of iterations for slow cryptographic functions (e.g., `password_hash`). Defaults to `1000`.\n    -   `[fast_func_iterations]` is an optional argument for the number of iterations for all other, faster functions. Defaults to `100000`.\n\n    **Example:**\n    ```bash\n    # Run with default iterations\n    ./benchmark.sh\n\n    # Run with 10 crypto iterations and 1,000,000 fast function iterations\n    ./benchmark.sh 10 1000000\n    ```\n\n## How it Works\n\nThe `benchmark.sh` script performs the following actions:\n\n1.  **Executes Benchmarks:** For each function, it runs both the compiled C executable and the corresponding PHP script, passing the same set of parameters (input data and iterations).\n2.  **Collects Results:** It captures the execution time (in seconds) from the output of each script.\n3.  **Generates Report:** The results are saved in a CSV file at `results/benchmark_results.csv`. The script will also print the contents of this file to the console upon completion.\n\n## C Binaries\n\nYou can compile the C binaries at any time by running the `./compile.sh` script or by running `make` inside the `c/` directory. The compiled binaries are committed to the repository.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fattogram%2Fbenchmark1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fattogram%2Fbenchmark1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fattogram%2Fbenchmark1/lists"}