{"id":21320147,"url":"https://github.com/deep1144/qrcode-benchbark","last_synced_at":"2025-03-15T22:30:06.834Z","repository":{"id":248552561,"uuid":"827920268","full_name":"Deep1144/qrcode-benchbark","owner":"Deep1144","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-15T17:05:49.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T11:28:20.773Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Deep1144.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-07-12T17:04:35.000Z","updated_at":"2024-07-15T17:05:52.000Z","dependencies_parsed_at":"2024-07-15T19:08:07.999Z","dependency_job_id":null,"html_url":"https://github.com/Deep1144/qrcode-benchbark","commit_stats":null,"previous_names":["deep1144/qrcode-benchbark"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deep1144%2Fqrcode-benchbark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deep1144%2Fqrcode-benchbark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deep1144%2Fqrcode-benchbark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deep1144%2Fqrcode-benchbark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Deep1144","download_url":"https://codeload.github.com/Deep1144/qrcode-benchbark/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243801600,"owners_count":20350105,"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":[],"created_at":"2024-11-21T19:45:26.238Z","updated_at":"2025-03-15T22:30:06.816Z","avatar_url":"https://github.com/Deep1144.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React + Vite\n\nThis template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.\n\nCurrently, two official plugins are available:\n\n- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh\n- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh\n\n\n\n# Benchmarking Guide for React Applications\n\n## Introduction\n\nThis guide provides a boilerplate approach for benchmarking methods or libraries in a React application. By following these steps, you can measure CPU usage, execution time, and memory usage for any method you want to benchmark.\n\nWe will use the performance API to measure the time and CPU usage, and performance.memory to measure memory usage.\n\n## Boilerplate Code\n\nBelow is a ready-to-use template for benchmarking methods in a React application.\n\n### Step 1: Setup\n\nImport necessary libraries and initialize your state and refs.\n\n```jsx\n  const [benchmarkResult, setBenchmarkResult] = useState({});\n  const iterations = 2000; // Number of iterations for benchmarking\n```\n\n### Step 2: Define the Method to be Benchmarked\n\nReplace the placeholder method with the actual method you want to benchmark.\n\n```jsx\nconst methodToBenchmark = (callback) =\u003e {\n  // Replace this block with the method you want to benchmark\n  // For example, QR code generation, data processing, etc.\n  // Ensure the callback is called at the end of the method execution\n  callback({});\n};\n```\n\n### Step 3: Benchmarking Function\n\nThe function that runs the benchmark by executing the method multiple times and collecting the metrics.\n\n```jsx\nconst runBenchmark = async () =\u003e {\n  const cpuStart = performance.now();\n  const memoryStart = performance.memory.usedJSHeapSize;\n  const startTime = performance.now();\n\n  for (let i = 0; i \u003c iterations; i++) {\n    await new Promise((resolve) =\u003e {\n      methodToBenchmark(() =\u003e {\n        resolve();\n      });\n    });\n  }\n\n  const endTime = performance.now();\n  const cpuEnd = performance.now();\n  const memoryEnd = performance.memory.usedJSHeapSize;\n\n  const timeTaken = endTime - startTime; // in ms\n  const cpuUsage = cpuEnd - cpuStart; // in ms\n  const memoryUsage = (memoryEnd - memoryStart) / 1024; // in KB\n\n  const avgTimeTaken = (timeTaken / iterations).toFixed(2);\n  const avgCpuUsage = (cpuUsage / iterations).toFixed(2);\n  const avgMemoryUsage = (memoryUsage / iterations).toFixed(2);\n\n  setBenchmarkResult({\n    timeTaken: `${avgTimeTaken} ms`,\n    cpuUsage: `${avgCpuUsage} ms`,\n    memoryUsage: `${avgMemoryUsage} KB`\n  });\n};\n```\n\n\n## How to Use\n\n\n1. **Replace the Method:**\n   Replace the `methodToBenchmark` function with the actual method you want to benchmark.\n\n2. **Run the Benchmark:**\n   Call the \"runBenchmark\" method to start the benchmarking process. The results will be stored in `benchmarkResult` state.\n\n3. **Analyze Results:**\n   Review the results for average time taken, CPU usage, and memory usage.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeep1144%2Fqrcode-benchbark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeep1144%2Fqrcode-benchbark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeep1144%2Fqrcode-benchbark/lists"}