{"_id":"perfy","_rev":"13-5cf012b8b3a048bc92efd78e41a46c85","name":"perfy","dist-tags":{"latest":"2.1.0"},"versions":{"1.0.0":{"name":"perfy","version":"1.0.0","keywords":["perfy","perf","performance","measure","execution","time","benchmark","elapsed"],"author":{"name":"Onur Yıldırım","email":"onur@cutepilot.com"},"license":"MIT","_id":"perfy@1.0.0","maintainers":[{"name":"onury","email":"onur@cutepilot.com"}],"homepage":"https://github.com/onury/perfy#readme","bugs":{"url":"https://github.com/onury/perfy/issues"},"dist":{"shasum":"ab2dfd47d1ffbeae389dddd8d11aa84eebae4292","tarball":"https://registry.npmjs.org/perfy/-/perfy-1.0.0.tgz","integrity":"sha512-JEnBefqxGW1T7tyZwiVdTYzE9p0i2wvSXfnI0bpbMISLF6j6NdClNcFgqjcb18GFjQdNpyB6PxlMoykeIB0GqQ==","signatures":[{"sig":"MEUCIDaJlWhzIs9boyJnFu3Zg37v6b6mMLEzPsGFjrsC0X4UAiEAznfjPU0PcSJL6eQoLfu9m/y2LN6T2cVX6cU53t0Jbtc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","files":["index.js","LICENSE"],"_shasum":"ab2dfd47d1ffbeae389dddd8d11aa84eebae4292","gitHead":"7fcdba9b9bfee0d46a5b7c49ec06ad8dbe96c69f","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"onury","email":"onur@cutepilot.com"},"repository":{"url":"git+https://github.com/onury/perfy.git","type":"git"},"_npmVersion":"2.14.4","description":"A simple, light-weight NodeJS utility for measuring code execution in high-resolution real times.","directories":{},"_nodeVersion":"4.1.1","devDependencies":{"grunt":"^0.4.5","grunt-jasmine-nodejs":"^1.4.3"}},"1.0.1":{"name":"perfy","version":"1.0.1","keywords":["perfy","perf","performance","measure","execution","time","benchmark","elapsed"],"author":{"name":"Onur Yıldırım","email":"onur@cutepilot.com"},"license":"MIT","_id":"perfy@1.0.1","maintainers":[{"name":"onury","email":"onur@cutepilot.com"}],"homepage":"https://github.com/onury/perfy#readme","bugs":{"url":"https://github.com/onury/perfy/issues"},"dist":{"shasum":"cef6284ae763ab1d1fcfbbdd4c17412dd5e2f4ed","tarball":"https://registry.npmjs.org/perfy/-/perfy-1.0.1.tgz","integrity":"sha512-UCNiMhCDpCisAMEy8La6c1JbwDELftdn+UU6bOmSSHsi2bRMRZx+9B5T2w6YTPCIFJMMMA1PpUZ9P42Gnj1tgw==","signatures":[{"sig":"MEYCIQDvspMdkYPB1c6h/tcu3Z++TLf8RyLtJrK8eYC7HMhQMgIhAMBTyqXwJmPzV7IPWndRshAyZOUBmo7lh3ZvNzsz1Xll","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","files":["index.js","LICENSE"],"_shasum":"cef6284ae763ab1d1fcfbbdd4c17412dd5e2f4ed","gitHead":"1d88d781bdb1f82f2c81ddae9ea977043693613a","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"onury","email":"onur@cutepilot.com"},"repository":{"url":"git+https://github.com/onury/perfy.git","type":"git"},"_npmVersion":"2.14.4","description":"A simple, light-weight NodeJS utility for measuring code execution in high-resolution real times.","directories":{},"_nodeVersion":"4.1.1","devDependencies":{"grunt":"^0.4.5","grunt-jasmine-nodejs":"^1.4.3"}},"1.1.0":{"name":"perfy","version":"1.1.0","keywords":["perfy","perf","performance","measure","execution","time","benchmark","elapsed"],"author":{"name":"Onur Yıldırım","email":"onur@cutepilot.com"},"license":"MIT","_id":"perfy@1.1.0","maintainers":[{"name":"onury","email":"onur@cutepilot.com"}],"homepage":"https://github.com/onury/perfy#readme","bugs":{"url":"https://github.com/onury/perfy/issues"},"dist":{"shasum":"d5478a67c3ea0b634acca03e59b5236ad2be2373","tarball":"https://registry.npmjs.org/perfy/-/perfy-1.1.0.tgz","integrity":"sha512-2xL50uW9KAU1+hWMB1ZKcb6Av37oOJrh04tIdeolAhPfo6kb+3+HMscp7HWV63zUgidu4H3XN7VMMCwCTQFBJQ==","signatures":[{"sig":"MEUCIDIjqGC6D4e9XkPgmWJ+y22AOYHdz3SXupXzehiPgMJeAiEAyHSXcMXlA06QsEhiCS+r7mAwjYrJqMR4qUWLI4rhgsc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","files":["index.js","LICENSE"],"_shasum":"d5478a67c3ea0b634acca03e59b5236ad2be2373","gitHead":"e720b4dd9e8e9c3163c291c3e5a6d08db57b3f34","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"onury","email":"onur@cutepilot.com"},"repository":{"url":"git+https://github.com/onury/perfy.git","type":"git"},"_npmVersion":"2.14.4","description":"A simple, light-weight NodeJS utility for measuring code execution in high-resolution real times.","directories":{},"_nodeVersion":"4.1.1","devDependencies":{"grunt":"^0.4.5","grunt-jasmine-nodejs":"^1.4.3"}},"1.1.2":{"name":"perfy","version":"1.1.2","keywords":["perfy","perf","performance","measure","execution","time","benchmark","elapsed"],"author":{"name":"Onur Yıldırım","email":"onur@cutepilot.com"},"license":"MIT","_id":"perfy@1.1.2","maintainers":[{"name":"onury","email":"onur@cutepilot.com"}],"homepage":"https://github.com/onury/perfy#readme","bugs":{"url":"https://github.com/onury/perfy/issues"},"dist":{"shasum":"e4a01247bc5a6fc99f3df1da0fd3a2d2553b4323","tarball":"https://registry.npmjs.org/perfy/-/perfy-1.1.2.tgz","integrity":"sha512-ejBPDgkNKEAZi4ZWaBFpcZGGzq+hQcsaP5PIM4ieoDT3XNHHszlSrDYvpPpjcMNZmHB3rm04fhaMg09igo5DvA==","signatures":[{"sig":"MEUCIQDqmS6DVEMBJxeRJErQe1WBc+EzGSHpcxyYOoOXcOP67AIgESPAk7SAXLl4EkCUPAmVSfDN15lu1OGScmuYJeM94oA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","files":["index.js","LICENSE"],"_shasum":"e4a01247bc5a6fc99f3df1da0fd3a2d2553b4323","gitHead":"3877cd98d8c6b82ae706c8f31e10eead62375f63","scripts":{"lint":"eslint index.js test","test":"grunt"},"_npmUser":{"name":"onury","email":"onur@cutepilot.com"},"repository":{"url":"git+https://github.com/onury/perfy.git","type":"git"},"_npmVersion":"2.14.12","description":"A simple, light-weight NodeJS utility for measuring code execution in high-resolution real times.","directories":{},"_nodeVersion":"4.3.0","devDependencies":{"grunt":"^0.4.5","eslint":"^2.4.0","grunt-jasmine-nodejs":"^1.4.3"},"_npmOperationalInternal":{"tmp":"tmp/perfy-1.1.2.tgz_1458686408094_0.905047913081944","host":"packages-12-west.internal.npmjs.com"}},"1.1.5":{"name":"perfy","version":"1.1.5","keywords":["perfy","perf","performance","measure","execution","time","benchmark","profile","elapsed"],"author":{"name":"Onur Yıldırım","email":"onur@cutepilot.com"},"license":"MIT","_id":"perfy@1.1.5","maintainers":[{"name":"onury","email":"onur@cutepilot.com"}],"homepage":"https://github.com/onury/perfy#readme","bugs":{"url":"https://github.com/onury/perfy/issues"},"dist":{"shasum":"0d629f870a34a3eb1866d3db485d2b3faef29e4b","tarball":"https://registry.npmjs.org/perfy/-/perfy-1.1.5.tgz","fileCount":4,"integrity":"sha512-/ieVBpMaPTJf83YTUl2TImsSwMEJ23qGP2w27pE6aX+NrB/ZRGqOnQZpl7J719yFwd+ebDiHguPNFeMSamyK7w==","signatures":[{"sig":"MEUCIQD9kRlFZWRLnVEFuWuZOABd29yfo2YfOf8h0oEihjggHQIgFmXezzCwqsQUp/ivKxWMZbmRbZ/yBxCjPzkBE2XnmVw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14762,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbZF8jCRA9TVsSAnZWagAADGEP/iy0i3eCN/lMNTePvYrq\nDUs2QMn/Jm2MZssIv0fQspTL/j4QwahJPbBQV6g+cnQS8UPdM6gQFsSauttW\nvLkjdB09pmKXRFeq4ByfBQiF/95gbOvXwlpftewS95bujcvjzNHPiLGImROg\nVdwmmRKmePoj+vJvLi3l8GbRGnVgFL5vwLvsJT/T/78o2QjYXoK+PF0LDnlR\nfwjSRZi8630bZ/xs1CMKk6J+8siw1VTXU5xcWqYqqGBqIDC0uslWV7LeOsH/\n0G/pcR/SFDjR3kqqNuAdw94fwfx6IP3444DIIsDV2/0jOgUhQd6r5CCQR2rh\nbXyCYKaZ97lc5nAEGiJq+0znJWL0YFV602A2DNNGTQokqgz9vYiyDuN/K6RK\nRBxKwy2WsvD3uluZbm36yoIMpgb1ZThmehrp5PTLJ+D4aSFDkLe2ENcDd7TX\nOX+dZtySwi7SCd4eXIe8u/RxTBVDBurJThWYr8MrUQXnDshv3DH6UlVSy4A3\n95pAXh0tDmHz4U1tyKiPghXOHM5re/egZkJZsCEcDbmTlJcuRmVRZn0Sr4wt\nrPmndrCC8O8/Qtsc4vjFAjibsYJHsy6NIG8e+N/9mfcg3/4IDB9qPhxIlush\n1NKjlv//4WwasrpdQSbR0S0hMQicVd9WureY3vtzq9Tdb3OkJ5JQCarafkIc\nxfqN\r\n=U/0n\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","files":["index.js","LICENSE"],"gitHead":"c02d345c9bf25e73ca254a27a47117b24cb5fe3a","scripts":{"lint":"eslint index.js test","test":"node test"},"_npmUser":{"name":"onury","email":"onur@cutepilot.com"},"repository":{"url":"git+https://github.com/onury/perfy.git","type":"git"},"_npmVersion":"6.2.0","description":"A simple, light-weight NodeJS utility for measuring code execution in high-resolution real times.","directories":{},"_nodeVersion":"8.9.3","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^5.2.0","jasmine":"^3.1.0","jasmine-console-reporter":"^3.0.2"},"_npmOperationalInternal":{"tmp":"tmp/perfy_1.1.5_1533304610565_0.1821165055690963","host":"s3://npm-registry-packages"}},"2.0.0":{"name":"perfy","version":"2.0.0","keywords":["perfy","perf","performance","measure","execution","time","timer","high-resolution","hrtime","benchmark","profile","elapsed"],"author":{"name":"Onur Yıldırım","email":"onur@cutepilot.com"},"license":"MIT","_id":"perfy@2.0.0","maintainers":[{"name":"onury","email":"onur@cutepilot.com"}],"homepage":"https://github.com/onury/perfy#readme","bugs":{"url":"https://github.com/onury/perfy/issues"},"dist":{"shasum":"ce0c855a963ebdfa9ba8082181a05f1042b9c166","tarball":"https://registry.npmjs.org/perfy/-/perfy-2.0.0.tgz","fileCount":31,"integrity":"sha512-DfmZtiJcws9SIIN3q4J/MzhmXsBuvUm3ROgQqQXsY+gE4mL9It/KmKrHez31+nwOy7OxdN2K4PrC0ph32svneQ==","signatures":[{"sig":"MEYCIQDmGXXqm6X0s1LwjaUZUzIq4ozkFKNSV0qWejicDcQ1TQIhAOmq7ppuC/Sbz99pEw+I8yoZy79qZyhU7qxE3YZMIwQU","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":42300},"main":"./lib/index.js","type":"module","types":"./lib/index.d.ts","module":"./lib/index.js","engines":{"node":">=22"},"exports":{".":{"types":"./lib/index.d.ts","default":"./lib/index.js"},"./package.json":"./package.json"},"gitHead":"833aa0d859a50569acb1f9966765f25564f4664c","scripts":{"lint":"biome check src test","test":"vitest run","build":"tsc -p tsconfig.build.json","cover":"vitest run --coverage","format":"biome check --write src test","pretest":"npm run lint && npm run typecheck","mutation":"stryker run","typecheck":"tsc --noEmit -p tsconfig.json","prepublishOnly":"npm run build"},"_npmUser":{"name":"onury","email":"onur@cutepilot.com"},"repository":{"url":"git+https://github.com/onury/perfy.git","type":"git"},"_npmVersion":"10.8.2","description":"A tiny, zero-dependency utility for measuring code execution time in high-resolution real time. Works in Node.js, browsers, Deno and Bun.","directories":{},"sideEffects":false,"_nodeVersion":"20.20.2","_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.10","typescript":"^6.0.3","@types/node":"^26.1.1","tsconfig-oy":"^2.0.1","@biomejs/biome":"^2.5.5","biome-config-oy":"^1.1.0","@stryker-mutator/core":"^9.6.1","@vitest/coverage-istanbul":"^4.1.10","@stryker-mutator/vitest-runner":"^9.6.1"},"_npmOperationalInternal":{"tmp":"tmp/perfy_2.0.0_1784766459590_0.035500206874433005","host":"s3://npm-registry-packages-npm-production"}},"2.1.0":{"name":"perfy","version":"2.1.0","description":"A tiny, zero-dependency utility for measuring code execution time in high-resolution real time. Works in Node.js, browsers, Deno and Bun.","author":{"name":"Onur Yıldırım","email":"onur@cutepilot.com"},"license":"MIT","type":"module","main":"./lib/index.js","module":"./lib/index.js","types":"./lib/index.d.ts","sideEffects":false,"exports":{".":{"types":"./lib/index.d.ts","default":"./lib/index.js"},"./package.json":"./package.json"},"engines":{"node":">=22"},"scripts":{"lint":"biome check src test","format":"biome check --write src test","build":"tsc -p tsconfig.build.json","typecheck":"tsc --noEmit -p tsconfig.json","pretest":"npm run lint && npm run typecheck","test":"vitest run","cover":"vitest run --coverage","mutation":"stryker run","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/onury/perfy.git"},"bugs":{"url":"https://github.com/onury/perfy/issues"},"homepage":"https://github.com/onury/perfy#readme","keywords":["perfy","perf","performance","measure","execution","time","timer","high-resolution","hrtime","benchmark","profile","elapsed"],"devDependencies":{"@biomejs/biome":"^2.5.5","@stryker-mutator/core":"^9.6.1","@stryker-mutator/vitest-runner":"^9.6.1","@types/node":"^26.1.1","@vitest/coverage-istanbul":"^4.1.10","biome-config-oy":"^1.1.0","tsconfig-oy":"^2.0.1","typescript":"^6.0.3","vitest":"^4.1.10"},"_id":"perfy@2.1.0","gitHead":"6b2da2ec027448f53eb697a717fbd821f250a413","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-ufBkhMxLLX3u1Ui0+qt6xftwlX/0DmiC+UmGGeILk0FMH5F4pcF3TsmjSwMCCal6fDe86xfxShUIlNKpRcbwSg==","shasum":"396f7f9cb26836ad0cf1ae2e66d63b3820b9b8aa","tarball":"https://registry.npmjs.org/perfy/-/perfy-2.1.0.tgz","fileCount":31,"unpackedSize":50580,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHfVpZDLzFbDpjq8lCspFe0oHUwUhXqF3F971h49wLCtAiEA3dHxqS2qosV9vuyNHWvtWanGB1SEkufZYlhByu1DEy0="}]},"_npmUser":{"name":"onury","email":"onur@cutepilot.com"},"directories":{},"maintainers":[{"name":"onury","email":"onur@cutepilot.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/perfy_2.1.0_1784767886042_0.21397031134380384"},"_hasShrinkwrap":false}},"time":{"created":"2015-10-12T00:59:04.246Z","modified":"2026-07-23T00:51:26.341Z","1.0.0":"2015-10-12T00:59:04.246Z","1.0.1":"2015-10-12T01:23:39.389Z","1.1.0":"2015-10-16T14:41:00.820Z","1.1.2":"2016-03-22T22:40:10.452Z","1.1.5":"2018-08-03T13:56:50.654Z","2.0.0":"2026-07-23T00:27:39.756Z","2.1.0":"2026-07-23T00:51:26.182Z"},"bugs":{"url":"https://github.com/onury/perfy/issues"},"author":{"name":"Onur Yıldırım","email":"onur@cutepilot.com"},"license":"MIT","homepage":"https://github.com/onury/perfy#readme","keywords":["perfy","perf","performance","measure","execution","time","timer","high-resolution","hrtime","benchmark","profile","elapsed"],"repository":{"type":"git","url":"git+https://github.com/onury/perfy.git"},"description":"A tiny, zero-dependency utility for measuring code execution time in high-resolution real time. Works in Node.js, browsers, Deno and Bun.","maintainers":[{"name":"onury","email":"onur@cutepilot.com"}],"readme":"# perfy\n\n<p align=\"center\">\n  <a href=\"https://github.com/onury/perfy/actions/workflows/ci.yml\"><img src=\"https://github.com/onury/perfy/actions/workflows/ci.yml/badge.svg\" alt=\"build\" /></a>\n  <a href=\"#tests--quality\"><img src=\"https://img.shields.io/badge/coverage-100%25-2BB150?logo=vitest&logoColor=%23FDC72B&style=flat\" alt=\"coverage\" /></a>\n  <a href=\"https://stryker-mutator.io/docs/\"><img src=\"https://img.shields.io/badge/mutation-100%25-2BB150?style=flat\" alt=\"mutation score\" /></a>\n  <a href=\"https://www.npmjs.com/package/perfy\"><img src=\"https://img.shields.io/npm/v/perfy.svg?style=flat&label=&color=%23C6234B&logo=npm\" alt=\"version\" /></a>\n  <a href=\"https://www.npmjs.com/package/perfy\"><img src=\"https://img.shields.io/npm/dm/perfy.svg?style=flat&color=2BB150&label=downloads\" alt=\"downloads\" /></a>\n  <a href=\"#\"><img src=\"https://img.shields.io/badge/dependencies-0-2BB150?style=flat\" alt=\"zero dependencies\" /></a>\n  <a href=\"https://gist.github.com/onury/d3f3d765d7db2e8b2d050d14315f2ac7\"><img src=\"https://img.shields.io/badge/ESM-F7DF1E?style=flat\" alt=\"ESM\" /></a>\n  <a href=\"https://www.typescriptlang.org/\"><img src=\"https://img.shields.io/badge/TS-3260C7?style=flat\" alt=\"TS\" /></a>\n  <a href=\"https://github.com/onury/perfy/blob/master/LICENSE\"><img src=\"https://img.shields.io/npm/l/perfy.svg?style=flat&color=blue\" alt=\"license\" /></a>\n</p>\n\n> This module is **ESM** 🔆. Please [**read this**](https://gist.github.com/onury/d3f3d765d7db2e8b2d050d14315f2ac7).\n\nA tiny, **zero-dependency** utility for measuring code execution time in **high-resolution real time** — named timers, one-shot `exec()` wrappers, and a rich elapsed-time result. Runs in **Node.js, browsers, Deno and Bun**.\n\n```ts\nimport { perfy } from 'perfy';\n\nperfy.start('loop');\n// ...heavy work...\nconsole.log(perfy.end('loop').time); // -> 1.235 (sec.)\n```\n\n> [!NOTE]\n> Perfy picks the **most precise clock available**: `process.hrtime.bigint()` on Node.js (exact integer nanoseconds), falling back to `performance.now()` elsewhere. The elapsed time is computed with integer-nanosecond math, so it never accumulates floating-point drift. Wall-clock `startTime` / `endTime` stamps come from `Date.now()`.\n\n## Installation\n\n```sh\nnpm install perfy\n```\n\n## Usage\n\nCall `perfy.start('name')` to create a timer and mark its start, then `perfy.end('name')` to get the elapsed-time [result](#the-result-object). By default the instance is destroyed once ended.\n\n```ts\nimport { perfy } from 'perfy';\n\nperfy.start('loop-stuff');\n// ...some heavy stuff here...\nconst result = perfy.end('loop-stuff');\nconsole.log(result.time); // -> 1.459 (sec.)\n```\n\n...or wrap the work in `exec()` and let Perfy time it for you:\n\n```ts\nperfy.exec('async-stuff', (done) => {\n  // ...some heavy async stuff here...\n  const result = done();\n  console.log(result.time); // -> 1.459 (sec.)\n});\n```\n\nThe exported `perfy` is a shared singleton — the simplest way to use the library. When you want an **isolated registry** (or a custom clock, e.g. in tests), construct your own:\n\n```ts\nimport { Perfy } from 'perfy';\n\nconst perfy = new Perfy();\n```\n\n## Exports\n\nEverything is a **named** export (there is no default export):\n\n```ts\nimport {\n  perfy,              // shared Perfy singleton — the simplest entry point\n  Perfy,              // class — construct an isolated registry: new Perfy(clock?)\n  PerfyItem,          // a single timing instance (advanced / typing)\n  PerfyError,         // Error subclass thrown on failure, with a `.code`\n  createNanoClock,    // build a NanoClock from given host objects\n  defaultNanoClock    // the NanoClock selected for this environment\n} from 'perfy';\n\nimport type {\n  IPerfyResult,       // the elapsed-time result object\n  IPerfyMeasurement,  // the disposable handle returned by measure()\n  NanoClock,          // () => bigint monotonic nanosecond clock\n  PerfyErrorCode,     // 'NAME_REQUIRED' | 'NO_INSTANCE' | 'NOT_STARTED' | 'INVALID_CALLBACK' | 'NO_CLOCK'\n  DoneFn,             // the `done` callback passed to a callback-style exec task\n  SyncTask,\n  AsyncTask,\n  PromiseTask,\n  PerfyTask           // SyncTask | AsyncTask | PromiseTask\n} from 'perfy';\n```\n\n## API\n\nEvery method that takes a `name` throws a [`PerfyError`](#errors) with code `NAME_REQUIRED` when it is empty.\n\n| Method | Returns | Description |\n| ------ | ------- | ----------- |\n| `start(name, autoDestroy?)` | `Perfy` | Creates a new instance under `name` and marks its start time. Reusing a name overwrites it. `autoDestroy` (default `true`) drops the instance when `end()` is called. Chainable. |\n| `end(name)` | [`IPerfyResult`](#the-result-object) | Ends the instance and returns the elapsed-time result. If `autoDestroy` was left on, the instance is removed right after. Calling `end()` again on a kept instance returns the same cached result. Throws `NO_INSTANCE` if no such instance exists. |\n| `lap(name)` | [`IPerfyResult`](#the-result-object) | Records a **split** — the elapsed time since the previous lap (or since `start` for the first) — then advances the lap marker. The instance keeps running; `end()` still reports the total from `start`. Throws `NO_INSTANCE` if no such instance exists. |\n| `measure(name, onEnd?)` | [`IPerfyMeasurement`](#the-result-object) | Starts a kept instance and returns a **disposable** whose `[Symbol.dispose]` ends it — so a `using` declaration times its enclosing scope. The result stays retrievable via `result(name)`; pass `onEnd` to receive it immediately. Disposing twice is a no-op. |\n| `exec([name,] fn)` | [`IPerfyResult`](#the-result-object) \\| `Promise<IPerfyResult>` \\| `Perfy` | Times the execution of `fn`, picking the mode from the task itself. **Synchronous** (`fn` returns a non-thenable) → ended automatically, result returned. **Promise-returning** (`fn` returns a promise) → awaited, resolves to the result (a rejection is propagated). **Callback-style** (`fn(done)` declares a `done` argument) → must call `done()` to end; returns the `Perfy` instance immediately. Pass a `name` to keep the instance. Throws `INVALID_CALLBACK` if `fn` is not a function. |\n| `result(name)` | [`IPerfyResult`](#the-result-object) \\| `null` | The stored result of a kept, ended instance — or `null` if it does not exist or has not ended yet. |\n| `exists(name)` | `boolean` | Whether an instance currently exists under `name`. `false` once an auto-destroyed instance has ended. |\n| `names()` | `string[]` | Names of all existing instances. |\n| `count()` | `number` | Number of existing instances. |\n| `destroy(name)` | `Perfy` | Destroys the instance under `name`, if any. Chainable. |\n| `destroyAll()` | `Perfy` | Destroys all existing instances. Chainable. |\n\n### The Result Object\n\n`end()` (and `exec()` / `result()`) return an `IPerfyResult` — every field is a plain `number`/`string`, so the object is safe to `JSON.stringify`.\n\n| Property | Type | Description |\n| -------- | ---- | ----------- |\n| `name` | `string` | Name of the instance (`''` for an unnamed `exec()`). |\n| `time` | `number` | Full elapsed time in **seconds** (float, 3 decimals). e.g. `1.235` |\n| `milliseconds` | `number` | Full elapsed time in **milliseconds** (float). e.g. `1235.125` |\n| `nanoseconds` | `number` | Full elapsed time in **nanoseconds**. e.g. `1235125283` |\n| `summary` | `string` | Human-readable shorthand. e.g. `'loop: 1.235 sec.'` |\n| `startTime` | `number` | UTC wall-clock time (ms) at start, via `Date.now()`. e.g. `1533302465251` |\n| `endTime` | `number` | UTC wall-clock time (ms) at end, via `Date.now()`. e.g. `1533302466486` |\n\n## Examples\n\n**Reading the elapsed time in different units:**\n\n```ts\nperfy.start('metric');\n// ...\nconst r = perfy.end('metric');\nconsole.log(`${r.time} sec.`);          // -> 1.234 sec.\nconsole.log(`${r.milliseconds} ms.`);   // -> 1234.567 ms.\nconsole.log(r.summary);                 // -> metric: 1.234 sec.\n```\n\n**Auto-destroy (default):**\n\n```ts\nperfy.start('metric').count();  // -> 1\nperfy.end('metric');\nperfy.count();                  // -> 0 (destroyed on end)\n```\n\n**Keep the instance (disable `autoDestroy`):**\n\n```ts\nperfy.start('metric', false);\nperfy.end('metric').time;   // -> 0.123\nperfy.exists('metric');     // -> true (kept)\nperfy.result('metric');     // -> the same result object\n```\n\n**Timing a synchronous function** — `exec()` returns the result directly:\n\n```ts\nconst result = perfy.exec(() => {\n  // sync work\n});\nconsole.log(result.time);\n```\n\n**Timing a promise / `async` function** — `exec` awaits it and resolves to the result:\n\n```ts\nconst result = await perfy.exec('fetch', async () => {\n  await fetch('https://example.com');\n});\nconsole.log(result.time);\n```\n\n**Timing a callback-style async function** — call `done()` when finished:\n\n```ts\nperfy.exec((done) => {\n  setTimeout(() => {\n    const result = done();\n    console.log(result.time);\n  }, 1000);\n});\n```\n\n**Laps** — record splits within one running timer:\n\n```ts\nperfy.start('pipeline');\nloadData();\nconsole.log('load:', perfy.lap('pipeline').time);\ntransform();\nconsole.log('transform:', perfy.lap('pipeline').time);\nconsole.log('total:', perfy.end('pipeline').time);\n```\n\n**Scope timing with `using`** — the timer ends automatically when the block exits:\n\n```ts\n{\n  using _ = perfy.measure('block', (r) => console.log(r.time));\n  // ...work...\n} // ended here\n```\n\n**Named `exec()`** keeps the instance for later retrieval:\n\n```ts\nperfy.exec('async-op', (done) => {\n  done();\n});\nperfy.exists('async-op');  // -> true\nperfy.result('async-op');  // -> the result object\n```\n\n**Destroy everything:**\n\n```ts\nperfy.destroyAll().count(); // -> 0\n```\n\n### Errors\n\nEvery failure throws a `PerfyError` — an `Error` subclass carrying a stable, machine-readable `code` (`NAME_REQUIRED`, `NO_INSTANCE`, `NOT_STARTED`, `INVALID_CALLBACK`, `NO_CLOCK`):\n\n```ts\nimport { perfy, PerfyError } from 'perfy';\n\ntry {\n  perfy.end('never-started');\n} catch (err) {\n  if (err instanceof PerfyError && err.code === 'NO_INSTANCE') {\n    // handle it\n  }\n}\n```\n\n## Tests & Quality\n\n100% test coverage (statements, branches, functions, lines) and a **100% [Stryker](https://stryker-mutator.io) mutation score**, run across Node.js 22 & 24 in CI.\n\n## Changelog\n\nSee [**CHANGELOG.md**](CHANGELOG.md). **v2 is a breaking release** (ESM-only, universal clock, streamlined result object) — the migration notes live there.\n\n## Related\n\n- [**tasktimer**](https://github.com/onury/tasktimer) — An accurate timer utility for running periodic tasks on the given interval ticks or dates.\n\n## License\n\n© 2026, Onur Yıldırım. [**MIT**](LICENSE) License.\n","readmeFilename":"README.md","users":{"emjimadhu":true,"flumpus-dev":true}}