Code Monkey home page Code Monkey logo

gdperfmonitor's Introduction

Performance monitor node for Godot

Simple node for in-game monitoring of FPS, memory usage and such, loosely styled by Three.js's performance monitor.

Example

It may have some performance overhead (around 180 draw calls per frame, CPU and mem usage is slight), but for FPS or memory monitoring it seems insignificant.

Can display any numeric object parameter or function call result.

Usage

  • Install from AssetLib

  • Add Monitor node to your scene tree

  • Setup what to monitor

    •   $Monitor.os_time_per_frame()
    •   $Monitor.add_perf_monitor(Performance.TIME_FPS, "FPS")
    •   $Monitor.add_custom_monitor($Player, "hitpoints", "Player hp")
        # your $Player node must have "hitpoints" attribute, which must be either float or int
    •   var render_info_funcref: FuncRef = funcref(VisualServer, "get_render_info")
        $Monitor.add_funcref_monitor(render_info_funcref, [VisualServer.INFO_TEXTURE_MEM_USED], "Texture mem")

Also you can set plot size, color, or amount of plot stored data, check out example.gd.

Convenience function $Monitor.os_time_per_frame(), creates a monitor to show difference in OS.get_ticks_usec() between _process() calls.

Reference

  •   os_time_perframe() - creates a plot panel to show difference between OS.get_ticks_usec() calls
    
  •   add_perf_monitor() - creates a plot panel to monitor one of the built-in Performance enum 
    
      # required
      param_key: int - key from Performance enum 
      
      # optional	
      label: String = "" - label to display
      color: Color = Color(0.2, 1, 0.2, 0.5) - color
      humanise: bool = false - whether to use humanize for large numbers
      is_data_int: bool = true - !important for floats change to false
      max_value: float = 0.0 - maximum value
      data_len: int = 180 
      size_px: Vector2 = Vector2(180, 80)
    
  •   add_custom_monitor() - creates a plot panel to monitor one of the passed objects' numeric attributes
    
      # required
      obj: Object - object to monitor
      param_name: String - name of numeric attribute of the object above
      
      # optional	
      label: String = "" - label to display
      color: Color = Color(0.2, 1, 0.2, 0.5) - color
      humanise: bool = false - whether to use humanize for large numbers
      is_data_int: bool = true - !important for floats change to false
      max_value: float = 0.0 - maximum value
      data_len: int = 180 
      size_px: Vector2 = Vector2(180, 80)
    
  •   add_funcref_monitor() - creates a plot panel to monitor results of the calls to the passed function
    
      # required
      function_ref: FuncRef - funcref to a function that will be called every _process()
      
      # optional	
      function_params: Array = [] - array of function param values
      label: String = "" - label to display
      color: Color = Color(0.2, 1, 0.2, 0.5) - color
      humanise: bool = false - whether to use humanize for large numbers
      is_data_int: bool = true - !important for floats change to false
      max_value: float = 0.0 - maximum value
      data_len: int = 180 
      size_px: Vector2 = Vector2(180, 80)
    

Other notes

The draw call happens in _process(), so update rate may be not constant.

The plot uses some kind of ring buffer based on PoolIntArray or PoolRealArray for storing data.

Rendering may be optimized.

gdperfmonitor's People

Contributors

aleksandrbazhin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.