Skip to content

Commit

Permalink
Release 2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Release Automat committed May 25, 2024
1 parent 5709200 commit e859a0d
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 72 deletions.
7 changes: 7 additions & 0 deletions Packages/tlp.udonprofiling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ The used pattern MAJOR.MINOR.PATCH indicates:

All notable changes to this project will be documented in this file.

### [2.0.1] - 2024-05-25

#### ⚙️ Miscellaneous Tasks

- Migrate to UdonUtils 8.0.0
- Update demo scene

### [2.0.0] - 2024-05-16

#### 🚀 Features
Expand Down
4 changes: 2 additions & 2 deletions Packages/tlp.udonprofiling/Runtime/GlobalProfileHandler.asset
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ MonoBehaviour:
Data: 8|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: TLP.UdonUtils.Logger.ELogLevel, TLP.UdonUtils.Runtime
Data: TLP.UdonUtils.Runtime.Logger.ELogLevel, TLP.UdonUtils.Runtime
- Name:
Entry: 8
Data:
Expand Down Expand Up @@ -325,7 +325,7 @@ MonoBehaviour:
Data: 19|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: TLP.UdonUtils.Logger.TlpLogger, TLP.UdonUtils.Runtime
Data: TLP.UdonUtils.Runtime.Logger.TlpLogger, TLP.UdonUtils.Runtime
- Name:
Entry: 8
Data:
Expand Down
4 changes: 2 additions & 2 deletions Packages/tlp.udonprofiling/Runtime/GlobalProfileKickoff.asset
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ MonoBehaviour:
Data: 8|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: TLP.UdonUtils.Logger.ELogLevel, TLP.UdonUtils.Runtime
Data: TLP.UdonUtils.Runtime.Logger.ELogLevel, TLP.UdonUtils.Runtime
- Name:
Entry: 8
Data:
Expand Down Expand Up @@ -325,7 +325,7 @@ MonoBehaviour:
Data: 19|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: TLP.UdonUtils.Logger.TlpLogger, TLP.UdonUtils.Runtime
Data: TLP.UdonUtils.Runtime.Logger.TlpLogger, TLP.UdonUtils.Runtime
- Name:
Entry: 8
Data:
Expand Down
2 changes: 1 addition & 1 deletion Packages/tlp.udonprofiling/Runtime/GlobalProfileKickoff.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using JetBrains.Annotations;
using TLP.UdonUtils;
using TLP.UdonUtils.Logger;
using TLP.UdonUtils.Runtime.Logger;
using UdonSharp;
using UnityEngine;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -904,17 +904,17 @@ PrefabInstance:
- target: {fileID: 2012949151903506351, guid: a2e29b4f6c24d5a49851f212381a8bf5,
type: 3}
propertyPath: Build
value: 16
value: 17
objectReference: {fileID: 0}
- target: {fileID: 2012949151903506351, guid: a2e29b4f6c24d5a49851f212381a8bf5,
type: 3}
propertyPath: Timestamp
value: 1715879103
value: 1716647143
objectReference: {fileID: 0}
- target: {fileID: 2012949151903506351, guid: a2e29b4f6c24d5a49851f212381a8bf5,
type: 3}
propertyPath: SyncedBuild
value: 16
value: 17
objectReference: {fileID: 0}
- target: {fileID: 2012949151903506351, guid: a2e29b4f6c24d5a49851f212381a8bf5,
type: 3}
Expand All @@ -924,7 +924,7 @@ PrefabInstance:
- target: {fileID: 2012949151903506351, guid: a2e29b4f6c24d5a49851f212381a8bf5,
type: 3}
propertyPath: serializationData.SerializedFormat
value: 0
value: 2
objectReference: {fileID: 0}
- target: {fileID: 2103673682335936013, guid: a2e29b4f6c24d5a49851f212381a8bf5,
type: 3}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ MonoBehaviour:
Data: 8|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: TLP.UdonUtils.Logger.ELogLevel, TLP.UdonUtils.Runtime
Data: TLP.UdonUtils.Runtime.Logger.ELogLevel, TLP.UdonUtils.Runtime
- Name:
Entry: 8
Data:
Expand Down Expand Up @@ -325,7 +325,7 @@ MonoBehaviour:
Data: 19|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: TLP.UdonUtils.Logger.TlpLogger, TLP.UdonUtils.Runtime
Data: TLP.UdonUtils.Runtime.Logger.TlpLogger, TLP.UdonUtils.Runtime
- Name:
Entry: 8
Data:
Expand Down Expand Up @@ -733,7 +733,7 @@ MonoBehaviour:
Data: 45|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: TLP.UdonUtils.DesignPatterns.MVC.Model, TLP.UdonUtils.Runtime
Data: TLP.UdonUtils.Runtime.DesignPatterns.MVC.Model, TLP.UdonUtils.Runtime
- Name:
Entry: 8
Data:
Expand Down Expand Up @@ -787,7 +787,7 @@ MonoBehaviour:
Data: 48|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: TLP.UdonUtils.DesignPatterns.MVC.View, TLP.UdonUtils.Runtime
Data: TLP.UdonUtils.Runtime.DesignPatterns.MVC.View, TLP.UdonUtils.Runtime
- Name:
Entry: 8
Data:
Expand Down
59 changes: 17 additions & 42 deletions Packages/tlp.udonprofiling/Runtime/Ui/PerformanceStatController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Diagnostics;
using TLP.UdonUtils.DesignPatterns.MVC;
using TLP.UdonUtils.Runtime.DesignPatterns.MVC;
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
Expand All @@ -15,37 +15,29 @@ public class PerformanceStatController : Controller
private float UpdateInterval = 1f;

#region State

private int _previousFrameCount;
private bool _hasStarted;
private float _lastUpdated;
private float _lastIntervalDuration;
private PerformanceStatModel _performanceStatModel;
private readonly Stopwatch _stopwatch = new Stopwatch();

#endregion

#region Monobehaviour

internal void OnEnable()
{
if (!Initialized)
{
internal void OnEnable() {
if (!Initialized) {
enabled = false;
return;
}

if (_hasStarted)
{
if (_hasStarted) {
Start();
}
}

public override void Start()
{
public override void Start() {
base.Start();
if (!Initialized && !InitializeMvcSingleGameObject(gameObject))
{
if (!Initialized && !InitializeMvcSingleGameObject(gameObject)) {
Error($"Failed to initialize");
enabled = false;
return;
Expand All @@ -56,48 +48,37 @@ public override void Start()
SendCustomEventDelayedSeconds(nameof(UpdateFrameRate), UpdateInterval);
_hasStarted = true;
}

#endregion

#region VRC

public override void OnPlayerJoined(VRCPlayerApi player)
{
if (!Initialized)
{
public override void OnPlayerJoined(VRCPlayerApi player) {
if (!Initialized) {
return;
}

if (!Utilities.IsValid(_performanceStatModel))
{
if (!Utilities.IsValid(_performanceStatModel)) {
Error($"{nameof(_performanceStatModel)} invalid");
}

_performanceStatModel.Dirty = true;
_performanceStatModel.NotifyIfDirty(1);
}

public override void OnPlayerLeft(VRCPlayerApi player)
{
if (!Initialized)
{
public override void OnPlayerLeft(VRCPlayerApi player) {
if (!Initialized) {
return;
}

_performanceStatModel.Dirty = true;
_performanceStatModel.NotifyIfDirty(1);
}

#endregion

#region Internal

public void UpdateFrameRate()
{
public void UpdateFrameRate() {
float currentTime = Time.timeSinceLevelLoad;
_lastIntervalDuration = currentTime - _lastUpdated;
if (_lastIntervalDuration < UpdateInterval)
{
if (_lastIntervalDuration < UpdateInterval) {
return;
}

Expand All @@ -110,12 +91,9 @@ public void UpdateFrameRate()
int countedFrames = frameCount - _previousFrameCount;
_performanceStatModel.CountedFrames = countedFrames;

if (countedFrames > 0)
{
if (countedFrames > 0) {
_performanceStatModel.AverageFrameTime = (float)(elapsedTotalMilliseconds / countedFrames);
}
else
{
} else {
_performanceStatModel.AverageFrameTime = 0f;
}

Expand All @@ -126,8 +104,7 @@ public void UpdateFrameRate()
SendCustomEventDelayedSeconds(nameof(UpdateFrameRate), UpdateInterval);
}

protected override bool InitializeInternal()
{
protected override bool InitializeInternal() {
#if TLP_DEBUG
DebugLog(nameof(InitializeInternal));
#endif
Expand All @@ -136,14 +113,12 @@ protected override bool InitializeInternal()
enabled = true;

bool initSuccess = Utilities.IsValid(_performanceStatModel);
if (initSuccess)
{
if (initSuccess) {
enabled = true;
}

return initSuccess;
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ MonoBehaviour:
Data: 8|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: TLP.UdonUtils.Logger.ELogLevel, TLP.UdonUtils.Runtime
Data: TLP.UdonUtils.Runtime.Logger.ELogLevel, TLP.UdonUtils.Runtime
- Name:
Entry: 8
Data:
Expand Down Expand Up @@ -325,7 +325,7 @@ MonoBehaviour:
Data: 19|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: TLP.UdonUtils.Logger.TlpLogger, TLP.UdonUtils.Runtime
Data: TLP.UdonUtils.Runtime.Logger.TlpLogger, TLP.UdonUtils.Runtime
- Name:
Entry: 8
Data:
Expand Down Expand Up @@ -733,7 +733,7 @@ MonoBehaviour:
Data: 45|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: TLP.UdonUtils.Events.UdonEvent, TLP.UdonUtils.Runtime
Data: TLP.UdonUtils.Runtime.Events.UdonEvent, TLP.UdonUtils.Runtime
- Name:
Entry: 8
Data:
Expand Down Expand Up @@ -1177,7 +1177,7 @@ MonoBehaviour:
Data: 65|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: TLP.UdonUtils.Sources.TimeSource, TLP.UdonUtils.Runtime
Data: TLP.UdonUtils.Runtime.Sources.TimeSource, TLP.UdonUtils.Runtime
- Name:
Entry: 8
Data:
Expand Down
20 changes: 15 additions & 5 deletions Packages/tlp.udonprofiling/Runtime/Ui/PerformanceStatModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using TLP.UdonUtils.DesignPatterns.MVC;
using TLP.UdonUtils.Sources;
using TLP.UdonUtils.Sources.Time;
using TLP.UdonUtils.Runtime.DesignPatterns.MVC;
using TLP.UdonUtils.Runtime.Sources;
using TLP.UdonUtils.Runtime.Sources.Time;
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
Expand Down Expand Up @@ -43,12 +43,15 @@ protected override bool SetupAndValidate() {
if (!Utilities.IsValid(RefNetworkTime)) {
var gameTime = NetworkTime.transform.Find("VrcTime");
if (!gameTime) {
ErrorAndDisableGameObject($"{nameof(RefNetworkTime)} is not set and failed to find fallback 'VrcTime");
ErrorAndDisableGameObject(
$"{nameof(RefNetworkTime)} is not set and failed to find fallback 'VrcTime");
return false;
}

RefNetworkTime = gameTime.GetComponent<TimeSource>();
if (!Utilities.IsValid(RefNetworkTime)) {
ErrorAndDisableGameObject($"{nameof(RefNetworkTime)} is not set and fallback is unavailable, add 'TLP_Essentials' prefab to your scene");
ErrorAndDisableGameObject(
$"{nameof(RefNetworkTime)} is not set and fallback is unavailable, add 'TLP_Essentials' prefab to your scene");
return false;
}
}
Expand All @@ -66,9 +69,11 @@ public double VrcServerTime
if (tlpNetworkTime) {
return tlpNetworkTime.SampledRealServerTime;
}

return 0f;
}
}

public double ServerTimeError
{
get
Expand All @@ -77,6 +82,7 @@ public double ServerTimeError
if (tlpNetworkTime) {
return tlpNetworkTime.ExactError;
}

return RefNetworkTime.TimeAsDouble() - NetworkTime.TimeAsDouble();
}
}
Expand All @@ -89,6 +95,7 @@ public int ServerTimeSamples
if (tlpNetworkTime) {
return tlpNetworkTime.Samples;
}

return -1;
}
}
Expand All @@ -101,9 +108,11 @@ public double CumulativeError
if (tlpNetworkTime) {
return tlpNetworkTime.AverageError;
}

return 0;
}
}

public double CorrectiveDrift
{
get
Expand All @@ -112,6 +121,7 @@ public double CorrectiveDrift
if (tlpNetworkTime) {
return tlpNetworkTime.AverageError / tlpNetworkTime.Samples;
}

return 0;
}
}
Expand Down
Loading

0 comments on commit e859a0d

Please sign in to comment.