{"id":15722609,"url":"https://github.com/britzl/defold-metrics","last_synced_at":"2025-05-08T16:56:22.555Z","repository":{"id":41814932,"uuid":"133767590","full_name":"britzl/defold-metrics","owner":"britzl","description":"Calculate and display performance metrics in Defold games","archived":false,"fork":false,"pushed_at":"2022-04-28T11:20:45.000Z","size":21,"stargazers_count":37,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-08T16:56:03.920Z","etag":null,"topics":["defold","defold-library"],"latest_commit_sha":null,"homepage":"","language":"Lua","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/britzl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-17T06:16:31.000Z","updated_at":"2025-04-29T07:07:46.000Z","dependencies_parsed_at":"2022-07-22T13:33:11.580Z","dependency_job_id":null,"html_url":"https://github.com/britzl/defold-metrics","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/britzl%2Fdefold-metrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/britzl%2Fdefold-metrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/britzl%2Fdefold-metrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/britzl%2Fdefold-metrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/britzl","download_url":"https://codeload.github.com/britzl/defold-metrics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253112074,"owners_count":21856070,"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":["defold","defold-library"],"created_at":"2024-10-03T22:08:38.774Z","updated_at":"2025-05-08T16:56:22.534Z","avatar_url":"https://github.com/britzl.png","language":"Lua","funding_links":[],"categories":["Libraries"],"sub_categories":["Programming Language"],"readme":"# Defold Metrics\nCalculate and display performance metrics in Defold games.\n\n\n# Installation\nYou can use Defold Metrics in your own project by adding this project as a [Defold library dependency](http://www.defold.com/manuals/libraries/). Open your game.project file and in the dependencies field under project add:\n\n\thttps://github.com/britzl/defold-metrics/archive/master.zip\n\nOr point to the ZIP file of a [specific release](https://github.com/britzl/defold-metrics/releases).\n\n\n# Usage\n* In your game.project settings, go to Dependencies,and add https://github.com/britzl/defold-metrics/archive/master.zip.\n* In the outline in your scene, right-click and \"Add Game Object File\" and choose \"/metrics/fps.go\"\n* Change the position on the game object to ex 10, 20, 0 to make it visible.\n* If you also want to use the Lua memory counter, add the \"/metrics/mem.go\" in the same way, but on position 10, 40, 0.\n\nDemo: https://britzl.github.io/Metrics/\n\n\n## FPS\nThe FPS counter uses socket.gettime() to get an accurate timestamp and calculates an average FPS based on a sequence of samples. The FPS counter can be used in several ways:\n\n1. Using fps.go() - Draw FPS counter at game object world position using draw text\n2. Using fps.script - Draw FPS counter at game object world position using draw text\n3. Using fps.lua - Draw FPS counter at specified position or get current FPS\n\n\n### fps.create(samples, format, position, color)\nCreate an instance of the FPS counter\n\n**PARAMETERS**\n* `samples` (number) - Optional sample count. This is the number of samples required before the module will calculate FPS. Defaults to 60.\n* `format` (string) - Optional format to draw FPS in. Defaults to \"FPS %.2f\"\n* `position` (string) - Optional position to draw FPS at. Defaults to v3(10, 20, 0)\n* `color` (string) - Optional color to use when drawing FPS text. Defaults to v4(0,0,1,1)\n\n**RETURNS**\n* `instance` (table) - An FPS counter instance\n\n\n### fps.update()\nCall this once per frame. Once enough samples have been collected it is possible to call fps() to get the current FPS.\n\n\n### fps.fps()\nGet the current FPS, based on collected samples.\n\n**RETURNS**\n* `fps` (number) - The calculated FPS\n\n\n### fps.draw()\nDraw fps count text using `draw_debug_text`.\n\n\n\n## Memory\nThe memory counter uses `collectgarbage(\"count\")` to get the amount of Lua memory used. The memory counter can be used in several ways:\n\n1. Using mem.go() - Draw memory usage at game object world position using draw text\n2. Using mem.script - Draw memory usage at game object world position using draw text\n3. Using mem.lua - Draw memory usage at specified position or get current memory usage\n\n\n### mem.create(format, position, color)\nCreate an instance of the memory counter\n\n**PARAMETERS**\n* `format` (string) - Optional format to draw memory usage in. Defaults to \"MEM %dkb\"\n* `position` (string) - Optional position to draw memory usage at. Defaults to v3(10, 20, 0)\n* `color` (string) - Optional color to use when drawing memory usage text. Defaults to v4(0,0,1,1)\n\n**RETURNS**\n* `instance` (table) - A memory counter counter instance\n\n\n### mem.update()\nCall this to get a new memory usage reading.\n\n\n### mem.mem()\nGet the current memory usage, in kilobytes.\n\n**RETURNS**\n* `mem` (number) - The Lua memory usage\n\n\n### mem.draw()\nDraw memory usage text using `draw_debug_text`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbritzl%2Fdefold-metrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbritzl%2Fdefold-metrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbritzl%2Fdefold-metrics/lists"}