FPS Counter and Graph is a frame counter that saves the time of each frame for a specified period of time and calculates the average fps, minimum and maximum fps from the obtained values.
This counter also displays a graph of the average value, and can record the values of the minimum, average and maximum FPS in a csv file, for further analysis.
Features:
- Counter minimum, average and maximum FPS.
- Graph of the average value of FPS.
- Log file (csv) for minimum, average and maximum FPS.
- You can use FPS counter as a class by calling it from anywhere else.
- One script.
- Good performance.
For Unity version of at least 2019.1.8 (64-bit)
Current version 2.0
Information
There is an example in this asset to understand the operation and settings.
I recommend importing this asset into a new project. Study the operation of the asset and copy the components you need to your project.
Component Settings
Description of component settings. There are already two prefabs in the asset, you can also explore example.
Settings
Time Update - the period (in seconds) for which information about the frame time is collected and the minimum, average and maximum FPS are calculated.
Highest Possible FPS - the maximum possible FPS in the scene and in the counter.
Graph Color - color of the chart lines.
Log Write - enable logging to the csv file.
Scripting
You can use the FPS counter as a class.
StFPS.Counter - is public static Vector3Int, where x - is the minimum FPS, y - is the average FPS, z - is the maximum FPS.
StFPS.Counter should only be called from Update().
using UnityEngine;
public class Example : MonoBehaviour
{
float timeUpdate = 1.0f;
void Update()
{
print("Min FPS:" + StFPS.Counter(timeUpdate).x);
print("Avg FPS:" + StFPS.Counter(timeUpdate).y);
print("Max FPS:" + StFPS.Counter(timeUpdate).z);
}
}
Logging to the file is done by calling public static void StFPS.LogWrite(), this is done only once, for example, when exiting the program.
using UnityEngine;
public class Example : MonoBehaviour
{
void OnApplicationQuit()
{
StFPS.LogWrite();
}
}
using UnityEngine;
using UnityEngine.UI;
public class Example : MonoBehaviour
{
public Button exitButton;
void Awake()
{
exitButton.onClick.AddListener(ExitButton);
}
void ExitButton()
{
StFPS.LogWrite();
Application.Quit();
}
}
License
This project is licensed under
MIT License