{"_id":"@andrewosh/nanobench","_rev":"3-94b999868d2e6d8f881bd099b94d8802","name":"@andrewosh/nanobench","dist-tags":{"latest":"2.3.0"},"versions":{"2.2.0":{"name":"@andrewosh/nanobench","version":"2.2.0","description":"Simple benchmarking tool with TAP-like output that is easy to parse","main":"index.js","dependencies":{"browser-process-hrtime":"^0.1.2","chalk":"^1.1.3","mutexify":"^1.1.0","pretty-hrtime":"^1.0.2"},"devDependencies":{"standard":"^8.5.0"},"scripts":{"test":"standard"},"bin":{"nanobench":"./run.js","nanobench-compare":"./compare.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/nanobench.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/nanobench/issues"},"homepage":"https://github.com/mafintosh/nanobench","gitHead":"7653645669e3aed79f4f046ce1ede4c04da16cd3","_id":"@andrewosh/nanobench@2.2.0","_npmVersion":"5.5.1","_nodeVersion":"9.3.0","_npmUser":{"name":"andrewosh","email":"andrewosh@gmail.com"},"dist":{"integrity":"sha512-NYsPIKAJsXk1PSUcDEd9jWluLxAkvFlOSSUbd88yVdMA3z9Eoz6N4CHEF8SPtRcZy23zryvUW3deyW2ua1Fqhw==","shasum":"8ddead063c43e93224b4e8cf3dff11c8fc224822","tarball":"https://registry.npmjs.org/@andrewosh/nanobench/-/nanobench-2.2.0.tgz","fileCount":9,"unpackedSize":25598,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDPXoLTAvLAYKwGyN5I4vpUe8s97RmhGBPxxGNhbM0cBAIhAPwwkO1vhKdqIujnoupkFDSwF2t1/pGw49sFa0RRLiUE"}]},"maintainers":[{"name":"andrewosh","email":"andrewosh@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nanobench_2.2.0_1521496837246_0.9998778956532928"},"_hasShrinkwrap":false},"2.3.0":{"name":"@andrewosh/nanobench","version":"2.3.0","description":"Simple benchmarking tool with TAP-like output that is easy to parse","main":"index.js","dependencies":{"browser-process-hrtime":"^0.1.2","chalk":"^1.1.3","mutexify":"^1.1.0","pretty-hrtime":"^1.0.2"},"devDependencies":{"standard":"^8.5.0"},"scripts":{"test":"standard"},"bin":{"nanobench":"./run.js","nanobench-compare":"./compare.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/nanobench.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/nanobench/issues"},"homepage":"https://github.com/mafintosh/nanobench","gitHead":"fc15af68b51125a01afd86b425892a96f8ac1968","_id":"@andrewosh/nanobench@2.3.0","_npmVersion":"5.5.1","_nodeVersion":"9.3.0","_npmUser":{"name":"andrewosh","email":"andrewosh@gmail.com"},"dist":{"integrity":"sha512-4I6puzf3+jDRhLcxd9u1lcRsGygOZqmzWAqkVEniv24Ve1eCwdrWvPft8XBIPX0aql8wQnuDf9gJGJ/PJViDfQ==","shasum":"a0459f98c271d339382fbd257eba5e7d39e65e81","tarball":"https://registry.npmjs.org/@andrewosh/nanobench/-/nanobench-2.3.0.tgz","fileCount":9,"unpackedSize":25598,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDHy3h5RFcNB86Tgti9eqKfK/N2lc2WPbppGOlh5jd40AiEA0/nKtZyecA4W2LH4GktSiy2+cDYIU9MNYqXhUXhuadk="}]},"maintainers":[{"name":"andrewosh","email":"andrewosh@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nanobench_2.3.0_1521497468945_0.15087698812038997"},"_hasShrinkwrap":false}},"time":{"created":"2018-03-19T22:00:37.245Z","2.2.0":"2018-03-19T22:00:37.384Z","modified":"2022-04-04T14:01:47.535Z","2.3.0":"2018-03-19T22:11:09.083Z"},"maintainers":[{"name":"andrewosh","email":"andrewosh@gmail.com"}],"description":"Simple benchmarking tool with TAP-like output that is easy to parse","homepage":"https://github.com/mafintosh/nanobench","repository":{"type":"git","url":"git+https://github.com/mafintosh/nanobench.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"bugs":{"url":"https://github.com/mafintosh/nanobench/issues"},"license":"MIT","readme":"# nanobench\n\nSimple benchmarking tool with TAP-like output that is easy to parse.\n\n```\nnpm install nanobench\n```\n\n## Usage\n\n``` js\nvar bench = require('nanobench')\n\nbench('sha256 200.000 times', function (b) {\n  var crypto = require('crypto')\n  var data = new Buffer('hello world')\n\n  b.start()\n\n  for (var i = 0; i < 200000; i++) {\n    data = crypto.createHash('sha256').update(data).digest()\n  }\n\n  b.end()\n})\n\nbench('sha1 200.000 times', function (b) {\n  var crypto = require('crypto')\n  var data = new Buffer('hello world')\n\n  b.start()\n\n  for (var i = 0; i < 200000; i++) {\n    data = crypto.createHash('sha1').update(data).digest()\n  }\n\n  b.end()\n})\n```\n\nRunning the above will produce output similar to this:\n\n```\nNANOBENCH version 2\n> node example.js\n\n# sha1 200.000 times\nok ~554 ms (0 s + 554449000 ns)\n\n# sha256 200.000 times\nok ~598 ms (0 s + 597703365 ns)\n\nall benchmarks completed\nok ~1.15 s (1 s + 152152365 ns)\n```\n\n## API\n\n#### `benchmark(name, run)`\n\nAdd a new benchmark. `run` is called with a benchmark object, `b` that has the following methods\n\n* `b.start()` - Start the benchmark. If not called the bench will be tracked from the beginning of the function.\n* `b.end()` - End the benchmark.\n* `b.error(err)` - Benchmark failed. Report error.\n* `b.log(msg)` - Log out a message\n\n#### `benchmark.skip(name, run)`\n\nSkip a benchmark.\n\n#### `benchmark.only(name, run)`\n\nOnly run this benchmark.\n\n## CLI\n\nIf you have multiple benchmarks as different files you can use the cli benchmark runner to run them all\n\n```\nnpm install -g nanobench\nnanobench benchmarks/*.js\n```\n\n## Comparing benchmarks\n\nA comparison tool for comparing two benchmark outputs is included as well.\nThis is useful if fx you ran a benchmark on two different git checkouts and want to compare which\none was the fastest one\n\n``` sh\n> git checkout hash-using-sha256\n> node benchmark.js > output-sha256\n> git checkout hash-using-blake2b\n> node benchmark.js > output-blake2b\n\nnanobench-compare output-sha256 output-blake2b\n```\n\nThe compare tool will print out something like this\n\n```\nNANOBENCH version 2               |    NANOBENCH version 2\n> node benchmark.js               |    > node benchmark.js\n                                  |\n# hashing 200.000 times          >>>   # hashing 200.000 times\n# (using sha256)                 >>>   # (using blake2b)\nok ~591 ms (0 s + 590687187 ns)  >>>   ok ~95 ms (0 s + 95347216 ns)\n                                  |\nall benchmarks completed         >>>   all benchmarks completed\nok ~591 ms (0 s + 590687187 ns)  >>>   ok ~95 ms (0 s + 95347216 ns)\n                                  |\n```\n\nWhere `>>>` means that right one was faster, `<<<` that the left one was, and `===` that they were within 5% of other\n\n\n\n## Parser\n\nAn parser for the output format is included as well. You can require it from node using\n\n``` js\nvar parse = require('nanobench/parse')\nvar output = parse(outputAsString)\nconsole.log(output)\n```\n\nIf you parse the above example output an object similar to this will be printed out\n\n``` js\n{ type: 'NANOBENCH',\n  version: 2,\n  command: 'nanobench example.js',\n  benchmarks:\n   [ { name: 'sha256 200.000 times',\n       output: [],\n       error: null,\n       time: [Object] },\n     { name: 'sha1 200.000 times',\n       output: [],\n       error: null,\n       time: [Object] },\n     { name: 'sha256 200.000 times',\n       output: [],\n       error: null,\n       time: [Object] } ],\n  error: null,\n  time: [ 1, 802600099 ] }\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}