-
Notifications
You must be signed in to change notification settings - Fork 1
/
RuntimeProfilerManager.cs
46 lines (42 loc) · 1.24 KB
/
RuntimeProfilerManager.cs
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
using System;
using UnityEngine;
using UnityEngine.Profiling;
using WebSocketSharp;
namespace Opencraft.Statistics
{
/// <summary>
/// Sets new profiler .raw log files every NUM_FRAMES.
/// </summary>
public class RuntimeProfilerManager : MonoBehaviour
{
private string baseFile;
private int fileOffset = 1;
private int lastUpdate = 0;
private int NUM_FRAMES = 1750;
private void Awake()
{
if (!Profiler.enabled || Profiler.logFile.IsNullOrEmpty())
{
this.enabled = false;
return;
}
// Filename without .raw extension
baseFile = Profiler.logFile.Substring(0, Profiler.logFile.Length-4);
}
private void Update()
{
int currentFrame = Time.frameCount;
if (currentFrame - lastUpdate >= NUM_FRAMES)
{
NewProfilerLogFile();
lastUpdate = currentFrame;
}
}
private void NewProfilerLogFile()
{
// Time.time is elapsed seconds since Awake calls finished
Profiler.logFile = $"{baseFile}_{fileOffset}_{Time.time}.raw";
fileOffset++;
}
}
}