{"id":50924149,"url":"https://github.com/stdlib-js/bench-harness","last_synced_at":"2026-06-16T20:34:30.273Z","repository":{"id":57162640,"uuid":"377249242","full_name":"stdlib-js/bench-harness","owner":"stdlib-js","description":"Benchmark harness.","archived":false,"fork":false,"pushed_at":"2026-06-11T03:48:55.000Z","size":4162,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-06-11T05:13:16.780Z","etag":null,"topics":["bench","benchmark","harness","javascript","lib","library","measure","node","node-js","nodejs","perf","performance","standard","stdlib","tap"],"latest_commit_sha":null,"homepage":"https://github.com/stdlib-js/stdlib","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stdlib-js.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["stdlib-js"],"open_collective":"stdlib","tidelift":"npm/@stdlib/stdlib"}},"created_at":"2021-06-15T17:50:19.000Z","updated_at":"2026-06-11T03:28:02.000Z","dependencies_parsed_at":"2023-12-01T04:26:48.471Z","dependency_job_id":"b6ad97ca-6736-458e-9bf4-717502374d60","html_url":"https://github.com/stdlib-js/bench-harness","commit_stats":{"total_commits":71,"total_committers":2,"mean_commits":35.5,"dds":"0.028169014084507005","last_synced_commit":"e337fd515d01c8910dd4d303df629057bf05fd15"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/stdlib-js/bench-harness","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stdlib-js%2Fbench-harness","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stdlib-js%2Fbench-harness/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stdlib-js%2Fbench-harness/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stdlib-js%2Fbench-harness/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stdlib-js","download_url":"https://codeload.github.com/stdlib-js/bench-harness/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stdlib-js%2Fbench-harness/sbom","scorecard":{"id":847574,"data":{"date":"2025-08-11","repo":{"name":"github.com/stdlib-js/bench-harness","commit":"3da044bcb8d26acf86165f1def5217c64e329dbe"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.6,"checks":[{"name":"Security-Policy","score":9,"reason":"security policy file detected","details":["Info: security policy file detected: SECURITY.md:1","Info: Found linked content: SECURITY.md:1","Warn: One or no descriptive hints of disclosure, vulnerability, and/or timelines in security policy","Info: Found text in security policy: SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":4,"reason":"5 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 4","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/cancel.yml:1","Warn: no topLevel permission defined: .github/workflows/close_pull_requests.yml:1","Warn: no topLevel permission defined: .github/workflows/examples.yml:1","Warn: no topLevel permission defined: .github/workflows/npm_downloads.yml:1","Warn: no topLevel permission defined: .github/workflows/productionize.yml:1","Warn: no topLevel permission defined: .github/workflows/publish.yml:1","Warn: no topLevel permission defined: .github/workflows/publish_cli.yml:1","Warn: no topLevel permission defined: .github/workflows/test.yml:1","Warn: no topLevel permission defined: .github/workflows/test_bundles.yml:1","Warn: no topLevel permission defined: .github/workflows/test_coverage.yml:1","Warn: no topLevel permission defined: .github/workflows/test_install.yml:1","Warn: no topLevel permission defined: .github/workflows/test_published_package.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":4,"reason":"dependency not pinned by hash detected -- score normalized to 4","details":["Warn: third-party GitHubAction not pinned by hash: .github/workflows/productionize.yml:84: update your workflow using https://app.stepsecurity.io/secureworkflow/stdlib-js/bench-harness/productionize.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/productionize.yml:274: update your workflow using https://app.stepsecurity.io/secureworkflow/stdlib-js/bench-harness/productionize.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/productionize.yml:448: update your workflow using https://app.stepsecurity.io/secureworkflow/stdlib-js/bench-harness/productionize.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/productionize.yml:456: update your workflow using https://app.stepsecurity.io/secureworkflow/stdlib-js/bench-harness/productionize.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/productionize.yml:621: update your workflow using https://app.stepsecurity.io/secureworkflow/stdlib-js/bench-harness/productionize.yml/main?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/examples.yml:58","Warn: npmCommand not pinned by hash: .github/workflows/examples.yml:58","Warn: npmCommand not pinned by hash: .github/workflows/examples.yml:58","Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:794","Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:794","Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:794","Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:156","Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:156","Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:156","Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:164","Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:268","Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:268","Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:268","Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:435","Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:435","Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:435","Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:615","Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:615","Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:615","Warn: npmCommand not pinned by hash: .github/workflows/test.yml:76","Warn: npmCommand not pinned by hash: .github/workflows/test.yml:76","Warn: npmCommand not pinned by hash: .github/workflows/test.yml:76","Warn: npmCommand not pinned by hash: .github/workflows/test.yml:83","Warn: npmCommand not pinned by hash: .github/workflows/test_bundles.yml:72","Warn: npmCommand not pinned by hash: .github/workflows/test_coverage.yml:67","Warn: npmCommand not pinned by hash: .github/workflows/test_coverage.yml:67","Warn: npmCommand not pinned by hash: .github/workflows/test_coverage.yml:67","Warn: npmCommand not pinned by hash: .github/workflows/test_coverage.yml:74","Warn: npmCommand not pinned by hash: .github/workflows/test_install.yml:75","Warn: npmCommand not pinned by hash: .github/workflows/test_install.yml:75","Warn: npmCommand not pinned by hash: .github/workflows/test_install.yml:75","Warn: npmCommand not pinned by hash: .github/workflows/test_published_package.yml:93","Info:  35 out of  35 GitHub-owned GitHubAction dependencies pinned","Info:  23 out of  28 third-party GitHubAction dependencies pinned","Info:   0 out of  32 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}}]},"last_synced_at":"2025-08-23T21:48:26.417Z","repository_id":57162640,"created_at":"2025-08-23T21:48:26.417Z","updated_at":"2025-08-23T21:48:26.417Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34423216,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"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":["bench","benchmark","harness","javascript","lib","library","measure","node","node-js","nodejs","perf","performance","standard","stdlib","tap"],"created_at":"2026-06-16T20:34:29.353Z","updated_at":"2026-06-16T20:34:30.256Z","avatar_url":"https://github.com/stdlib-js.png","language":"JavaScript","funding_links":["https://github.com/sponsors/stdlib-js","https://opencollective.com/stdlib","https://tidelift.com/funding/github/npm/@stdlib/stdlib"],"categories":[],"sub_categories":[],"readme":"\u003c!--\n\n@license Apache-2.0\n\nCopyright (c) 2018 The Stdlib Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n--\u003e\n\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    About stdlib...\n  \u003c/summary\u003e\n  \u003cp\u003eWe believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.\u003c/p\u003e\n  \u003cp\u003eThe library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.\u003c/p\u003e\n  \u003cp\u003eWhen you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.\u003c/p\u003e\n  \u003cp\u003eTo join us in bringing numerical computing to the web, get started by checking us out on \u003ca href=\"https://github.com/stdlib-js/stdlib\"\u003eGitHub\u003c/a\u003e, and please consider \u003ca href=\"https://opencollective.com/stdlib\"\u003efinancially supporting stdlib\u003c/a\u003e. We greatly appreciate your continued support!\u003c/p\u003e\n\u003c/details\u003e\n\n# Benchmark\n\n[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] \u003c!-- [![dependencies][dependencies-image]][dependencies-url] --\u003e\n\n\u003e Benchmark harness.\n\n\u003c!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --\u003e\n\n\u003csection class=\"intro\"\u003e\n\n\u003c/section\u003e\n\n\u003c!-- /.intro --\u003e\n\n\u003c!-- Package usage documentation. --\u003e\n\n\u003csection class=\"installation\"\u003e\n\n## Installation\n\n```bash\nnpm install @stdlib/bench-harness\n```\n\nAlternatively,\n\n-   To load the package in a website via a `script` tag without installation and bundlers, use the [ES Module][es-module] available on the [`esm`][esm-url] branch (see [README][esm-readme]).\n-   If you are using Deno, visit the [`deno`][deno-url] branch (see [README][deno-readme] for usage intructions).\n-   For use in Observable, or in browser/node environments, use the [Universal Module Definition (UMD)][umd] build available on the [`umd`][umd-url] branch (see [README][umd-readme]).\n-   To use as a general utility for the command line, install the corresponding [CLI package][cli-section] globally.\n\nThe [branches.md][branches-url] file summarizes the available branches and displays a diagram illustrating their relationships.\n\nTo view installation and usage instructions specific to each branch build, be sure to explicitly navigate to the respective README files on each branch, as linked to above.\n\n\u003c/section\u003e\n\n\u003csection class=\"usage\"\u003e\n\n## Usage\n\n```javascript\nvar bench = require( '@stdlib/bench-harness' );\n```\n\n\u003ca name=\"bench\"\u003e\u003c/a\u003e\n\n#### bench( name\\[, options]\\[, benchmark] )\n\nQueues a `benchmark` to be run during a subsequent turn of the event loop. After running the `benchmark`, the function outputs benchmark results as Test Anything Protocol ([TAP][tap]) output.\n\n\u003c!-- eslint-disable no-restricted-syntax, stdlib/no-builtin-math --\u003e\n\n```javascript\nbench( 'Math.sin', function benchmark( b ) {\n    var x;\n    var i;\n    b.tic();\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        x = Math.sin( Math.random() );\n        if ( x !== x ) {\n            b.fail( 'should not return NaN' );\n        }\n    }\n    b.toc();\n    if ( x !== x ) {\n        b.fail( 'should not return NaN' );\n    }\n    b.pass( 'benchmark finished' );\n    b.end();\n});\n```\n\nA `benchmark` function has the following signature:\n\n```javascript\nfunction benchmark( b ) {\n    // Benchmark code...\n}\n```\n\nwhere `b` is a `Benchmark` instance. Synchronous benchmarks should, at minimum, have the following structure:\n\n```javascript\nfunction benchmark( b ) {\n    var x;\n    var i;\n\n    // [1] Start timing:\n    b.tic();\n\n    // [2] Loop containing code to time...\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        // [3] Code to time...\n\n        // [4] A conditional verifying results to prevent certain compiler optimizations:\n        if ( x !== x ) {\n            b.fail( 'something went wrong!' );\n        }\n    }\n    // [5] Stop timing:\n    b.toc();\n\n    // [6] Another conditional verifying results to prevent certain compiler optimizations:\n    if ( x !== x ) {\n        b.fail( 'something went wrong!' );\n    }\n    // [7] End the benchmark:\n    b.end();\n}\n```\n\nAsynchronous benchmarks should have a structure similar to the following:\n\n```javascript\nfunction benchmark( b ) {\n    var i = 0;\n\n    // [1] Start timing:\n    b.tic();\n\n    // [2] Asynchronous code to time:\n    return next();\n\n    function next( error ) {\n        if ( error ) {\n            return b.fail( error.message );\n        }\n        i += 1;\n\n        // [3] Exit condition:\n        if ( i \u003c= b.iterations ) {\n            // Asynchronous task...\n            return;\n        }\n        // [4] Stop timing:\n        b.toc();\n\n        // [5] End the benchmark:\n        b.end();\n    }\n}\n```\n\nFor both synchronous and asynchronous benchmarks, calling `b.end()` is **mandatory**, as failing to do so will cause the harness to hang. For example, the following benchmark will **never** complete.\n\n```javascript\nfunction benchmark( b ) {\n    var i;\n    b.tic();\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        // Synchronous task...\n    }\n    b.toc();\n}\n```\n\n**Avoid** making assertions within timed code, as doing so will **significantly** affect raw performance numbers. For example, **avoid** the following:\n\n\u003c!-- eslint-disable stdlib/no-builtin-math --\u003e\n\n```javascript\nfunction benchmark( b ) {\n    var x;\n    var i;\n    b.tic();\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        x = Math.sin( Math.random() );\n        b.equal( x, x, 'does not return NaN' ); // Avoid doing this!\n    }\n    b.toc();\n    b.equal( x, x, 'does not return NaN' );     // This is fine.\n    b.end();\n}\n```\n\nAdditionally, ensure that all setup code executes **before** calling `b.tic()` and that all cleanup code executes **after** calling `b.toc()`. For example, **avoid** the following:\n\n\u003c!-- eslint-disable stdlib/no-builtin-math --\u003e\n\n```javascript\nfunction benchmark( b ) {\n    var x;\n    var y;\n    var i;\n\n    // Start timing:\n    b.tic();\n\n    // Setup code:\n    x = new Array( b.iterations );                  // Should be before b.tic()!\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        x[ i ] = Math.random();\n    }\n    // Code to be timed...\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        y = Math.sin( x[ i ] );\n        if ( y !== y ) {\n            b.fail( 'should not return NaN' );\n        }\n    }\n    // Verify results:\n    b.equal( x, x, 'does not return NaN' );         // Should be after b.toc()!\n\n    // Stop timing:\n    b.toc();\n\n    b.end();\n}\n```\n\nThe function accepts the following `options`:\n\n-   **iterations**: number of iterations. If `null`, the number of iterations is determined by trying successive powers of `10` until the total time is at least `0.1` seconds. Default: `null`.\n-   **repeats**: number of repeats. Default: `3`.\n-   **timeout**: number of milliseconds before a benchmark is considered failed. Exceeding a timeout does **not**, however, end the benchmark. Ending a long running benchmark requires manual intervention. Default: `300000` (5 minutes).\n-   **skip**: `boolean` indicating whether to skip a benchmark.\n\nBy default, the harness will automatically determine an iteration number for each benchmark such that a benchmark runs for a length of time sufficient to accurately compute benchmark results. To require a specific number of iterations, set the `iterations` option.\n\n\u003c!-- eslint-disable no-restricted-syntax --\u003e\n\n```javascript\nvar opts = {\n    'iterations': 1e6\n};\n\nbench( 'require a specific number of iterations', opts, function benchmark( b ) {\n    var i;\n    b.tic();\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        // Code to be benchmarked...\n    }\n    b.toc();\n    b.end();\n});\n```\n\nTo ensure that benchmark results are reproducible, the harness runs each benchmark function multiple times. To specify a repetition number, set the `repeats` option.\n\n\u003c!-- eslint-disable no-restricted-syntax --\u003e\n\n```javascript\nvar opts = {\n    'repeats': 5\n};\n\nbench( 'repeat a benchmark multiple times', opts, function benchmark( b ) {\n    var i;\n    b.tic();\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        // Code to be benchmarked...\n    }\n    b.toc();\n    b.end();\n});\n```\n\nTo skip a benchmark, set the `skip` option.\n\n\u003c!-- eslint-disable no-restricted-syntax --\u003e\n\n```javascript\nvar opts = {\n    'skip': true\n};\n\nbench( 'skipped benchmark', opts, function benchmark( b ) {\n    var i;\n    b.tic();\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        // Code to be benchmarked...\n    }\n    b.toc();\n    b.end();\n});\n```\n\nTo fail benchmarks which take longer than a specified amount of time to complete, set a `timeout` option (in milliseconds).\n\n\u003c!-- eslint-disable no-restricted-syntax --\u003e\n\n```javascript\nvar opts = {\n    'timeout': 5000    // 5 seconds\n};\n\nbench( 'async benchmark', opts, function benchmark( b ) {\n    var i = 0;\n    b.tic();\n    return next();\n\n    function next( error ) {\n        if ( error ) {\n            return b.fail( error.message );\n        }\n        i += 1;\n        if ( i \u003c= b.iterations ) {\n            // Asynchronous task...\n            return;\n        }\n        b.toc();\n        b.end();\n    }\n});\n```\n\n\u003ca name=\"bench-onfinish\"\u003e\u003c/a\u003e\n\n#### bench.onFinish( clbk )\n\nSets a listener which is invoked once the harness **finishes** running all benchmarks.\n\n```javascript\nfunction onFinish() {\n    console.log( 'Done!' );\n}\n\nbench.onFinish( onFinish );\n```\n\n\u003ca name=\"bench-createstream\"\u003e\u003c/a\u003e\n\n#### bench.createStream( \\[options] )\n\nReturns a results [stream][nodejs-stream].\n\n\u003c!-- eslint-disable no-restricted-syntax --\u003e\n\n```javascript\nvar stdout = require( '@stdlib/streams-node-stdout' );\n\nvar stream = bench.createStream();\n\n// Direct all results to `stdout`:\nstream.pipe( stdout );\n\nvar opts = {\n    'iterations': 1,\n    'repeats': 1\n};\n\nbench( 'beep', opts, function benchmark( b ) {\n    var i;\n    b.tic();\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        b.equal( 3.14, 3.14, 'should be equal' );\n    }\n    b.toc();\n    b.end();\n});\n```\n\n```text\nTAP version 13\n# beep\nok 1 should be equal\n  ---\n  iterations: 1\n  elapsed: 0.002985193\n  rate: 334.98671610177297\n  ...\n#\n1..1\n# total 1\n# pass  1\n#\n# ok\n```\n\nThe results stream can be combined with any [`Writable`][nodejs-writable-stream] stream (e.g., network connection, file, `stdout`, etc).\n\nThe function accepts the same `options` as [@stdlib/streams/node/transform][@stdlib/streams/node/transform]. For example, by default, the method returns a stream which produces [TAP][tap] output as text. To return an object stream,\n\n\u003c!-- eslint-disable no-restricted-syntax --\u003e\n\n```javascript\nvar opts = {\n    'objectMode': true\n};\n\nvar stream = bench.createStream( opts );\nstream.on( 'data', onRow );\n\nfunction onRow( row ) {\n    console.log( JSON.stringify( row ) );\n}\n\nopts = {\n    'iterations': 1,\n    'repeats': 1\n};\n\nbench( 'beep', opts, function benchmark( b ) {\n    var i;\n    b.tic();\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        b.equal( 3.14, 3.14, 'should be equal' );\n    }\n    b.toc();\n    b.end();\n});\n```\n\n```text\n{\"type\":\"benchmark\",\"name\":\"beep\",\"id\":0}\n{\"id\":0,\"ok\":true,\"name\":\"should be equal\",\"operator\":\"equal\",\"actual\":3.14,\"expected\":3.14,\"benchmark\":0,\"type\":\"assert\"}\n{\"ok\":true,\"operator\":\"result\",\"iterations\":1,\"elapsed\":0.00283753,\"rate\":352.41918147120913,\"benchmark\":0,\"type\":\"result\"}\n{\"benchmark\":0,\"type\":\"end\"}\n```\n\n\u003ca name=\"bench-createharness\"\u003e\u003c/a\u003e\n\n#### bench.createHarness( \\[options]\\[, clbk] )\n\nCreates a benchmark harness with a new pending stack and state.\n\n\u003c!-- eslint-disable no-restricted-syntax --\u003e\n\n```javascript\nvar harness = bench.createHarness();\n\nharness( 'beep', function benchmark( b ) {\n    var i;\n    b.tic();\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        // Synchronous task...\n    }\n    b.toc();\n    b.end();\n});\n```\n\nTo trigger an action when a harness finishes running all benchmarks, provide a callback `function`.\n\n\u003c!-- eslint-disable no-restricted-syntax --\u003e\n\n```javascript\nvar harness = bench.createHarness( onFinish );\n\nfunction onFinish() {\n    harness.close();\n}\n\nharness( 'beep', function benchmark( b ) {\n    var i;\n    b.tic();\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        // Synchronous task...\n    }\n    b.toc();\n    b.end();\n});\n```\n\nThe method accepts the following `options`:\n\n-   **autoclose**: `boolean` indicating whether to automatically close a harness after running all benchmarks.\n\nBy default, a `harness` does **not** automatically close. To automatically close a harness once a harness finishes running all benchmarks, set the `autoclose` option to `true`.\n\n\u003c!-- eslint-disable no-restricted-syntax --\u003e\n\n```javascript\nvar harness = bench.createHarness({\n    'autoclose': true\n});\n\nharness( 'beep', function benchmark( b ) {\n    var i;\n    b.tic();\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        // Synchronous task...\n    }\n    b.toc();\n    b.end();\n});\n```\n\n* * *\n\n### Harness\n\nA `harness` has the following properties and methods...\n\n\u003ca name=\"harness-createstream\"\u003e\u003c/a\u003e\n\n#### harness.createStream( \\[options] )\n\nReturns a results [stream][nodejs-stream].\n\n\u003c!-- eslint-disable no-restricted-syntax --\u003e\n\n```javascript\nvar stdout = require( '@stdlib/streams-node-stdout' );\n\nvar harness = bench.createHarness();\nvar stream = harness.createStream();\n\n// Direct all results to `stdout`:\nstream.pipe( stdout );\n\nvar opts = {\n    'iterations': 1,\n    'repeats': 1\n};\n\nharness( 'beep', opts, function benchmark( b ) {\n    var i;\n    b.tic();\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        b.equal( 'beep', 'beep', 'should be equal' );\n    }\n    b.toc();\n    b.end();\n});\n```\n\n```text\nTAP version 13\n# beep\nok 1 should be equal\n  ---\n  iterations: 1\n  elapsed: 0.00166768\n  rate: 599.6354216636286\n  ...\n#\n1..1\n# total 1\n# pass  1\n#\n# ok\n```\n\nThe method accepts the same `options` as [@stdlib/streams/node/transform][@stdlib/streams/node/transform].\n\n**Note**: benchmarks will **not** run until a destination stream has been created.\n\n\u003ca name=\"harness-close\"\u003e\u003c/a\u003e\n\n#### harness.close()\n\nCloses a benchmark harness. Any pending benchmarks are cleared from the harness stack.\n\n\u003c!-- eslint-disable no-restricted-syntax --\u003e\n\n```javascript\nvar stdout = require( '@stdlib/streams-node-stdout' );\n\nvar harness = bench.createHarness();\n\nvar stream = harness.createStream();\nstream.pipe( stdout );\n\nvar opts = {\n    'iterations': 5,\n    'repeats': 5\n};\n\nharness( 'early close', opts, function benchmark( b ) {\n    var i = 0;\n    b.tic();\n    setTimeout( next, 0 );\n    function next() {\n        i += 1;\n        if ( i \u003c= b.iterations ) {\n            b.ok( true, 'should be truthy' );\n            return setTimeout( next, 10 );\n        }\n        b.toc();\n        b.end();\n    }\n});\n\n// Early close:\nsetTimeout( onTimeout, 50 );\n\nfunction onTimeout() {\n    harness.close();\n}\n```\n\n```text\nTAP version 13\n# early close\nok 1 should be truthy\nok 2 should be truthy\n# WARNING: harness closed before completion.\nok 3 should be truthy\nok 4 should be truthy\nok 5 should be truthy\n  ---\n  iterations: 5\n  elapsed: 0.05940291\n  rate: 84.17096064822414\n  ...\n```\n\n**Warning**: a running benchmark may finish **after** closing a harness.\n\n\u003ca name=\"harness-exit\"\u003e\u003c/a\u003e\n\n#### harness.exit()\n\nForcefully exits a benchmark harness. All pending benchmarks will generate **failing** assertions.\n\n\u003c!-- eslint-disable no-restricted-syntax --\u003e\n\n```javascript\nvar stdout = require( '@stdlib/streams-node-stdout' );\n\nvar harness = bench.createHarness();\n\nvar stream = harness.createStream();\nstream.pipe( stdout );\n\nvar opts = {\n    'iterations': 5\n};\n\nharness( 'force exit', opts, function benchmark( b ) {\n    var i = 0;\n    b.tic();\n    return next();\n    function next() {\n        i += 1;\n        if ( i \u003c= b.iterations ) {\n            b.ok( true, 'should be truthy' );\n            return setTimeout( next, 10 );\n        }\n        b.toc();\n        b.end();\n    }\n});\n\n// Forcefully exit:\nsetTimeout( onTimeout, 20 );\n\nfunction onTimeout() {\n    harness.exit();\n}\n```\n\n```text\nTAP version 13\n# force exit\nok 1 should be truthy\nnot ok 2 benchmark exited without ending\n  ---\n  operator: fail\n  TODO: include stack\n  ...\nnot ok 3 benchmark exited without ending\n  ---\n  operator: fail\n  TODO: include stack\n  ...\nok 4 should be truthy\nok 5 should be truthy\nok 6 should be truthy\nok 7 should be truthy\n  ---\n  iterations: 5\n  elapsed: 0.061504862\n  rate: 81.29438612511642\n  ...\n```\n\n**Warning**: a running benchmark may finish **after** exiting a harness.\n\n\u003ca name=\"harness-exitcode\"\u003e\u003c/a\u003e\n\n#### harness.exitCode\n\n**Read-only** property whose value is the harness exit code. If all benchmarks run successfully (i.e., no failing assertions), the exit code is `0`; otherwise, the exit code is `1`.\n\n\u003c!-- eslint-disable no-restricted-syntax --\u003e\n\n```javascript\nvar harness = bench.createHarness();\n\n// Benchmarks only start running when results have a destination:\nvar stream = harness.createStream();\n\nfunction onFinish() {\n    console.log( harness.exitCode );\n    // =\u003e 1\n}\n\nvar opts = {\n    'iterations': 1,\n    'repeats': 1\n};\n\nharness( 'exit code', opts, function benchmark( b ) {\n    var i;\n    b.tic();\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        b.fail( 'failing assertion' );\n    }\n    b.toc();\n    b.end();\n});\n```\n\n* * *\n\n### Benchmark\n\nA `Benchmark` instance has the following properties and methods...\n\n\u003ca name=\"benchmark-name\"\u003e\u003c/a\u003e\n\n#### b.name\n\n**Read-only** property whose value is the benchmark `name`.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/doctest --\u003e\n\n```javascript\nvar str = b.name;\n// returns \u003cstring\u003e\n```\n\n\u003ca name=\"benchmark-iterations\"\u003e\u003c/a\u003e\n\n#### b.iterations\n\n**Read-only** property whose value is the number of iterations.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/doctest --\u003e\n\n```javascript\nvar iter = b.iterations;\n// returns \u003cnumber\u003e\n```\n\n\u003ca name=\"benchmark-tic\"\u003e\u003c/a\u003e\n\n#### b.tic()\n\nStarts a benchmark timer. In order to benchmark code, this method **must always** be called within a `benchmark` function.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/no-builtin-math --\u003e\n\n```javascript\nfunction benchmark( b ) {\n    var x;\n    var i;\n\n    // Start a timer:\n    b.tic();\n\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        x = Math.sin( Math.random() );\n        if ( x !== x ) {\n            b.fail( 'should not return NaN' );\n        }\n    }\n    b.toc();\n    if ( x !== x ) {\n        b.fail( 'should not return NaN' );\n    }\n    b.end();\n}\n```\n\n\u003ca name=\"benchmark-toc\"\u003e\u003c/a\u003e\n\n#### b.toc()\n\nStops a benchmark timer. In order to benchmark code, this method **must always** be called within a `benchmark` function.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/no-builtin-math --\u003e\n\n```javascript\nfunction benchmark( b ) {\n    var x;\n    var i;\n\n    b.tic();\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        x = Math.sin( Math.random() );\n        if ( x !== x ) {\n            b.fail( 'should not return NaN' );\n        }\n    }\n    // Stop a timer:\n    b.toc();\n\n    if ( x !== x ) {\n        b.fail( 'should not return NaN' );\n    }\n    b.end();\n}\n```\n\n\u003ca name=\"benchmark-end\"\u003e\u003c/a\u003e\n\n#### b.end()\n\nExplicitly ends a benchmark. In order to benchmark code, this method **must always** be called within a `benchmark` function.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/no-builtin-math --\u003e\n\n```javascript\nfunction benchmark( b ) {\n    var x;\n    var i;\n\n    b.tic();\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        x = Math.sin( Math.random() );\n        if ( x !== x ) {\n            b.fail( 'should not return NaN' );\n        }\n    }\n    b.toc();\n\n    if ( x !== x ) {\n        b.fail( 'should not return NaN' );\n    }\n\n    // Explicitly end the benchmark:\n    b.end();\n}\n```\n\n**Warning**: no assertions should follow a call to `b.end()`. Including assertions after `b.end()` may result in interleaved [TAP][tap] output or an output stream closing before a benchmark executes pending assertions.\n\n\u003ca name=\"benchmark-comment\"\u003e\u003c/a\u003e\n\n#### b.comment( msg )\n\nWrites a message without breaking [TAP][tap] output.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/doctest --\u003e\n\n```javascript\nb.comment( 'This is a comment.' );\n```\n\n```text\n# This is a comment.\n```\n\nTo prevent confusing results parsers, **avoid** using comments. Comments are frequently used for demarcating the beginning of a new benchmark run and/or providing diagnostic information. Both of the aforementioned use cases typically fall under the domain of the harness, not the user.\n\n\u003ca name=\"benchmark-skip\"\u003e\u003c/a\u003e\n\n#### b.skip( value, msg )\n\nGenerates an assertion which will be skipped.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/doctest --\u003e\n\n```javascript\nb.skip( false, 'This is skipped.' );\nb.skip( true, 'This is skipped.' );\n```\n\n```text\nok 1 This is skipped. # SKIP\nok 2 This is skipped. # SKIP\n```\n\n\u003ca name=\"benchmark-todo\"\u003e\u003c/a\u003e\n\n#### b.todo( value, msg )\n\nGenerates an assertion which should be implemented.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/doctest --\u003e\n\n```javascript\nb.todo( false, 'This is a todo.' );\nb.todo( true, 'This is a todo.' );\n```\n\n```text\nnot ok 3 This is a todo. # TODO\n  ---\n  operator: todo\n  TODO: include stack\n  ...\nok 4 This is a todo. # TODO\n```\n\nWhile `b.todo()` assertions typically fail, they do **not** contribute to the failed assertion count. If a benchmark includes `b.todo()` assertions and no other failing assertions, the benchmark is considered successful.\n\n\u003ca name=\"benchmark-fail\"\u003e\u003c/a\u003e\n\n#### b.fail( msg )\n\nGenerates a failing assertion.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/doctest --\u003e\n\n```javascript\nb.fail( 'This is a failing assertion.' );\n```\n\n```text\nnot ok 5 This is a failing assertion.\n  ---\n  operator: fail\n  TODO: include stack\n  ...\n```\n\n\u003ca name=\"benchmark-pass\"\u003e\u003c/a\u003e\n\n#### b.pass( msg )\n\nGenerates a passing assertion.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/doctest --\u003e\n\n```javascript\nb.pass( 'This is a passing assertion.' );\n```\n\n```text\nok 6 This is a passing assertion.\n```\n\n\u003ca name=\"benchmark-ok\"\u003e\u003c/a\u003e\n\n#### b.ok( value\\[, msg] )\n\nAsserts that a `value` is truthy.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/doctest --\u003e\n\n```javascript\nb.ok( [] );\n```\n\n```text\nok 7 should be truthy\n```\n\nTo override the default message, provide a `msg` argument.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/doctest --\u003e\n\n```javascript\nb.ok( true, 'This asserts a value is truthy.' );\nb.ok( false, 'This asserts a value is truthy.' );\n```\n\n```text\nok 8 This asserts a value is truthy.\nnot ok 9 This asserts a value is truthy.\n  ---\n  operator: ok\n  TODO: include stack\n  ...\n```\n\n\u003ca name=\"benchmark-notok\"\u003e\u003c/a\u003e\n\n#### b.notOk( value\\[, msg] )\n\nAsserts that a `value` is falsy.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/doctest --\u003e\n\n```javascript\nb.notOk( null );\n```\n\n```text\nok 10 should be falsy\n```\n\nTo override the default message, provide a `msg` argument.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/doctest --\u003e\n\n```javascript\nb.notOk( false, 'This asserts a value is falsy.' );\nb.notOk( true, 'This asserts a value is falsy.' );\n```\n\n```text\nok 11 This asserts a value is falsy.\nnot ok 12 This asserts a value is falsy.\n  ---\n  operator: notOk\n  TODO: include stack\n  ...\n```\n\n\u003ca name=\"benchmark-equal\"\u003e\u003c/a\u003e\n\n#### b.equal( actual, expected\\[, msg] )\n\nAsserts that `actual` is **strictly** equal to `expected`.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/doctest --\u003e\n\n```javascript\nvar expected = [];\nvar actual = expected;\n\nb.equal( actual, expected );\n```\n\n```text\nok 13 should be equal\n```\n\nTo override the default message, provide a `msg` argument.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/doctest --\u003e\n\n```javascript\nvar expected = [];\nvar actual = expected;\n\nb.equal( actual, expected, 'This asserts two values are strictly equal.' );\nb.equal( 1.0, 2.0, 'This asserts two values are strictly equal.' );\n```\n\n```text\nok 14 This asserts two values are strictly equal.\nnot ok 15 This asserts two values are strictly equal.\n  ---\n  operator: equal\n  TODO: include stack\n  ...\n```\n\n\u003ca name=\"benchmark-notequal\"\u003e\u003c/a\u003e\n\n#### b.notEqual( actual, expected\\[, msg] )\n\nAsserts that `actual` is not **strictly** equal to `expected`.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/doctest --\u003e\n\n```javascript\nvar expected = [];\nvar actual = [];\n\nb.notEqual( actual, expected );\n```\n\n```text\nok 16 should not be equal\n```\n\nTo override the default message, provide a `msg` argument.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/doctest --\u003e\n\n```javascript\nvar expected = [];\nvar actual = [];\n\nb.notEqual( 1.0, 2.0, 'This asserts two values are not equal.' );\nb.notEqual( actual, expected, 'This asserts two values are not equal.' );\n```\n\n```text\nok 17 This asserts two values are not equal.\nnot ok 18 This asserts two values are not equal.\n  ---\n  operator: notEqual\n  TODO: include stack\n  ...\n```\n\n\u003ca name=\"benchmark-deepequal\"\u003e\u003c/a\u003e\n\n#### b.deepEqual( actual, expected\\[, msg] )\n\nAsserts that `actual` is **deeply** equal to `expected`.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/doctest --\u003e\n\n```javascript\nvar expected = {\n    'a': 'b'\n};\nvar actual = {\n    'a': 'b'\n};\n\nb.deepEqual( actual, expected );\n```\n\n```text\nok 19 should be deeply equal\n```\n\nTo override the default message, provide a `msg` argument.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/doctest --\u003e\n\n```javascript\nvar expected = {\n    'a': 'b'\n};\nvar actual = {\n    'a': 'b'\n};\n\nb.deepEqual( actual, expected, 'This asserts two values are deeply equal.' );\n\nactual.a = 'c';\nb.deepEqual( actual, expected, 'This asserts two values are deeply equal.' );\n```\n\n```text\nTODO\n```\n\n\u003ca name=\"benchmark-notdeepequal\"\u003e\u003c/a\u003e\n\n#### b.notDeepEqual( actual, expected\\[, msg] )\n\nAsserts that `actual` is not **deeply** equal to `expected`.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/doctest --\u003e\n\n```javascript\nvar expected = {\n    'a': 'b'\n};\nvar actual = {\n    'a': 'c'\n};\n\nb.notDeepEqual( actual, expected );\n```\n\n```text\nok 22 should not be deeply equal\n```\n\nTo override the default message, provide a `msg` argument.\n\n\u003c!-- run-disable --\u003e\n\n\u003c!-- eslint-disable stdlib/doctest --\u003e\n\n```javascript\nvar expected = {\n    'a': 'b'\n};\nvar actual = {\n    'a': 'c'\n};\n\nb.notDeepEqual( actual, expected, 'This asserts two values are not deeply equal.' );\n\nactual.a = 'b';\nb.notDeepEqual( actual, expected, 'This asserts two values are not deeply equal.' );\n```\n\n```text\nTODO\n```\n\n\u003c/section\u003e\n\n\u003c!-- /.usage --\u003e\n\n\u003c!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --\u003e\n\n* * *\n\n\u003csection class=\"notes\"\u003e\n\n## Notes\n\n-   All benchmark functions execute **serially** in separate turns of the event loop.\n-   All benchmark functions should be added during the **same** turn of the event loop. Otherwise, you will likely encounter race conditions where a benchmark executes and finishes causing a harness to close **before** subsequent benchmarks register.\n-   Similarly, create results streams **before** adding benchmarks to the harness. Otherwise, you will likely miss benchmark results.\n-   If a harness is invoked without providing a `benchmark` function, the benchmark is considered a `todo` and `opts.repeat` is ignored.\n-   All benchmarks are pretested. If a benchmark generates failing assertions or fails to call `b.tic()` and/or `b.toc()` during pretests (even if due to an intermittent failure), a benchmark is **only** run once (i.e., `options.repeats` is ignored). Similarly, if `options.iterations` is `null` and a benchmark fails during iteration number determination, a benchmark is **only** run once and for one iteration. Accordingly, if a benchmark does not run an expected number of repetitions and/or iterations, this behavior is likely attributable to a benchmark failure during pretesting.\n-   All benchmarks must have a `name`. If a `name` is not provided, the harness will throw an `Error`.\n-   While not required, all benchmarks should have a **unique** `name`. Unique names ensure easier identification and assignment of benchmark results.\n-   Uncaught exceptions in benchmark functions are **not** intercepted and will cause the harness to error.\n-   If any one of `b.tic()`, `b.toc()`, or `b.end()` is called more than once within a benchmark, the benchmark will **fail**.\n-   **Always** verify results. Doing so prevents the compiler from performing dead code elimination and other optimization techniques, which would render timing results meaningless.\n-   While many benchmark frameworks calculate various statistics over raw timing results (e.g., mean and standard deviation), do **not** do this. Instead, consider the fastest time an approximate lower bound for how fast an environment can execute benchmark code. Slower times are more likely attributable to other processes interfering with timing accuracy rather than attributable to variability in JavaScript's speed. In which case, the minimum time is most likely the only result of interest. When considering all raw timing results, apply common sense rather than statistics.\n\n### TAP\n\n-   Results are output in accordance with the Test Anything Protocol ([TAP][tap]) version [13][tap].\n\n-   Example [TAP][tap] output:\n\n    ```text\n    TAP version 13\n    # Math.hypot\n      ---\n      iterations: 1000000\n      elapsed: 0.457849215\n      rate: 2184125.181911691\n      ...\n    ok 1 benchmark finished\n    # Math.hypot\n      ---\n      iterations: 1000000\n      elapsed: 0.454676639\n      rate: 2199365.250432407\n      ...\n    ok 2 benchmark finished\n    # Math.hypot\n      ---\n      iterations: 1000000\n      elapsed: 0.472378014\n      rate: 2116948.652059831\n      ...\n    ok 3 benchmark finished\n    # hypot\n      ---\n      iterations: 1000000\n      elapsed: 0.13120811\n      rate: 7621480.105155086\n      ...\n    ok 4 benchmark finished\n    # hypot\n      ---\n      iterations: 1000000\n      elapsed: 0.129308984\n      rate: 7733414.717727579\n      ...\n    ok 5 benchmark finished\n    # hypot\n      ---\n      iterations: 1000000\n      elapsed: 0.12404053\n      rate: 8061881.064197323\n      ...\n    ok 6 benchmark finished\n    #\n    1..6\n    # total 6\n    # pass  6\n    #\n    # ok\n    ```\n\n-   For each failing assertion, the harness outputs diagnostic information as [YAML][yaml] blocks.\n\n    ```text\n    TODO\n    ```\n\n-   Timing results are output as [YAML][yaml] blocks. The fields are as follows:\n\n    -   **iterations**: number of iterations.\n    -   **elapsed**: total elapsed time beginning with `b.tic()` and ending with `b.toc()` (in seconds).\n    -   **rate**: number of operations per second.\n\n\u003c/section\u003e\n\n\u003c!-- /.notes --\u003e\n\n\u003c!-- Package usage examples. --\u003e\n\n* * *\n\n\u003csection class=\"examples\"\u003e\n\n## Examples\n\n\u003c!-- eslint-disable no-restricted-syntax, stdlib/no-builtin-math --\u003e\n\n\u003c!-- eslint no-undef: \"error\" --\u003e\n\n```javascript\nvar randu = require( '@stdlib/random-base-randu' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar sin = require( '@stdlib/math-base-special-sin' );\nvar bench = require( '@stdlib/bench-harness' );\n\nvar opts = {\n    'iterations': 1e6,\n    'repeats': 3\n};\n\nbench( 'Math.sin', opts, function benchmark( b ) {\n    var x;\n    var y;\n    var i;\n\n    b.tic();\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        x = (randu()*100.0) - 50.0;\n        y = Math.sin( x );\n        if ( y \u003c -1.0 || y \u003e 1.0 ) {\n            b.fail( 'something went wrong!' );\n        }\n    }\n    b.toc();\n\n    if ( isnan( y ) ) {\n        b.fail( 'something went wrong!' );\n    }\n    b.pass( 'benchmark finished' );\n    b.end();\n});\n\nbench( 'sin', opts, function benchmark( b ) {\n    var x;\n    var y;\n    var i;\n\n    b.tic();\n    for ( i = 0; i \u003c b.iterations; i++ ) {\n        x = (randu()*100.0) - 50.0;\n        y = sin( x );\n        if ( y \u003c -1.0 || y \u003e 1.0 ) {\n            b.fail( 'something went wrong!' );\n        }\n    }\n    b.toc();\n\n    if ( isnan( y ) ) {\n        b.fail( 'something went wrong!' );\n    }\n    b.pass( 'benchmark finished' );\n    b.end();\n});\n```\n\n\u003c/section\u003e\n\n\u003c!-- /.examples --\u003e\n\n\u003c!-- Section for describing a command-line interface. --\u003e\n\n* * *\n\n\u003csection class=\"cli\"\u003e\n\n## CLI\n\n\u003csection class=\"installation\"\u003e\n\n## Installation\n\nTo use as a general utility, install the CLI package globally\n\n```bash\nnpm install -g @stdlib/bench-harness-cli\n```\n\n\u003c/section\u003e\n\u003c!-- CLI usage documentation. --\u003e\n\n\n\u003csection class=\"usage\"\u003e\n\n### Usage\n\n```text\nUsage: bench [options] \u003cglob\u003e ...\n\nOptions:\n\n  -h,    --help                Print this message.\n  -V,    --version             Print the package version.\n  -r,    --require module      Load module before running benchmarks.\n```\n\n\u003c/section\u003e\n\n\u003c!-- /.usage --\u003e\n\n\u003c!-- CLI usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --\u003e\n\n\u003csection class=\"notes\"\u003e\n\n### Notes\n\n-   Running benchmark files does **not** require using the command-line interface. For example, to run a single file containing benchmarks,\n\n    ```bash\n    $ node /path/to/benchmark.js\n    ```\n\n-   To load one or more modules **before** running benchmarks, set the `-r` flag one or more times. For example,\n\n    ```bash\n    $ bench -r foo -r bar 'benchmark/*.js'\n    ```\n\n    the modules `foo` and `bar` will both be loaded **before** any benchmarks matching the glob `benchmark/*.js`. The `-r` flag behaves exactly like `require`, and modules are resolved relative to the current working directory. To load local modules, use relative paths.\n\n    ```bash\n    $ bench -r ./foo/bar.js -r ./beep/boop/bap 'benchmark/*.js'\n    ```\n\n    Note that `-r` modules are loaded **before** running benchmarks regardless of order. Hence,\n\n    ```bash\n    $ bench -r foo -r bar 'benchmark/*.js'\n    ```\n\n    and\n\n    ```bash\n    $ bench -r foo 'benchmark/*.js' -r bar\n    ```\n\n    behave the same.\n\n    Depending on the preloaded module, a module may support parameterization via environment variables, command-line options, and/or configuration files.\n\n-   To perform shell expansion on systems supporting globbing, do not quote provided globs.\n\n    ```bash\n    $ bench benchmark/*.js\n    ```\n\n    Beware, however, that globbing via shell expansion may result in shell argument lists which exceed length limits. To prevent shell expansion, wrap globs in quotes.\n\n    ```bash\n    $ bench 'benchmark/*.js'\n    $ bench \"benchmark/*.js\"\n    ```\n\n\u003c/section\u003e\n\n\u003c!-- /.notes --\u003e\n\n\u003c!-- CLI usage examples. --\u003e\n\n\u003csection class=\"examples\"\u003e\n\n### Examples\n\n```bash\n$ bench ./examples/index.js\n```\n\nwill generate [TAP][tap] output similar to the following\n\n```text\nTAP version 13\n# Math.sin\n  ---\n  iterations: 1000000\n  elapsed: 0.107631765\n  rate: 9290937.484858675\n  ...\nok 1 benchmark finished\n# Math.sin\n  ---\n  iterations: 1000000\n  elapsed: 0.100319363\n  rate: 9968165.368035682\n  ...\nok 2 benchmark finished\n# Math.sin\n  ---\n  iterations: 1000000\n  elapsed: 0.095116262\n  rate: 10513449.31952856\n  ...\nok 3 benchmark finished\n# sin\n  ---\n  iterations: 1000000\n  elapsed: 0.173696195\n  rate: 5757178.503536016\n  ...\nok 4 benchmark finished\n# sin\n  ---\n  iterations: 1000000\n  elapsed: 0.158544701\n  rate: 6307369.42762912\n  ...\nok 5 benchmark finished\n# sin\n  ---\n  iterations: 1000000\n  elapsed: 0.157709895\n  rate: 6340756.234730865\n  ...\nok 6 benchmark finished\n#\n1..6\n# total 6\n# pass  6\n#\n# ok\n```\n\n\u003c/section\u003e\n\n\u003c!-- /.examples --\u003e\n\n\u003c/section\u003e\n\n\u003c!-- /.cli --\u003e\n\n\u003c!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. --\u003e\n\n* * *\n\n\u003csection class=\"references\"\u003e\n\n## References\n\n-   Chen, Jiahao, and Jarrett Revels. 2016. \"Robust benchmarking in noisy environments.\" _CoRR_ abs/1608.04295 (August). \u003chttp://arxiv.org/abs/1608.04295\u003e.\n\n\u003c/section\u003e\n\n\u003c!-- /.references --\u003e\n\n\u003c!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --\u003e\n\n\u003csection class=\"related\"\u003e\n\n\u003c/section\u003e\n\n\u003c!-- /.related --\u003e\n\n\u003c!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --\u003e\n\n\n\u003csection class=\"main-repo\" \u003e\n\n* * *\n\n## Notice\n\nThis package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.\n\nFor more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].\n\n#### Community\n\n[![Chat][chat-image]][chat-url]\n\n---\n\n## License\n\nSee [LICENSE][stdlib-license].\n\n\n## Copyright\n\nCopyright \u0026copy; 2016-2026. The Stdlib [Authors][stdlib-authors].\n\n\u003c/section\u003e\n\n\u003c!-- /.stdlib --\u003e\n\n\u003c!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --\u003e\n\n\u003csection class=\"links\"\u003e\n\n[npm-image]: http://img.shields.io/npm/v/@stdlib/bench-harness.svg\n[npm-url]: https://npmjs.org/package/@stdlib/bench-harness\n\n[test-image]: https://github.com/stdlib-js/bench-harness/actions/workflows/test.yml/badge.svg?branch=main\n[test-url]: https://github.com/stdlib-js/bench-harness/actions/workflows/test.yml?query=branch:main\n\n[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/bench-harness/main.svg\n[coverage-url]: https://codecov.io/github/stdlib-js/bench-harness?branch=main\n\n\u003c!--\n\n[dependencies-image]: https://img.shields.io/david/stdlib-js/bench-harness.svg\n[dependencies-url]: https://david-dm.org/stdlib-js/bench-harness/main\n\n--\u003e\n\n[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg\n[chat-url]: https://stdlib.zulipchat.com\n\n[stdlib]: https://github.com/stdlib-js/stdlib\n\n[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors\n\n[cli-section]: https://github.com/stdlib-js/bench-harness#cli\n[cli-url]: https://github.com/stdlib-js/bench-harness/tree/cli\n[@stdlib/bench-harness]: https://github.com/stdlib-js/bench-harness/tree/main\n\n[umd]: https://github.com/umdjs/umd\n[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules\n\n[deno-url]: https://github.com/stdlib-js/bench-harness/tree/deno\n[deno-readme]: https://github.com/stdlib-js/bench-harness/blob/deno/README.md\n[umd-url]: https://github.com/stdlib-js/bench-harness/tree/umd\n[umd-readme]: https://github.com/stdlib-js/bench-harness/blob/umd/README.md\n[esm-url]: https://github.com/stdlib-js/bench-harness/tree/esm\n[esm-readme]: https://github.com/stdlib-js/bench-harness/blob/esm/README.md\n[branches-url]: https://github.com/stdlib-js/bench-harness/blob/main/branches.md\n\n[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/bench-harness/main/LICENSE\n\n[tap]: https://testanything.org/tap-version-13-specification.html\n\n[yaml]: https://yaml.org/\n\n[nodejs-stream]: https://nodejs.org/api/stream.html\n\n[nodejs-writable-stream]: https://nodejs.org/api/stream.html#stream_writable_streams\n\n[@stdlib/streams/node/transform]: https://github.com/stdlib-js/streams-node-transform\n\n\u003c/section\u003e\n\n\u003c!-- /.links --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstdlib-js%2Fbench-harness","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstdlib-js%2Fbench-harness","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstdlib-js%2Fbench-harness/lists"}