public static void Start(ref UdpBitStream bitStream, BandwidthLogType _logType) { if (!enabled) { return; } logType = _logType; lastPtr = bitStream.ptr; startPtr = lastPtr; summary = ""; }
public static void ReportMasterBits(ref UdpBitStream bitstream, BandwidthLogType logType) { if (!enabled) { return; } // log start time if this is the first call. if (logType == BandwidthLogType.MasterIn) { if (masterInStartTimer == 0) { masterInStartTimer = Time.time; } else if (masterOutStartTimer == 0) { masterOutStartTimer = Time.time; } } if (logType == BandwidthLogType.MasterIn) { masterInTotalBits += bitstream.ptr; } else { masterOutTotalBits += bitstream.ptr; } float elapstedTime = Time.time - ((logType == BandwidthLogType.MasterIn) ? masterInStartTimer : masterOutStartTimer); string color = (logType == BandwidthLogType.MasterIn) ? "<color=blue>" : "<color=green>"; string avg = (masterInTotalBits / elapstedTime).ToString(); UnityEngine.Debug.Log(Time.time + " " + color + "<b>" + logType + " Summary:</b></color> " + bitstream.ptr + " bits / " + bitstream.BytesUsed + " Bytes / " + avg + " b/s "); }