Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
FrameSkipTest.cs
Go to the documentation of this file.
5
6namespace Terraria;
7
8public class FrameSkipTest
9{
10 private static int LastRecordedSecondNumber;
11
12 private static float CallsThisSecond;
13
14 private static float DeltasThisSecond;
15
16 private static List<float> DeltaSamples = new List<float>();
17
18 private const int SamplesCount = 5;
19
20 private static MultiTimer serverFramerateTest = new MultiTimer(60);
21
22 public static void Update(GameTime gameTime)
23 {
24 float num = 60f;
25 float num2 = 1f / num;
26 float num3 = (float)gameTime.ElapsedGameTime.TotalSeconds;
27 Thread.Sleep((int)MathHelper.Clamp((num2 - num3) * 1000f + 1f, 0f, 1000f));
28 }
29
30 public static void CheckReset(GameTime gameTime)
31 {
32 if (LastRecordedSecondNumber != gameTime.TotalGameTime.Seconds)
33 {
35 if (DeltaSamples.Count > 5)
36 {
37 DeltaSamples.RemoveAt(0);
38 }
39 CallsThisSecond = 0f;
41 LastRecordedSecondNumber = gameTime.TotalGameTime.Seconds;
42 }
43 }
44
45 public static void UpdateServerTest()
46 {
47 serverFramerateTest.Record("frame time");
48 serverFramerateTest.StopAndPrint();
49 serverFramerateTest.Start();
50 }
51}
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
static void Sleep(int millisecondsTimeout)
Definition Thread.cs:658
static void UpdateServerTest()
static MultiTimer serverFramerateTest
static void CheckReset(GameTime gameTime)
static float DeltasThisSecond
static int LastRecordedSecondNumber
static void Update(GameTime gameTime)
static float CallsThisSecond
static List< float > DeltaSamples