public string Compare(BenchmarkResult other) { if (other == null) { return(string.Empty); } string compare = string.Format("Compare to {2}-test from {0} with {1} runs\r\n", other.TestDate, other.TestRuns, other.Tag); if (TestCode == other.TestCode) { compare += string.Format("Same syntax tree. Number of combinations: {0}\r\n", Combi); } else if (Combi == other.Combi) { compare += string.Format("Different tree! same number of combinations: {0}\r\n", Combi); } else { compare += string.Format("Different tree! Combinations: {0} vs {1}. Scale: {2}\r\n", Combi, other.Combi, other.Combi / Combi); } compare += "\r\n"; int pad = 10; compare += string.Format("---Time-ms---|-{0}-|-{1}-|\r\n", Tag.PadLeft(pad, '-'), other.Tag.PadLeft(pad, '-')); compare += string.Format("---Parse ----|-{0}-|-{1}-|\r\n", TimeParse.ToString().PadLeft(pad), other.TimeParse.ToString().PadLeft(pad)); compare += string.Format("---Query ----|-{0}-|-{1}-|\r\n", TimeQuery.ToString().PadLeft(pad), other.TimeQuery.ToString().PadLeft(pad)); compare += "\r\n"; compare += string.Format("---Memory-kb-|-{0}-|-{1}-|\r\n", Tag.PadLeft(pad, '-'), other.Tag.PadLeft(pad, '-')); compare += string.Format("---Parse ----|-{0}-|-{1}-|\r\n", MemParse.ToString().PadLeft(pad), other.MemParse.ToString().PadLeft(pad)); return(compare); }
public IActionResult Get(string zoneId = null) { var utcTime = DateTime.UtcNow; var serverTime = DateTime.Now; TimeZoneInfo timeZoneInfo = string.IsNullOrEmpty(zoneId) ? null : TimeZoneInfo.FindSystemTimeZoneById(zoneId); var requestedTimeZone = timeZoneInfo; var ip = this.HttpContext.Connection.RemoteIpAddress.ToString(); var returnVal = GetReturnVal(zoneId, utcTime, serverTime, requestedTimeZone, ip); //List<string> TimeQuery = new List<string>(); using (var db = new ClockworkContext()) { db.CurrentTimeQueries.Add(returnVal); var count = db.SaveChanges(); Console.WriteLine("{0} records saved to database", count); Console.WriteLine(); foreach (var CurrentTimeQuery in db.CurrentTimeQueries) { Console.WriteLine($" - {CurrentTimeQuery.UTCTime}"); TimeQuery.Add(CurrentTimeQuery.UTCTime.ToString()); } } return(Ok(returnVal)); }
public static async Task AlignTimeAsync() { long currentTime = Util.GetSystemUnixTime(); WebClient client = new WebClient(); try { string response = await client.UploadStringTaskAsync(new Uri(APIEndpoints.TWO_FACTOR_TIME_QUERY), "steamid=0"); TimeQuery query = JsonConvert.DeserializeObject <TimeQuery>(response); TimeAligner._timeDifference = (int)(query.Response.ServerTime - currentTime); TimeAligner._aligned = true; } catch (WebException) { return; } }
private static void SyncTime() { long currentTime = GetSystemUnixTime(); using (WebClient client = new WebClient()) { try { string response = client.UploadString(SteamAPIEndpoints.TWO_FACTOR_TIME_QUERY, "steamid=0"); TimeQuery query = JsonConvert.DeserializeObject <TimeQuery>(response); timeDifference = (int)(query.Response.ServerTime - currentTime); inSync = true; } catch (WebException) { return; } } }
public static void AlignTime() { long currentTime = GetSystemUnixTime(); using (WebClient client = new WebClient()) { try { string response = client.UploadString("https://api.steampowered.com/ITwoFactorService/QueryTime/v0001", "steamid=0"); TimeQuery query = JsonConvert.DeserializeObject <TimeQuery>(response); _timeDifference = (int)(query.Response.ServerTime - currentTime); _aligned = true; } catch (WebException) { return; } } }
// Determine the type of message and return an appropriate object // base on a variety of metrics public static Message createMessage(string text) { Message message = null; string commandType = getCommandType(text); if (text.StartsWith(Command.getKeyword())) { message = new Command(text); } else if (text.StartsWith(Status.getKeyword())) { message = new Status(text); } else if (text.StartsWith(Ok.getKeyword())) { message = new Ok(text); } else if (text.StartsWith(Error.getKeyword())) { message = new Error(text); } else if (text.StartsWith(BatteryQuery.getKeyword())) { message = new BatteryQuery(text); } else if (text.StartsWith(SpeedQuery.getKeyword())) { message = new SpeedQuery(text); } else if (text.StartsWith(TimeQuery.getKeyword())) { message = new TimeQuery(text); } else if (text.StartsWith(Curve.getKeyword())) { message = new Curve(text); } else if (text.StartsWith(Flip.getKeyword())) { message = new Flip(text); } else if (text.StartsWith(Go.getKeyword())) { message = new Go(text); } else if (text.StartsWith(Jump.getKeyword())) { message = new Jump(text); } else if (text.StartsWith(Land.getKeyword())) { message = new Land(text); } else if (text.StartsWith(Takeoff.getKeyword())) { message = new Takeoff(text); } else if (Rotate.getKeywords().Any(keyword => text.StartsWith(keyword))) { message = new Rotate(text); } else if (DirectionalMove.getKeywords().Any(keyword => text.StartsWith(keyword))) { message = new DirectionalMove(text); } else { message = new DataResponse(text); } return(message); }