private void PrintRecyclerStats() { Console.WriteLine(); Console.WriteLine("Recycler statistics: "); int rFree = Recycler <NetworkMessage> .GetPoolFreeCount(); int rTotal = Recycler <NetworkMessage> .GetPoolCount(); Console.WriteLine("NetworkMessage: " + rFree + "/" + rTotal); rFree = ByteRecycler.GetPoolFreeCount(2048); rTotal = ByteRecycler.GetPoolCount(2048); Console.WriteLine("ByteArray 2048: " + rFree + "/" + rTotal); rFree = ByteRecycler.GetPoolFreeCount(128 * 1024 * 1024); rTotal = ByteRecycler.GetPoolCount(128 * 1024 * 1024); Console.WriteLine("ByteArray 128M: " + rFree + "/" + rTotal); Console.WriteLine("Total memory: " + GC.GetTotalMemory(false) / 1024); }
private void Update() { safeDisplay = optionsWindow.showDebugWindow; if (safeDisplay) { if (((Client.realtimeSinceStartup - lastUpdateTime) > DISPLAY_UPDATE_INTERVAL) || displayFast) { lastUpdateTime = Client.realtimeSinceStartup; //Vector text if (displayVectors) { if (HighLogic.LoadedScene == GameScenes.FLIGHT && FlightGlobals.ready && FlightGlobals.fetch.activeVessel != null) { Vessel ourVessel = FlightGlobals.fetch.activeVessel; vectorText = "Forward vector: " + ourVessel.GetFwdVector() + "\n"; vectorText += "Up vector: " + (Vector3)ourVessel.upAxis + "\n"; vectorText += "Srf Rotation: " + ourVessel.srfRelRotation + "\n"; vectorText += "Vessel Rotation: " + ourVessel.transform.rotation + "\n"; vectorText += "Vessel Local Rotation: " + ourVessel.transform.localRotation + "\n"; vectorText += "mainBody Rotation: " + (Quaternion)ourVessel.mainBody.rotation + "\n"; vectorText += "mainBody Transform Rotation: " + (Quaternion)ourVessel.mainBody.bodyTransform.rotation + "\n"; vectorText += "Surface Velocity: " + ourVessel.GetSrfVelocity() + ", |v|: " + ourVessel.GetSrfVelocity().magnitude + "\n"; vectorText += "Orbital Velocity: " + ourVessel.GetObtVelocity() + ", |v|: " + ourVessel.GetObtVelocity().magnitude + "\n"; if (ourVessel.orbitDriver != null && ourVessel.orbitDriver.orbit != null) { vectorText += "Frame Velocity: " + (Vector3)ourVessel.orbitDriver.orbit.GetFrameVel() + ", |v|: " + ourVessel.orbitDriver.orbit.GetFrameVel().magnitude + "\n"; } vectorText += "CoM offset vector: " + ourVessel.CoM.ToString() + "\n"; vectorText += "Angular Velocity: " + ourVessel.angularVelocity + ", |v|: " + ourVessel.angularVelocity.magnitude + "\n"; vectorText += "World Pos: " + (Vector3)ourVessel.GetWorldPos3D() + ", |pos|: " + ourVessel.GetWorldPos3D().magnitude + "\n"; } else { vectorText = "You have to be in flight"; } } //NTP text if (displayNTP) { ntpText = "Warp rate: " + Math.Round(Time.timeScale, 3) + "x.\n"; ntpText += "Current subspace: " + timeSyncer.currentSubspace + ".\n"; if (timeSyncer.locked) { ntpText += "Current subspace rate: " + Math.Round(timeSyncer.lockedSubspace.subspaceSpeed, 3) + "x.\n"; } else { ntpText += "Current subspace rate: " + Math.Round(timeSyncer.requestedRate, 3) + "x.\n"; } ntpText += "Current Error: " + Math.Round((timeSyncer.GetCurrentError() * 1000), 0) + " ms.\n"; ntpText += "Current universe time: " + Math.Round(Planetarium.GetUniversalTime(), 3) + " UT\n"; ntpText += "Network latency: " + Math.Round((timeSyncer.networkLatencyAverage / 10000f), 3) + " ms\n"; ntpText += "Server clock difference: " + Math.Round((timeSyncer.clockOffsetAverage / 10000f), 3) + " ms\n"; ntpText += "Server lag: " + Math.Round((timeSyncer.serverLag / 10000f), 3) + " ms\n"; } //Connection queue text if (displayConnectionQueue) { connectionText = "Last send time: " + networkWorker.GetStatistics("LastSendTime") + "ms.\n"; connectionText += "Last receive time: " + networkWorker.GetStatistics("LastReceiveTime") + "ms.\n"; connectionText += "Queued outgoing messages (High): " + networkWorker.GetStatistics("HighPriorityQueueLength") + ".\n"; connectionText += "Queued outgoing messages (Split): " + networkWorker.GetStatistics("SplitPriorityQueueLength") + ".\n"; connectionText += "Queued outgoing messages (Low): " + networkWorker.GetStatistics("LowPriorityQueueLength") + ".\n"; connectionText += "Queued out bytes: " + networkWorker.GetStatistics("QueuedOutBytes") + ".\n"; connectionText += "Sent bytes: " + networkWorker.GetStatistics("SentBytes") + ".\n"; connectionText += "Received bytes: " + networkWorker.GetStatistics("ReceivedBytes") + ".\n"; connectionText += "Stored future updates: " + vesselWorker.GetStatistics("StoredFutureUpdates") + "\n"; connectionText += "Stored future proto updates: " + vesselWorker.GetStatistics("StoredFutureProtoUpdates") + ".\n"; } //Dynamic tick text if (displayDynamicTickStats) { dynamicTickText = "Current tick rate: " + DynamicTickWorker.SEND_TICK_RATE + "hz.\n"; dynamicTickText += "Current max secondry vessels: " + dynamicTickWorker.maxSecondryVesselsPerTick + ".\n"; } //Requested rates text if (displayRequestedRates) { requestedRateText = dmpSettings.playerName + ": " + Math.Round(timeSyncer.requestedRate, 3) + "x.\n"; foreach (KeyValuePair <string, float> playerEntry in warpWorker.clientSkewList) { requestedRateText += playerEntry.Key + ": " + Math.Round(playerEntry.Value, 3) + "x.\n"; } } //Requested rates text if (displayRecycler) { recyclerText = "16kB: " + ByteRecycler.GetPoolCount(Client.SMALL_MESSAGE_SIZE) + ", free: " + ByteRecycler.GetPoolFreeCount(Client.SMALL_MESSAGE_SIZE) + "\n"; recyclerText += "512kB: " + ByteRecycler.GetPoolCount(Client.MEDIUM_MESSAGE_SIZE) + ", free: " + ByteRecycler.GetPoolFreeCount(Client.MEDIUM_MESSAGE_SIZE) + "\n"; recyclerText += "6MB: " + ByteRecycler.GetPoolCount(Client.LARGE_MESSAGE_SIZE) + ", free: " + ByteRecycler.GetPoolFreeCount(Client.LARGE_MESSAGE_SIZE) + "\n"; recyclerText += "VesselUpdate: " + Recycler <VesselUpdate> .GetPoolCount() + ", free: " + Recycler <VesselUpdate> .GetPoolFreeCount() + "\n"; } if (dumpRecycler) { dumpRecycler = false; string dumpPath = Path.Combine(KSPUtil.ApplicationRootPath, "DarkMultiPlayer-Recycler"); ByteRecycler.DumpNonFree(dumpPath); } } } }