-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathFpsCounter.cs
More file actions
85 lines (69 loc) · 1.89 KB
/
FpsCounter.cs
File metadata and controls
85 lines (69 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using UnityEngine;
using System.Collections;
public class FpsCounter : MonoBehaviour {
public float updateInterval = 0.5F;
private float lastInterval;
private int frames = 0;
private float fps;
private int displayCounter = 0;
public int displayCounterTarget = 5;
public static int pathfindingsCounter = 0;
public static int pathfindingsMax = int.MinValue;
private int maxPFSFps = 0;
private int lowFPS = int.MaxValue;
public bool first = true;
public bool firstFps = true;
public bool firstMPF = true;
public static long pathfindingTime = 0;
public long maxPathFindingTime = 0;
void Start() {
lastInterval = Time.realtimeSinceStartup;
frames = 0;
}
void OnGUI() {
GUI.Label(new Rect(1, 1, 600, 28), "FPS: " + fps.ToString() + " lowest FPS: " + lowFPS + " PFS: " + pathfindingsCounter + " Max PFS: " + pathfindingsMax + " FPS with Max PFS: " + maxPFSFps + " MAX PF TIME: " + maxPathFindingTime, "box");
}
void Update() {
++frames;
float timeNow = Time.realtimeSinceStartup;
if (timeNow > lastInterval + 1) {
fps = frames;
frames = 0;
lastInterval = timeNow;
displayCounter++;
if (displayCounter >= displayCounterTarget)
{
displayCounter = 0;
}
if (pathfindingsMax < pathfindingsCounter)
{
if (!first)
{
pathfindingsMax = pathfindingsCounter;
maxPFSFps = (int)fps;
}
else
first = false;
}
if (lowFPS > fps)
{
if (!firstFps)
{
lowFPS = (int) fps;
}
else
firstFps = false;
}
if (maxPathFindingTime < pathfindingTime)
{
if (!firstMPF)
{
maxPathFindingTime = pathfindingTime;
}
else
firstMPF = false;
}
pathfindingsCounter = 0;
}
}
}