{"name":"marky","version":"1.3.0","description":"Performance timer based on performance.mark() and measure()","main":"lib/marky.cjs.js","jsnext:main":"lib/marky.es.js","module":"lib/marky.es.js","types":"marky.d.ts","scripts":{"clean":"rimraf lib dist && mkdirp lib dist","rollup-cjs":"rollup -c config/rollup.config.cjs.js && rollup -c config/rollup.config.browser.cjs.js","rollup-es":"rollup -c config/rollup.config.es.js && rollup -c config/rollup.config.browser.es.js","rollup-iife":"rollup -c config/rollup.config.iife.js","rollup":"npm-run-all --parallel rollup-cjs rollup-es rollup-iife","minify":"terser -mc < dist/marky.js > dist/marky.min.js","prepare":"npm run build","build":"npm-run-all clean rollup minify","test":"npm run rollup-cjs && mocha test/test.js","test-browser":"karma start --single-run","test-browser-debug":"karma start --browsers=Chrome --single-run=false","lint":"standard"},"keywords":["mark","measure","performance","user timing","timing","polyfill","stopwatch","timer"],"author":{"name":"Nolan Lawson","email":"nolan@nolanlawson.com"},"license":"Apache-2.0","devDependencies":{"@rollup/plugin-buble":"^0.21.3","@rollup/plugin-commonjs":"^21.0.1","@rollup/plugin-node-resolve":"^13.1.3","@rollup/plugin-replace":"^3.1.0","assert":"^2.0.0","karma":"^6.3.16","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.2","karma-mocha":"^2.0.1","karma-rollup-preprocessor":"^7.0.8","mkdirp":"^1.0.4","mocha":"^9.2.0","npm-run-all":"^4.1.5","rimraf":"^3.0.2","rollup":"^2.67.2","standard":"^16.0.4","terser":"^5.10.0"},"browser":{"./lib/marky.cjs.js":"./lib/marky.browser.cjs.js","./lib/marky.es.js":"./lib/marky.browser.es.js"},"standard":{"ignore":["lib","dist"]},"repository":{"type":"git","url":"git+https://github.com/nolanlawson/marky.git"},"bugs":{"url":"https://github.com/nolanlawson/marky/issues"},"homepage":"https://github.com/nolanlawson/marky#readme","volta":{"node":"16.15.1","yarn":"1.22.19"},"packageManager":"yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e","_id":"marky@1.3.0","gitHead":"9d4fdbb80ab49f86ae1a06db56fe179741718a19","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-ocnPZQLNpvbedwTy9kNrQEsknEfgvcLMvOtz3sFeWApDq1MXH1TqkCIx58xlpESsfwQOnuBO9beyQuNGzVvuhQ==","shasum":"422b63b0baf65022f02eda61a238eccdbbc14997","tarball":"http://registry-npm.ywwl.com/marky/download/marky-1.3.0.tgz","fileCount":10,"unpackedSize":35752,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGsJuBmmyoAzB+lr/o9R1SMeoiPMu4FgZWW97XGHEQLIAiAHGArd6NfpjcdJjTTYfpYNuESQxU4jl9tGZoO00PvqdA=="}],"size":9212,"noattachment":false,"key":"/marky/-/marky-1.3.0.tgz"},"_npmUser":{"name":"nolanlawson","email":"nolan@nolanlawson.com"},"directories":{},"maintainers":[{"name":"nolanlawson","email":"nolan@nolanlawson.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/marky_1.3.0_1744573508759_0.3619472984665044"},"_hasShrinkwrap":false,"readme":"marky\n======\n\nJavaScript timer based on `performance.mark()` and `performance.measure()`, providing [high-resolution\ntimings](https://developer.mozilla.org/en-US/docs/Web/API/User_Timing_API) as well as nice Dev Tools visualizations.\n\nFor browsers that don't support `performance.mark()`, it falls back to \n`performance.now()` or `Date.now()`. In Node, it uses `process.hrtime()`.\n\nQuick start\n----\n\nInstall via npm:\n\n    npm install marky\n\nOr as a script tag:\n\n```html\n<script src=\"https://unpkg.com/marky/dist/marky.min.js\"></script>\n```\n\nThen take some measurements:\n\n```js\nvar marky = require('marky');\n\nmarky.mark('expensive operation');\ndoExpensiveOperation();\nmarky.stop('expensive operation');\n```\n\nWhy?\n---\n\nThe [User Timing API](https://developer.mozilla.org/en-US/docs/Web/API/User_Timing_API) is [more performant](https://gist.github.com/paulirish/2fad3834e2617fb199bc12e17058dde4)\nthan `console.time()` and `console.timeEnd()`,\nand [more accurate](https://developer.mozilla.org/en-US/docs/Web/API/Performance/now) than `Date.now()`. Also, you get nice visualizations in Chrome Dev Tools:\n\n![Chrome Dev Tools screenshot](doc/chrome.png)\n\nAs well as Edge F12 Tools:\n\n![Edge F12 screenshot](doc/edge.png)\n\nThis is because `marky` adds standard\n[PerformanceEntries](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry) to the [Performance Timeline](https://developer.mozilla.org/en-US/docs/Web/API/Performance_Timeline). Tools like [WebPageTest](http://blog.patrickmeenan.com/2013/07/measuring-performance-of-user-experience.html) and [Windows Performance Analyzer](https://blogs.windows.com/msedgedev/2016/05/11/top-down-analysis-wpt/) also surface them, and you can even [send them to your analytics provider](https://github.com/googlecodelabs/performance-analytics).\n\nAPI\n---\n\n`marky.mark()` begins recording, and `marky.stop()` finishes recording:\n\n```js\nmarky.mark('releaseTheHounds');\nreleaseTheHounds();\nmarky.stop('releaseTheHounds');\n```\n\nYou can also do more complex scenarios:\n\n```js\nfunction setSail() {\n  marky.mark('setSail');\n  marky.mark('raiseTheAnchor');\n  raiseTheAnchor();\n  marky.stop('raiseTheAnchor');\n  marky.mark('unfurlTheSails');\n  unfurlTheSails();\n  marky.stop('unfurlTheSails');\n  marky.stop('setSail');\n}\n```\n\n`marky.stop()` also returns a `PerformanceEntry`:\n\n```js\nmarky.mark('manTheTorpedos');\nmanTheTorpedos();\nvar entry = marky.stop('manTheTorpedos');\n```\n\nThe entry will look something like:\n\n```json\n{\n  \"entryType\": \"measure\",\n  \"startTime\": 1974112,\n  \"duration\": 350,\n  \"name\": \"manTheTorpedos\"\n}\n```\n\nYou can get all entries using:\n\n```js\nvar entries = marky.getEntries();\n```\n\nThis provides a list of all measures ordered by `startTime`, e.g.:\n\n```json\n[\n  {\n    \"entryType\": \"measure\",\n    \"startTime\": 1974112,\n    \"duration\": 350,\n    \"name\": \"numberOne\"\n  },\n  {\n    \"entryType\": \"measure\",\n    \"startTime\": 1975108,\n    \"duration\": 300,\n    \"name\": \"numberTwo\"\n  },\n  {\n    \"entryType\": \"measure\",\n    \"startTime\": 1976127,\n    \"duration\": 250,\n    \"name\": \"numberThree\"\n  }\n]\n```\n\nYou can also clear the entries using `marky.clear():`\n\n```js\nmarky.clear()\n```\n\nAfter this, `marky.getEntries()` will return an empty list. (If the User Timing API is supported, this will delete all the `mark` and `measure` entries from the timeline.)\n\nBrowser support\n----\n\n`marky` has been tested in the following browsers/environments:\n\n* IE 9+\n* Safari 8+\n* iOS 8+\n* Android 4.4+\n* Chrome\n* Firefox\n* Edge\n* Node 4+\n\nPer [the spec](https://www.w3.org/TR/resource-timing-1/#extensions-performance-interface), browsers only need to hold a minimum\nof 150 entries in their Performance Timeline buffer. [In older versions of Firefox](https://bugzilla.mozilla.org/show_bug.cgi?id=1331135), the buffer\nis throttled to 150, which for `marky`\nmeans you can get a maximum of 50 entries from `marky.getEntries()` (because `marky` creates two marks and a measure).\n\nIf you need to get more than 50 entries from `marky.getEntries()`, you can do:\n\n```js\nif (typeof performance !== 'undefined' && performance.setResourceTimingBufferSize) {\n  performance.setResourceTimingBufferSize(10000); // or however many you need\n}\n```\n\nIn Node and [browsers that don't support the User Timing API](http://caniuse.com/#feat=user-timing),\n`marky` follows the behavior of Edge and Chrome, and does not limit the number of entries. `marky.stop()` and \n`marky.getEntries()` will return pseudo-`PerformanceEntry` objects.\n\nSee also\n---\n\n- [appmetrics.js](https://github.com/ebidel/appmetrics.js) – a library on top of `mark()`/`measure()` which reports to Google Analytics.\n\nCredits\n----\n\nThanks to [@toddreifsteck](https://github.com/toddreifsteck) for feedback on this project and clarifications on the User Timing API.\n","publish_time":1744573508934,"_cnpm_publish_time":1744573508934,"dist-tags":{"latest":"1.3.0"}}