All Projects → britzl → defold-metrics

britzl / defold-metrics

Licence: MIT license
Calculate and display performance metrics in Defold games

Programming Languages

lua
6591 projects
go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to defold-metrics

gooey
Defold GUI system
Stars: ✭ 99 (+330.43%)
Mutual labels:  defold, defold-library
jstodef
Library for sending messages from JavaScript to Defold (Lua)
Stars: ✭ 21 (-8.7%)
Mutual labels:  defold, defold-library
defold-richtext
Defold-RichText is a system to create styled text based on an HTML inspired markup language
Stars: ✭ 35 (+52.17%)
Mutual labels:  defold, defold-library
extension-admob
Defold native extension which provides access to AdMob functionality on Android and iOS
Stars: ✭ 31 (+34.78%)
Mutual labels:  defold, defold-library
DefVideoAds
UnityAds native extension for Defold engine.
Stars: ✭ 37 (+60.87%)
Mutual labels:  defold, defold-library
extension-gpgs
Defold native extension for Google Play Game Services
Stars: ✭ 19 (-17.39%)
Mutual labels:  defold, defold-library
defnet
Defold networking examples
Stars: ✭ 52 (+126.09%)
Mutual labels:  defold, defold-library
defold-sharing
Defold native extension to share data from a Defold application using native dialogs
Stars: ✭ 20 (-13.04%)
Mutual labels:  defold, defold-library
drawpixels
Defold engine native extension for drawing pixels into texture buffer.
Stars: ✭ 46 (+100%)
Mutual labels:  defold, defold-library
defpro
Defold Profiler interaction using Lua
Stars: ✭ 19 (-17.39%)
Mutual labels:  defold, defold-library
defold-playable-ads
Make playable ads with Defold! It's a project with Gulp tasks to bundle the Defold game into a single HTML file.
Stars: ✭ 15 (-34.78%)
Mutual labels:  defold, defold-library
defold-eva
Basic defold module for mobile games
Stars: ✭ 21 (-8.7%)
Mutual labels:  defold, defold-library
platypus
Defold platformer engine
Stars: ✭ 31 (+34.78%)
Mutual labels:  defold, defold-library
defold-input
Simplify input related operations such as gesture detection, input mapping and clicking/dragging game objects
Stars: ✭ 67 (+191.3%)
Mutual labels:  defold, defold-library
DAABBCC
Dynamic AABB Tree native extension with Branch and Bound Algorithm for Defold Engine
Stars: ✭ 42 (+82.61%)
Mutual labels:  defold, defold-library
extension-fbinstant
Facebook Instant Games extension for the Defold game engine
Stars: ✭ 39 (+69.57%)
Mutual labels:  defold, defold-library
defold-hyper-trails
Easy to use and customizable trail effect for the Defold game engine.
Stars: ✭ 33 (+43.48%)
Mutual labels:  defold, defold-library
defos
Extra native OS functions for games written using the Defold game engine
Stars: ✭ 64 (+178.26%)
Mutual labels:  defold, defold-library
nakama-defold
Defold client for Nakama server.
Stars: ✭ 58 (+152.17%)
Mutual labels:  defold
defold-deployer
Universal build && deploy script for Defold projects
Stars: ✭ 23 (+0%)
Mutual labels:  defold

Defold Metrics

Calculate and display performance metrics in Defold games.

Installation

You can use Defold Metrics in your own project by adding this project as a Defold library dependency. Open your game.project file and in the dependencies field under project add:

https://github.com/britzl/defold-metrics/archive/master.zip

Or point to the ZIP file of a specific release.

Usage

  • In your game.project settings, go to Dependencies,and add https://github.com/britzl/defold-metrics/archive/master.zip.
  • In the outline in your scene, right-click and "Add Game Object File" and choose "/metrics/fps.go"
  • Change the position on the game object to ex 10, 20, 0 to make it visible.
  • 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.

Demo: https://britzl.github.io/Metrics/

FPS

The 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:

  1. Using fps.go() - Draw FPS counter at game object world position using draw text
  2. Using fps.script - Draw FPS counter at game object world position using draw text
  3. Using fps.lua - Draw FPS counter at specified position or get current FPS

fps.create(samples, format, position, color)

Create an instance of the FPS counter

PARAMETERS

  • samples (number) - Optional sample count. This is the number of samples required before the module will calculate FPS. Defaults to 60.
  • format (string) - Optional format to draw FPS in. Defaults to "FPS %.2f"
  • position (string) - Optional position to draw FPS at. Defaults to v3(10, 20, 0)
  • color (string) - Optional color to use when drawing FPS text. Defaults to v4(0,0,1,1)

RETURNS

  • instance (table) - An FPS counter instance

fps.update()

Call this once per frame. Once enough samples have been collected it is possible to call fps() to get the current FPS.

fps.fps()

Get the current FPS, based on collected samples.

RETURNS

  • fps (number) - The calculated FPS

fps.draw()

Draw fps count text using draw_debug_text.

Memory

The memory counter uses collectgarbage("count") to get the amount of Lua memory used. The memory counter can be used in several ways:

  1. Using mem.go() - Draw memory usage at game object world position using draw text
  2. Using mem.script - Draw memory usage at game object world position using draw text
  3. Using mem.lua - Draw memory usage at specified position or get current memory usage

mem.create(format, position, color)

Create an instance of the memory counter

PARAMETERS

  • format (string) - Optional format to draw memory usage in. Defaults to "MEM %dkb"
  • position (string) - Optional position to draw memory usage at. Defaults to v3(10, 20, 0)
  • color (string) - Optional color to use when drawing memory usage text. Defaults to v4(0,0,1,1)

RETURNS

  • instance (table) - A memory counter counter instance

mem.update()

Call this to get a new memory usage reading.

mem.mem()

Get the current memory usage, in kilobytes.

RETURNS

  • mem (number) - The Lua memory usage

mem.draw()

Draw memory usage text using draw_debug_text.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].