public void CleanUp() { publishMessageCounter.Reset(); if (QManager != null) { UnityEngine.Object.Destroy(QManager); } if (Latency != null) { Latency.CleanUp(); UnityEngine.Object.Destroy(Latency); } #if (ENABLE_PUBNUB_LOGGING) this.PNLog.WriteToLog("CleanUp: Destructing GameObject", PNLoggingMethod.LevelInfo); #endif try{ if (localGobj && (GameObjectRef != null)) { UnityEngine.Object.Destroy(GameObjectRef); } }catch (Exception ex) { #if (ENABLE_PUBNUB_LOGGING) this.PNLog.WriteToLog(string.Format("CleanUp: Destructing GameObject exception {0}", ex.ToString()), PNLoggingMethod.LevelInfo); #endif } }
public override int GetBehaviorHashCode() { return(AddMode.GetHashCode() ^ AinitValue.GetHashCode() ^ Atype.GetHashCode() ^ Awidth ^ Bconstant.GetHashCode() ^ BorrowSense.GetHashCode() ^ Btype.GetHashCode() ^ Bvalue.GetHashCode() ^ Bwidth ^ BypassCePriority.GetHashCode() ^ BypassSense.GetHashCode() ^ ConstantInputValue.GetHashCode() ^ Generator.GetHashCode() ^ HasBypass.GetHashCode() ^ HasCarryIn.GetHashCode() ^ HasCarryOut.GetHashCode() ^ HasCE.GetHashCode() ^ HasConstantInput.GetHashCode() ^ HasSCLR.GetHashCode() ^ HasSSET.GetHashCode() ^ Implementation.GetHashCode() ^ Latency.GetHashCode() ^ LatencyConfiguration.GetHashCode() ^ OutWidth); }
private static Latency ExecuteNOPersisstentConnection(string connectionString) { var result = new Latency(); string[] lines = System.IO.File.ReadAllLines(@"connections.sql"); var stopwatch = new Stopwatch(); foreach (string line in lines) { stopwatch.Restart(); using (var connection = new MySqlConnection(connectionString)) { connection.Open(); result.ConnectionElapsedMilliseconds += stopwatch.ElapsedMilliseconds; stopwatch.Restart(); //Console.WriteLine(line); using (var command = new MySqlCommand($"{line};", connection)) { command.ExecuteScalar(); result.CommandElapsedMilliseconds += stopwatch.ElapsedMilliseconds; } } } return(result); }
/// <summary> /// Write file. This fuction write file in 512b chunks. /// </summary> /// <param name="name"></param> /// <param name="data"></param> public override void Write(string name, byte[] data) { PendingWrites++; int index = 0; int offset = (512 > data.Length) ? data.Length : 512; // Testing output int delay = Latency.Next(Random); using (BinaryWriter file = new BinaryWriter(new FileStream(Path.Combine(DirectoryInfo.FullName, name), FileMode.OpenOrCreate, FileAccess.Write))) { while (index < offset) { Task.Delay(delay).Wait(); file.Write(data, index, (offset - index)); int bufferSize = offset - index; // Update buffer write region index = offset; offset += 512; offset = (offset > data.Length) ? data.Length : offset; } } TotalWrites++; TotalBytesWritten += data.Length; PendingWrites--; }
public Dictionary <string, string> SerializeData() { var data = new Dictionary <string, string> { { "SucceededAt", JobHelper.SerializeDateTime(SucceededAt) }, { "PerformanceDuration", PerformanceDuration.ToString(CultureInfo.InvariantCulture) }, { "Latency", Latency.ToString(CultureInfo.InvariantCulture) } }; if (Result != null) { string serializedResult; try { serializedResult = JobHelper.ToJson(Result); } catch (Exception) { serializedResult = "Can not serialize the return value"; } if (serializedResult != null) { data.Add("Result", serializedResult); } } return(data); }
public override int GetHashCode() { var hashCode = 272928259; hashCode = hashCode * -1521134295 + TimeStamp.GetHashCode(); hashCode = hashCode * -1521134295 + Latency.GetHashCode(); hashCode = hashCode * -1521134295 + Status.GetHashCode(); return(hashCode); }
public Dictionary <string, string> SerializeData() { return(new Dictionary <string, string> { { "SucceededAt", JobHelper.ToStringTimestamp(SucceededAt) }, { "PerformanceDuration", PerformanceDuration.ToString(CultureInfo.InvariantCulture) }, { "Latency", Latency.ToString(CultureInfo.InvariantCulture) } }); }
internal static bool DismountAndHarvest(PGameObject harvest, Ticker timeOut) { if (!LazySettings.BackgroundMode && !harvest.Location.IsFacing()) { harvest.Location.Face(); } if (Mount.IsMounted() && !ObjectManager.MyPlayer.IsInFlightForm) { Mount.Dismount(); timeOut.Reset(); while (ObjectManager.MyPlayer.IsMoving && !timeOut.IsReady) { Thread.Sleep(100); } Thread.Sleep(500); } Logging.Debug("Going to do harvest now"); harvest.Interact(true); Latency.Sleep(ObjectManager.MyPlayer.UnitRace != "Tauren" ? 750 : 500); if (!ObjectManager.MyPlayer.IsCasting && ObjectManager.MyPlayer.UnitRace != "Tauren") { harvest.Interact(true); Latency.Sleep(750); } if (CheckFight(harvest)) { ToldAboutNode.TellAbout("正在战斗状态", harvest); return(false); } timeOut.Reset(); while (ObjectManager.MyPlayer.IsCasting && !timeOut.IsReady) { if (CheckFight(harvest)) { ToldAboutNode.TellAbout("正在战斗状态", harvest); return(false); } Thread.Sleep(100); } if (CheckFight(harvest)) { ToldAboutNode.TellAbout("正在战斗状态", harvest); return(false); } if (Langs.SkillToLow(ObjectManager.MyPlayer.RedMessage)) { Logging.Write("技能太低"); HelperFunctions.ResetRedMessage(); if (FindNode.IsMine(harvest) || FindNode.IsHerb(harvest)) { SkillToLow.Blacklist(harvest.Name, 240); } return(false); } return(true); }
public PongPacketLog( Latency latency, Directions direction, PacketDetails packetDetails) { _latency = latency; _direction = direction; _createdAt = DateTime.UtcNow; _packetDetails = packetDetails; }
/// <summary> /// Returns a <see cref="string" /> that represents this instance. /// </summary> /// <returns>A <see cref="string" /> that represents this instance.</returns> public override string ToString() { return("{0} was invoked {1} time(s) over a period of {2}. Last recovery wait time was {3}, giving a total recovery wait time of {4}. Latency was {5}.".FormatWith( Member, Attempts, Latency.Add(TotalRecoveryWaitTime), RecoveryWaitTime, TotalRecoveryWaitTime, Latency)); }
public override int GetHashCode() { unchecked { var hashCode = Status.GetHashCode(); hashCode = (hashCode * 397) ^ (Headers != null ? Headers.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Latency.GetHashCode(); hashCode = (hashCode * 397) ^ (Body != null ? Body.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (File != null ? File.GetHashCode() : 0); return(hashCode); } }
/// <summary> /// Scan folder to buld a list of device folders. Alternates between chunked and normal folder devices. /// </summary> /// <param name="directoryInfo"></param> /// <param name="latency"></param> /// <returns></returns> static IDevice[] GetDevices(DirectoryInfo directoryInfo) { Latency latency = new Latency( int.Parse(System.Configuration.ConfigurationManager.AppSettings.Get("Latency.Min")), int.Parse(System.Configuration.ConfigurationManager.AppSettings.Get("Latency.Max")) ); return(directoryInfo.GetDirectories() .Select((directory, index) => (0 == (index % 2)) ? new FolderDevice(directory, latency) : new ChunkFolderDevice(directory, latency)) .ToArray()); }
public static Latency Empty() { var l = new Latency(); l.AveragePayloadSize = 0; l.Count = 0; l.MaxLatency = double.NaN; l.MeanLatency = double.NaN; l.MinLatency = double.NaN; l.NinetyFiveReadPercentLatency = double.NaN; return(l); }
private static void TryUnstuck(int tickCount) { MountTimeOut.Reset(); while (!IsMounted() && !MountTimeOut.IsReady) { if ((Environment.TickCount - tickCount) > 3000) { if (!ObjectManager.ShouldDefend) { MoveHelper.RotateRight(true); while ((Environment.TickCount - tickCount) < 3500) { Thread.Sleep(100); } Thread.Sleep(300); MoveHelper.StopMove(); MoveHelper.Forwards(true); if (ObjectManager.ShouldDefend) { MoveHelper.StopMove(); return; } MoveHelper.Jump(1000); while ((Environment.TickCount - tickCount) < 9000) { Thread.Sleep(100); } MoveHelper.StopMove(); } else { return; } } if (!IsMounted()) { Thread.Sleep(500); KeyHelper.SendKey("FMount"); MountTimer.Reset(); while (!MountTimer.IsReady && !IsMounted()) { if (ObjectManager.ShouldDefend || ObjectManager.MyPlayer.IsDead) { return; } Thread.Sleep(100); } Latency.Sleep(0); } } return; }
public string NamePrefix(Configuration config, int PREFIX_FLAG) { string prefix = "["; if (PREFIX_FLAG == PREFIX_LATENCY) { switch (Latency) { case LATENCY_UNKNOWN: prefix += I18N.GetString("Unknown"); break; case LATENCY_TESTING: prefix += I18N.GetString("Testing"); break; case LATENCY_ERROR: prefix += I18N.GetString("Error"); break; case LATENCY_PENDING: prefix += I18N.GetString("Pending"); break; default: prefix += Latency.ToString() + "ms"; break; } } else if (PREFIX_FLAG == PREFIX_AIRPORT) { foreach (var subscription in config.subscriptions) { if (subscription.url == subscription_url) { prefix += subscription.airport; break; } } } if (subscription_url == "") { prefix += "]"; } else { prefix += " " + ratio + "x]"; } return(prefix); }
public Boolean Save() { Boolean Saved = true; try { XmlNode Node; m_Doc.RemoveAll(); Node = m_Doc.CreateXmlDeclaration("1.0", "utf-8", String.Empty); m_Doc.AppendChild(Node); Node = m_Doc.CreateComment(String.Format(" ScpControl Configuration Data. {0} ", DateTime.Now)); m_Doc.AppendChild(Node); Node = m_Doc.CreateWhitespace("\r\n"); m_Doc.AppendChild(Node); Node = m_Doc.CreateNode(XmlNodeType.Element, "ScpControl", null); { CreateTextNode(Node, "Idle", Idle.ToString()); CreateTextNode(Node, "LX", LX.ToString()); CreateTextNode(Node, "LY", LY.ToString()); CreateTextNode(Node, "RX", RX.ToString()); CreateTextNode(Node, "RY", RY.ToString()); CreateTextNode(Node, "LED", LED.ToString()); CreateTextNode(Node, "Rumble", Rumble.ToString()); CreateTextNode(Node, "Triggers", Triggers.ToString()); CreateTextNode(Node, "Latency", Latency.ToString()); CreateTextNode(Node, "DeadL", DeadL.ToString()); CreateTextNode(Node, "DeadR", DeadR.ToString()); CreateTextNode(Node, "Native", Native.ToString()); CreateTextNode(Node, "SSP", SSP.ToString()); CreateTextNode(Node, "Brightness", Brightness.ToString()); CreateTextNode(Node, "Bus", Bus.ToString()); CreateTextNode(Node, "Force", Repair.ToString()); } m_Doc.AppendChild(Node); m_Doc.Save(m_File); } catch { Saved = false; } return(Saved); }
private void ReceivePong() { // Measure and update latency when pong received int latencyMs = ((Time.realtimeSinceStartup - pingedAtTime) * 1000).Ceil(); mainThreadActions.Enqueue(() => { pongReceived = true; if (!latency) { latency = GameObject.FindObjectOfType <Latency>(); } latency?.UpdateLatency(latencyMs); }); }
public Dictionary <string, string> SerializeData() { var data = new Dictionary <string, string> { { "SucceededAt", JobHelper.SerializeDateTime(SucceededAt) }, { "PerformanceDuration", PerformanceDuration.ToString(CultureInfo.InvariantCulture) }, { "Latency", Latency.ToString(CultureInfo.InvariantCulture) } }; if (Result != null) { data.Add("Result", JobHelper.ToJson(Result)); } return(data); }
private static Latency ExecuteRoundtrip(string connectionString) { var result = new Latency(); var stopwatch = new Stopwatch(); stopwatch.Restart(); using (var connection = new MySqlConnection(connectionString)) { connection.Open(); result.ConnectionElapsedMilliseconds = stopwatch.ElapsedMilliseconds; stopwatch.Restart(); using (var command = new MySqlCommand("SELECT 1;", connection)) { command.ExecuteScalar(); result.CommandElapsedMilliseconds = stopwatch.ElapsedMilliseconds; } } return(result); }
public StatsdMetric(string name, StatsdType type, double val) { Name = name; Type = type; _set = null; Lat = null; Value = val; NumUpdates = 1; switch (Type) { case StatsdType.StatsdSet: _set = new HashSet<double> {val}; break; case StatsdType.StatsdTimer: Lat = new Latency(); Lat.Min = Lat.Max = Lat.Sum = val; Lat.Num = 1; break; } }
private static Latency WormUp(string connectionString) { var result = new Latency(); string[] lines = System.IO.File.ReadAllLines(@"connections.sql"); var stopwatch = new Stopwatch(); stopwatch.Restart(); using (var connection = new MySqlConnection(connectionString)) { connection.Open(); result.ConnectionElapsedMilliseconds += stopwatch.ElapsedMilliseconds; stopwatch.Restart(); using (var command = new MySqlCommand($"select 1", connection)) { command.ExecuteScalar(); result.CommandElapsedMilliseconds += stopwatch.ElapsedMilliseconds; } } return(result); }
public string GetDeviceDetails() { string details = ""; switch (connectionType) { case ConnectionType.BT: details += " over Bluetooth"; break; case ConnectionType.USB: details += " over USB"; break; case ConnectionType.SONYWA: details += " over DS4 Wireless adapter"; break; } details += Charging ? " ⚡" : " "; details += "🔋" + Battery + "% Delay: " + Latency.ToString("0.00") + " ms"; return(details); }
public StatsdMetric(string name, StatsdType type, double val) { Name = name; Type = type; _set = null; Lat = null; Value = val; NumUpdates = 1; switch (Type) { case StatsdType.StatsdSet: _set = new HashSet <double> { val }; break; case StatsdType.StatsdTimer: Lat = new Latency(); Lat.Min = Lat.Max = Lat.Sum = val; Lat.Num = 1; break; } }
public ModelSetLatency(Latency val) { this.val = val; }
public override int GetHashCode() { int hash = 1; if (RequestMethod.Length != 0) { hash ^= RequestMethod.GetHashCode(); } if (RequestUrl.Length != 0) { hash ^= RequestUrl.GetHashCode(); } if (RequestSize != 0L) { hash ^= RequestSize.GetHashCode(); } if (Status != 0) { hash ^= Status.GetHashCode(); } if (ResponseSize != 0L) { hash ^= ResponseSize.GetHashCode(); } if (UserAgent.Length != 0) { hash ^= UserAgent.GetHashCode(); } if (RemoteIp.Length != 0) { hash ^= RemoteIp.GetHashCode(); } if (ServerIp.Length != 0) { hash ^= ServerIp.GetHashCode(); } if (Referer.Length != 0) { hash ^= Referer.GetHashCode(); } if (latency_ != null) { hash ^= Latency.GetHashCode(); } if (CacheLookup != false) { hash ^= CacheLookup.GetHashCode(); } if (CacheHit != false) { hash ^= CacheHit.GetHashCode(); } if (CacheValidatedWithOriginServer != false) { hash ^= CacheValidatedWithOriginServer.GetHashCode(); } if (CacheFillBytes != 0L) { hash ^= CacheFillBytes.GetHashCode(); } return(hash); }
public void MergeFrom(HttpRequest other) { if (other == null) { return; } if (other.RequestMethod.Length != 0) { RequestMethod = other.RequestMethod; } if (other.RequestUrl.Length != 0) { RequestUrl = other.RequestUrl; } if (other.RequestSize != 0L) { RequestSize = other.RequestSize; } if (other.Status != 0) { Status = other.Status; } if (other.ResponseSize != 0L) { ResponseSize = other.ResponseSize; } if (other.UserAgent.Length != 0) { UserAgent = other.UserAgent; } if (other.RemoteIp.Length != 0) { RemoteIp = other.RemoteIp; } if (other.ServerIp.Length != 0) { ServerIp = other.ServerIp; } if (other.Referer.Length != 0) { Referer = other.Referer; } if (other.latency_ != null) { if (latency_ == null) { latency_ = new global::Google.Protobuf.WellKnownTypes.Duration(); } Latency.MergeFrom(other.Latency); } if (other.CacheLookup != false) { CacheLookup = other.CacheLookup; } if (other.CacheHit != false) { CacheHit = other.CacheHit; } if (other.CacheValidatedWithOriginServer != false) { CacheValidatedWithOriginServer = other.CacheValidatedWithOriginServer; } if (other.CacheFillBytes != 0L) { CacheFillBytes = other.CacheFillBytes; } }
public ActionResult <string> Reset() { Latency.ResetLatency(); return("success"); }
public ActionResult <string> GetDependentValue() { Thread.Sleep(Latency.GetLatency()); return($"requested data: {new Random().Next() }"); }
/// <summary> /// Create instance of the folder device. /// </summary> /// <param name="directoryInfo"></param> /// <param name="latency"></param> public ChunkFolderDevice(DirectoryInfo directoryInfo, Latency latency) : base(directoryInfo, latency) { }
private bool Synchronize(byte[] targetBuffer, int targetBufferOffset, int requestedBytes, double speedRatio) { /* * Wikipedia says: * For television applications, audio should lead video by no more than 15 milliseconds and audio should * lag video by no more than 45 milliseconds. For film, acceptable lip sync is considered to be no more * than 22 milliseconds in either direction. * * The Media and Acoustics Perception Lab says: * The results of the experiment determined that the average audio leading threshold for a/v sync * detection was 185.19 ms, with a standard deviation of 42.32 ms * * The ATSC says: * At first glance it seems loose: +90 ms to -185 ms as a Window of Acceptability * - Undetectable from -100 ms to +25 ms * - Detectable at -125 ms & +45 ms * - Becomes unacceptable at -185 ms & +90 ms * * NOTE: (- Sound delayed, + Sound advanced) */ var audioLatencyMs = Latency.TotalMilliseconds; var isBeyondThreshold = false; var readableCount = AudioBuffer.ReadableCount; var rewindableCount = AudioBuffer.RewindableCount; if (audioLatencyMs > SyncThresholdLagging) { isBeyondThreshold = true; // a positive audio latency means we are rendering audio behind (after) the clock (skip some samples) // and therefore we need to advance the buffer before we read from it. if (speedRatio == 1.0) { MediaCore.Log(MediaLogMessageType.Warning, $"SYNC AUDIO: LATENCY: {Latency.Format()} | SKIP (samples being rendered too late)"); } // skip some samples from the buffer. var audioLatencyBytes = WaveFormat.ConvertLatencyToByteSize(Convert.ToInt32(Math.Ceiling(audioLatencyMs))); AudioBuffer.Skip(Math.Min(audioLatencyBytes, readableCount)); } else if (audioLatencyMs < SyncThresholdLeading) { isBeyondThreshold = true; // Compute the latency in bytes var audioLatencyBytes = WaveFormat.ConvertLatencyToByteSize(Convert.ToInt32(Math.Ceiling(Math.Abs(audioLatencyMs)))); // audioLatencyBytes = requestedBytes; // uncomment this line to enable rewinding. if (audioLatencyBytes > requestedBytes && audioLatencyBytes < rewindableCount) { // This means we have the audio pointer a little too ahead of time and we need to // rewind it the requested amount of bytes. AudioBuffer.Rewind(Math.Min(audioLatencyBytes, rewindableCount)); } else { // a negative audio latency means we are rendering audio ahead (before) the clock // and therefore we need to render some silence until the clock catches up if (speedRatio == 1.0) { MediaCore.Log(MediaLogMessageType.Warning, $"SYNC AUDIO: LATENCY: {Latency.Format()} | WAIT (samples being rendered too early)"); } // render silence for the wait time and return Array.Clear(targetBuffer, targetBufferOffset, requestedBytes); return(false); } } // Perform minor adjustments until the delay is less than 10ms in either direction if (MediaCore.State.HasVideo && speedRatio == 1.0 && isBeyondThreshold == false && Math.Abs(audioLatencyMs) > SyncThresholdPerfect) { var stepDurationMillis = Convert.ToInt32(Math.Min(SyncThresholdMaxStep, Math.Abs(audioLatencyMs))); var stepDurationBytes = WaveFormat.ConvertLatencyToByteSize(stepDurationMillis); if (audioLatencyMs > SyncThresholdPerfect) { AudioBuffer.Skip(Math.Min(stepDurationBytes, readableCount)); } else if (audioLatencyMs < -SyncThresholdPerfect) { AudioBuffer.Rewind(Math.Min(stepDurationBytes, rewindableCount)); } } return(true); }
public void ReceiveModelSetLatency(ModelSetLatency modelSetLatency) { element = modelSetLatency.val; }