Skip to content

Commit 10521e0

Browse files
committed
Parse speedtest results
1 parent 516ae25 commit 10521e0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

modSystem.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@ public static int RunSpeedTest()
255255
SpeedTestRunner.WaitForExit();
256256
string speedJson = SpeedTestRunner.StandardOutput.ReadToEnd();
257257
modLogging.LogEvent("Speed test results: " + speedJson, EventLogEntryType.Information, 6072);
258+
using (JsonDocument speedResults = JsonDocument.Parse(speedJson))
259+
{
260+
double downSpeed = Math.Round(speedResults.RootElement.GetProperty("download").GetProperty("bandwidth").GetInt64() / 125000D, 2);
261+
double upSpeed = Math.Round(speedResults.RootElement.GetProperty("upload").GetProperty("bandwidth").GetInt64() / 125000D, 2);
262+
modLogging.LogEvent("Speed test results: " + downSpeed.ToString() + " Mbps Down, " + upSpeed.ToString() + " Mbps Up", EventLogEntryType.Information, 6072);
263+
}
258264
return SpeedTestRunner.ExitCode;
259265
}
260266
catch(Exception err)

0 commit comments

Comments
 (0)