{"id":15691712,"url":"https://github.com/victornpb/micro-fps","last_synced_at":"2025-06-15T20:37:35.914Z","repository":{"id":12222784,"uuid":"14831378","full_name":"victornpb/micro-fps","owner":"victornpb","description":"A super lightweight fps meter, with near zero overhead for mission critical loops and animations","archived":false,"fork":false,"pushed_at":"2022-12-06T16:58:45.000Z","size":3239,"stargazers_count":8,"open_issues_count":18,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-14T19:03:00.906Z","etag":null,"topics":["benchmark","fps","frames","javascript","timing"],"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/victornpb.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2013-12-01T00:57:01.000Z","updated_at":"2021-08-22T23:19:23.000Z","dependencies_parsed_at":"2023-01-13T16:50:27.343Z","dependency_job_id":null,"html_url":"https://github.com/victornpb/micro-fps","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/victornpb%2Fmicro-fps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victornpb%2Fmicro-fps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victornpb%2Fmicro-fps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victornpb%2Fmicro-fps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/victornpb","download_url":"https://codeload.github.com/victornpb/micro-fps/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252899234,"owners_count":21821756,"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":["benchmark","fps","frames","javascript","timing"],"created_at":"2024-10-03T18:23:35.023Z","updated_at":"2025-05-07T14:47:50.341Z","avatar_url":"https://github.com/victornpb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# micro-fps\n\n![Node](https://img.shields.io/node/v/micro-fps.svg?style=flat-square)\n[![NPM](https://img.shields.io/npm/v/micro-fps.svg?style=flat-square)](https://www.npmjs.com/package/micro-fps)\n[![Travis](https://img.shields.io/travis/victornpb/micro-fps/master.svg?style=flat-square)](https://travis-ci.org/victornpb/micro-fps)\n[![David](https://img.shields.io/david/victornpb/micro-fps.svg?style=flat-square)](https://david-dm.org/victornpb/micro-fps)\n[![Coverage Status](https://img.shields.io/coveralls/victornpb/micro-fps.svg?style=flat-square)](https://coveralls.io/github/victornpb/micro-fps)\n[![NPM](https://img.shields.io/npm/dt/micro-fps.svg?style=flat-square)](https://www.npmjs.com/package/micro-fps)\n\n\u003e A super lightweight fps meter, with near zero overhead\n\n*createFpsMeter* is a function factory, it returns a new meter.  \nBut why not a class? Last time I checked, accessing instance properties was slower than accessing variables on a near closure.\n\n\n### Installation\n\n[Yarn](https://github.com/yarnpkg/yarn)\n\n\tyarn add micro-fps\n\nNPM\n\n\tnpm install micro-fps\n  \nIf you don't use a package manager, you can [access `micro-fps` via unpkg (CDN)](https://unpkg.com/micro-fps/), download the source, or point your package manager to the url.\n\n### Usage\n\nJS fiddle Example: https://jsfiddle.net/Victornpb/g8pra2a6/\n\n```js\nimport microFps from 'micro-fps';\n\nfunction updatedUIcallback(stats){\n  // Update your UI\n  fps_div.innerHTML = stats.fps.toFixed(2) + \" fps\"; \n  console.log(stats);\n}\n\nconst REFRESH_RATE = 2; // update you HUD twice a second (it can be a fraction e.g.: 0.5 will compute every 2 seconds).\nconst fpsTick = microFps(updatedUIcallback, REFRESH_RATE); // create a tick function\n\n```\n    \nThen call the returned function on every frame of your loop    \n```js    \n// game/animation loop\nsetInterval(function loop(){\n    fpsTick(); // call on every frame\n     \n    // Your game/animation logic\n\n}, 1000/60);\n```    \n \nCallback stats object\n\n| property | type    | description                                           |\n|----------|---------|-------------------------------------------------------|\n| fps      | float   | The calculated frames per second                      |\n| jitter   | float   | The absolute difference since the last calculated fps |\n| elapsed  | float   | Milliseconds ellapsed since the last computation      |\n| frames   | integer | Number of frames since the last computation           |\n| trigger  | float   | Next computation will happen at this amount of frames |\n\n\n\n### Examples\n\nSee [`example`](example/script.js) folder or the [runkit](https://runkit.com/victornpb/micro-fps) example.\n\n### Builds\n\n`micro-fps` is compiled as a collection of [CommonJS](http://webpack.github.io/docs/commonjs.html) modules \u0026 [ES2015 modules](http://www.2ality.com/2014/0\n  -9/es6-modules-final.html) for bundlers that support the `jsnext:main` or `module` field in package.json (Rollup, Webpack 2)\n\nThe `micro-fps` package includes precompiled production and development [UMD](https://github.com/umdjs/umd) builds in the [`dist/umd` folder](https://unpkg.com/micro-fps/dist/umd/). They can be used directly without a bundler and are thus compatible with many popular JavaScript module loaders and environments. You can drop a UMD build as a [`\u003cscript\u003e` tag](https://unpkg.com/micro-fps) on your page. The UMD builds make `micro-fps` available as a `window.microFps` global variable.\n\n### License\n\nThe code is available under the [MIT](LICENSE) license.\n\n### Contributing\n\nWe are open to contributions, see [CONTRIBUTING.md](CONTRIBUTING.md) for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvictornpb%2Fmicro-fps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvictornpb%2Fmicro-fps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvictornpb%2Fmicro-fps/lists"}