{"id":23843694,"url":"https://github.com/ngduc/mstime","last_synced_at":"2025-09-07T19:32:04.129Z","repository":{"id":54739912,"uuid":"106523077","full_name":"ngduc/mstime","owner":"ngduc","description":"a lightweight module (2KB gzip) to measure \u0026 visualize code performance in millisecond (ms), run on Node \u0026 browser. No dependencies!","archived":false,"fork":false,"pushed_at":"2021-02-01T14:31:48.000Z","size":757,"stargazers_count":11,"open_issues_count":22,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-07T22:06:56.929Z","etag":null,"topics":["measurement","optimization","performance"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ngduc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-11T07:53:56.000Z","updated_at":"2021-11-08T13:05:33.000Z","dependencies_parsed_at":"2022-08-14T01:20:34.150Z","dependency_job_id":null,"html_url":"https://github.com/ngduc/mstime","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngduc%2Fmstime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngduc%2Fmstime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngduc%2Fmstime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngduc%2Fmstime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ngduc","download_url":"https://codeload.github.com/ngduc/mstime/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232250733,"owners_count":18494772,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["measurement","optimization","performance"],"created_at":"2025-01-02T19:50:45.427Z","updated_at":"2025-01-02T19:50:45.939Z","avatar_url":"https://github.com/ngduc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mstime\n\n[![NPM version](https://img.shields.io/npm/v/mstime.svg?style=flat-square)](https://npmjs.org/package/mstime)\n[![Build Status](https://img.shields.io/travis/ngduc/mstime/master.svg?style=flat-square)](https://travis-ci.org/ngduc/mstime) [![Coverage Status](https://img.shields.io/codecov/c/github/ngduc/mstime/master.svg?style=flat-square)](https://codecov.io/gh/ngduc/mstime/branch/master)\n[![NPM](https://img.shields.io/npm/dt/mstime.svg?style=flat-square)](https://www.npmjs.com/package/mstime)\n\na lightweight module (2KB gzip) to measure \u0026 visualize code performance in millisecond (ms), run on Node \u0026 browser. No dependencies!\n\n_mstime_ uses [performance.now Web API](https://developers.google.com/web/updates/2012/08/When-milliseconds-are-not-enough-performance-now) (high resolution timer) to measure the difference between start \u0026 end points.\n\n_mstime_ has an easy **Plugin System** which lets you write simple (yet powerful) plugins to process/visualize data in different ways.\n\n## Example / Demo\n\n* Example in Node: https://runkit.com/ngduc/mstime\n* Example in Browser: https://rawgit.com/ngduc/mstime/master/docs/demo/index.html\n* Example in Codesandbox: https://codesandbox.io/s/jlnp3owm2y\n\n[![Demo Screenshot](/docs/screenshot-01.png)](https://rawgit.com/ngduc/mstime/master/docs/demo/index.html)\n\n## Install\n\n    $ npm install --save mstime\n\n## Usage\n\n```js\nimport mstime from \"mstime\";\n\nmstime.start(\"codeblock1\");\nprocessData(); // your function\nconst result = mstime.end(\"codeblock1\");\n```\n\n`result` is a JSON object: (all values are in milliseconds)\n\n```\n{\n  entries: [\n    { start: 41991120.53, end: 41991133.04, diff: 12.50 }\n  ]\n  last: 12.50,\n  sum: 12.50,\n  avg: 12.50\n}\n```\n\nAvailable builds (dist): CommonJS, ES, UMD.\n\n## Config\n\n```js\nmstime.config({\n  decimalDigits: 4, // default: 2\n  consoleTime: true // use console.time \u0026 console.timeEnd, default: false\n});\n```\n\n## Plugins\n\nPlugins offer more useful abilities on the captured data.\n\nA plugin is just a function that processes data and returns this structure:\n\n```js\nconst pluginExample = ({ config }) =\u003e ({\n  name: \"msplugin-example\",\n  run: (allData, timerData) =\u003e {\n    const output = \"do something useful here with allData \u0026 timerData...\";\n    return {\n      // property \u0026 value can be anything\n    };\n  }\n});\n```\n\n`run` function will get called on `mstime.end` and its result will be put in \"timerData.plugins\"\n\n### List of Plugins:\n```\n- msplugin-use-local-storage   use localStorage to store timer data. \n- msplugin-trim-mean           calculate for trimmed mean.\n- msplugin-chartist            plot data using Chartist.\n\n- msplugin-find-outliers       (In Progress: find outliers)\n- msplugin-post-to-api         (In Progress: post timer data to API)\n- msplugin-save-to-db          (In Progress: save timer data to DB)\n- (create your plugin \u0026 add it here...)\n```\n\n## Documentation\n\n- [Change Log](/CHANGELOG.md)\n\n## License\n\nMIT © [Duc Nguyen](https://github.com/ngduc)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngduc%2Fmstime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fngduc%2Fmstime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngduc%2Fmstime/lists"}