{"id":23002553,"url":"https://github.com/kartikmehta8/rust-node-benchmarking","last_synced_at":"2026-05-04T00:32:40.738Z","repository":{"id":267507220,"uuid":"901310846","full_name":"kartikmehta8/rust-node-benchmarking","owner":"kartikmehta8","description":"This project benchmarks CPU-intensive tasks using Node.js and Rust bindings, showcasing performance improvements by offloading computations to Rust. It includes APIs \u0026 benchmarking with autocannon library.","archived":false,"fork":false,"pushed_at":"2024-12-10T12:31:13.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-15T17:02:14.238Z","etag":null,"topics":["benchmarking","express","node","rust"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/kartikmehta8.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":"2024-12-10T12:30:59.000Z","updated_at":"2024-12-10T12:31:49.000Z","dependencies_parsed_at":"2024-12-10T19:40:24.087Z","dependency_job_id":null,"html_url":"https://github.com/kartikmehta8/rust-node-benchmarking","commit_stats":null,"previous_names":["kartikmehta8/rust-node-benchmarking"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kartikmehta8/rust-node-benchmarking","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kartikmehta8%2Frust-node-benchmarking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kartikmehta8%2Frust-node-benchmarking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kartikmehta8%2Frust-node-benchmarking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kartikmehta8%2Frust-node-benchmarking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kartikmehta8","download_url":"https://codeload.github.com/kartikmehta8/rust-node-benchmarking/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kartikmehta8%2Frust-node-benchmarking/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32590252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"ssl_error","status_checked_at":"2026-05-03T22:09:10.534Z","response_time":103,"last_error":"SSL_read: 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":["benchmarking","express","node","rust"],"created_at":"2024-12-15T07:11:22.353Z","updated_at":"2026-05-04T00:32:40.717Z","avatar_url":"https://github.com/kartikmehta8.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rust \u0026 Node.js Benchmark Project\n\nThis project demonstrates the use of **Rust bindings in Node.js** to perform a CPU-intensive task (calculating Fibonacci numbers) and benchmarks the performance difference between a **pure Node.js implementation** and a **Rust-powered implementation**. The benchmarking is conducted using the `autocannon` library.\n\n## Project Structure\n\n```\nproject/\n├── src/\n│   └── lib.rs          # Rust implementation of Fibonacci calculation.\n├── target/             # Compiled Rust artifacts.\n├── index.node          # Compiled Neon bindings for Node.js.\n├── index.js            # Node.js server with endpoints.\n├── benchmark.js        # Benchmark script using autocannon.\n├── package.json        # Node.js dependencies.\n├── Cargo.toml          # Rust dependencies and project configuration.\n└── README.md           # Documentation.\n```\n\n## Running the Project\n\n### Start the Server\nRun the Node.js server:\n```bash\nnode index.js\n```\nThe server will start at `http://localhost:3000`.\n\n### API Endpoints\n- **Node.js Endpoint**:\n  ```\n  GET http://localhost:3000/node-fib?n=\u003cnumber\u003e\n  ```\n  Example: `http://localhost:3000/node-fib?n=35`\n\n- **Rust Endpoint**:\n  ```\n  GET http://localhost:3000/rust-fib?n=\u003cnumber\u003e\n  ```\n  Example: `http://localhost:3000/rust-fib?n=35`\n\n---\n\n## Benchmarking\n\nThe benchmarking script uses `autocannon` to test the performance of the two endpoints under load.\n\n### Run Benchmark\nRun the benchmarking script:\n```bash\nnode benchmark.js\n```\n\n### Example Output\n\n```js\n// For Rust Endpoint\n{ method: 'Rust', input: 35, result: 9227465, timeTaken: '29ms' }\n{ method: 'Rust', input: 35, result: 9227465, timeTaken: '27ms' }\n{ method: 'Rust', input: 35, result: 9227465, timeTaken: '27ms' }\n{ method: 'Rust', input: 35, result: 9227465, timeTaken: '28ms' }\n{ method: 'Rust', input: 35, result: 9227465, timeTaken: '30ms' }\n{ method: 'Rust', input: 35, result: 9227465, timeTaken: '35ms' }\n{ method: 'Rust', input: 35, result: 9227465, timeTaken: '35ms' }\n{ method: 'Rust', input: 35, result: 9227465, timeTaken: '32ms' }\n{ method: 'Rust', input: 35, result: 9227465, timeTaken: '28ms' }\n\n// For Node Endpoint\n{ method: 'Node.js', input: 35, result: 9227465, timeTaken: '97ms' }\n{ method: 'Node.js', input: 35, result: 9227465, timeTaken: '88ms' }\n{ method: 'Node.js', input: 35, result: 9227465, timeTaken: '87ms' }\n{ method: 'Node.js', input: 35, result: 9227465, timeTaken: '79ms' }\n{ method: 'Node.js', input: 35, result: 9227465, timeTaken: '99ms' }\n{ method: 'Node.js', input: 35, result: 9227465, timeTaken: '96ms' }\n{ method: 'Node.js', input: 35, result: 9227465, timeTaken: '90ms' }\n{ method: 'Node.js', input: 35, result: 9227465, timeTaken: '88ms' }\n```\n\n## Advantages of Offloading Tasks to Rust\n\n1. **Performance**:\n   - Rust is a systems programming language optimized for performance and memory efficiency.\n   - For CPU-intensive tasks, Rust can outperform Node.js by an order of magnitude due to its compiled nature.\n\n2. **Concurrency**:\n   - Rust handles concurrency efficiently with zero-cost abstractions and safety guarantees, making it ideal for multi-threaded workloads.\n\n3. **Memory Safety**:\n   - Rust guarantees memory safety at compile time, reducing the risk of bugs like segmentation faults and buffer overflows.\n\n4. **Reuse of Existing Code**:\n   - You can integrate high-performance Rust libraries into your Node.js project, leveraging the best of both ecosystems.\n\n## Use Case\nThis project is ideal for scenarios where:\n- You need to process large amounts of data or perform complex computations (e.g., image processing, cryptography, simulations).\n- The performance of pure JavaScript is insufficient for the workload.\n- You want to optimize resource-intensive parts of your Node.js application without rewriting the entire project.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkartikmehta8%2Frust-node-benchmarking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkartikmehta8%2Frust-node-benchmarking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkartikmehta8%2Frust-node-benchmarking/lists"}