{"_id":"@danny.andrews/asymptotic-analyzer","name":"@danny.andrews/asymptotic-analyzer","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@danny.andrews/asymptotic-analyzer","version":"0.0.1","main":"./src/util.js","type":"module","license":"MIT","scripts":{"start":"./bin/analyze.js test/workbenches.js"},"bin":{"analyze":"bin/analyze.js"},"dependencies":{"@preact/signals":"^1.1.1","@shoelace-style/shoelace":"^2.0.0-beta.52","ajv":"^8.11.0","avj":"^0.0.0","chart.js":"^3.5.1","common-tags":"^1.8.2","esbuild":"^0.15.7","fast-check":"^2.17.0","highlight.js":"^11.6.0","preact":"^10.11.0","pure-rand":"^5.0.0","ramda":"^0.27.1","rxjs":"^7.3.0","vite":"^3.1.0"},"gitHead":"d5024e029c0036b82a4c3edec5121f795d08e520","description":"This repo contains a command-line tool for benchmarking functions asymptotically in an interactive way. Currently, it's most useful for comparing various implementations of algorithms to see which one performs better for various input sizes; so it gives y","_id":"@danny.andrews/asymptotic-analyzer@0.0.1","_nodeVersion":"16.14.2","_npmVersion":"8.5.0","dist":{"integrity":"sha512-H7WbClHA2qC72vW8+XFvnzw0RHSyzoHSDemshs4EIbiLeuLLpfxGwQGw24O3PAJq+wUr1wObhhtR1SO7hwEE2w==","shasum":"e7f891fdee9854435c949694caec3b47d20e883f","tarball":"https://registry.npmjs.org/@danny.andrews/asymptotic-analyzer/-/asymptotic-analyzer-0.0.1.tgz","fileCount":26,"unpackedSize":26421,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC4+2A0GAu+ej5Ti8anhmHi7UxfivJc2LkThEIDnTAJIQIgGI+fWSSDQy9DBCghcYRbOX1J5lGO2hAJ+Tq9z6gem9I="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjO1IdACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq7IA//QkkOTOw10Q4B9bWx323iy3kUVRzEBKYnwj5CDVlRo8YBBM68\r\nfuFG+a6ZWa2q33A+z7yZGA3DYhCXLFJDr3uiX/dD0LKR3pO9zgI/lNHDBAnv\r\nLGhGEYQnIVi8+72GqtUk7jveW9XT0Pn3OXf8GcEA4+Bd6VYTab2kCGFlGzbM\r\nJLdF8rIA222c3Hio6wJycqLjv2k+3/1yf8ShJgRJbhIjcByRL5QD4iACDHBW\r\nbxvn+gfxwOsYgC4RhCY6HqYWg4+fzJg8h1OH120IyNRU6lA19Emnfae+ow51\r\nSQNBbsWTVjUlUGOVwbM+dZtKmKAw9dUEy+S3h4KXDSlfrblEWQQfGMz937A0\r\naUFgpE6DAaJ4Eiwr2lDB/aDAES//mqwNzHSif/Pv8e2cE3khO0XqH9CI81em\r\nZM7r5Fq3CX9UWL7TWJgLarhSQOa7qJfiWp3Eu3SRbTlUyWPlE4Rm/zx+HEra\r\nvovOURT3qXqH3Q48NxAoytD2WKISQTu3Lro2l10pHDnlwmjQB6mo5QcgeJwA\r\nGE+WCi5RSA5MseIxri/OCqz44MFbYWjYuECGSZ3ejlrQbxepKmnCM8XbLa88\r\nr2K2M17yS0ncxhGokXkvtITnS52wXDGV0L4acuFBEI/igM+CU4zkiQOqgPR3\r\nAJZJC9cPrFoMaSyygG5pYHGb+BTNp77JWVs=\r\n=Pgxm\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"danny.andrews","email":"lunde.andrews@gmail.com"},"directories":{},"maintainers":[{"name":"danny.andrews","email":"lunde.andrews@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/asymptotic-analyzer_0.0.1_1664832028830_0.4295712772217002"},"_hasShrinkwrap":false}},"time":{"created":"2022-10-03T21:20:28.775Z","0.0.1":"2022-10-03T21:20:29.012Z","modified":"2022-10-03T21:20:29.188Z"},"maintainers":[{"name":"danny.andrews","email":"lunde.andrews@gmail.com"}],"description":"This repo contains a command-line tool for benchmarking functions asymptotically in an interactive way. Currently, it's most useful for comparing various implementations of algorithms to see which one performs better for various input sizes; so it gives y","license":"MIT","readme":"# Asymptotic Analyzer\n\nThis repo contains a command-line tool for benchmarking functions asymptotically in an interactive way. Currently, it's most useful for comparing various implementations of algorithms to see which one performs better for various input sizes; so it gives you much more information than a simple benchmarking tool that only runs a single input against a function.\n\nEventually, this tool can be used to estimate runtime complexity in an interactive way, as well as profile memory usage, but these features have not been completed yet.\n\n## Usage\n\n1. Install: `$ npm install --save-dev asymptotic-analyzer`.\n2. Define a workbenches file, for example `./test/workbenches.js` (more on that below).\n3. Run the script against your workbenches file: `$ npx analyze ./test/workbenches.js`.\n\n## Defining a Workbenches File\n\nNext, you'll need to create a file which exports the sets of functions you are interested in benchmarking, along with functions for generating valid inputs for those functions. Take a look at `./test/workbenches.js` for an example.\n\nThe default export in this file must match the following `Workbenches` type:\n\n```ts\ntype Workbenches = Array<Workbench>;\n\ntype Workbench = {\n  // The name of the workbench to display in the UI. Must be unique.\n  name: string;\n  // The functions to analyze.\n  subjects: Array<Subject>;\n  // A function which, given an input size, returns a valid input for the\n  // subjects you're testing.\n  generator: InputGenerator | Array<InputGenerator>;\n  // An array containing values to use as n values.\n  domain: Array<Number>;\n};\n\ntype Subject = (...args: Array<any>) => any;\n\ntype InputGenerator = (n: number) => any;\n```\n\nHere's a simple example:\n\n```js\n// workbenches.js\n\nconst copyWithForLoop = (arr) => {\n  let result = [];\n  for (let i = 0; i < arr.length; i++) {\n    result.push(arr[i]);\n  }\n\n  return result;\n};\n\nconst copyWithForEachLoop = (arr) => {\n  let result = [];\n  arr.forEach((val) => {\n    result.push(val);\n  });\n\n  return result;\n};\n\nexport default [\n  {\n    name: \"Array Copy\",\n    subjects: [copyWithForLoop, copyWithForEachLoop],\n    generator: (n) => [...Array(n).keys()],\n    domain: [1, 2, 3, 4, 5, 6, 7, 8].map((num) => num * 10000),\n  },\n];\n```\n\n## Future Plans\n\n1. Memory usage profiling.\n1. Interactive time complexity estimation.\n","readmeFilename":"README.md"}