protected internal void WriteTo(ref Fragment fragment, ITextSink sink) { int run = fragment.head; if (run != fragment.tail) { int runOffset = fragment.headOffset; do { RunEntry runEntry = this.runList[run]; if (runEntry.Type == RunType.Normal) { sink.Write(this.buffer, runOffset, runEntry.Length); } else if (runEntry.Type == RunType.Literal) { sink.Write(runEntry.Value); } runOffset += runEntry.Length; }while (++run != fragment.tail && !sink.IsEnough); } }
protected internal void WriteTo(LexicalUnit unit, ITextSink sink) { int run = unit.head; if (run != -1) { int runOffset = unit.headOffset; RunEntry runEntry = this.runList[run]; uint kind = runEntry.MajorKind; do { if (runEntry.Type == RunType.Normal) { sink.Write(this.buffer, runOffset, runEntry.Length); } else if (runEntry.Type == RunType.Literal) { sink.Write(runEntry.Value); } runOffset += runEntry.Length; runEntry = this.runList[++run]; }while (runEntry.MajorKindPlusStartFlag == kind && !sink.IsEnough); } }
protected internal int CalculateHashLowerCase(Fragment fragment) { int num = fragment.head; if (num == fragment.tail) { return(HashCode.CalculateEmptyHash()); } int num2 = fragment.headOffset; if (num + 1 == fragment.tail && runList[num].Type == (RunType)2147483648u) { return(HashCode.CalculateLowerCase(buffer, num2, runList[num].Length)); } HashCode hashCode = new HashCode(true); do { RunEntry runEntry = runList[num]; if (runEntry.Type == (RunType)2147483648u) { hashCode.AdvanceLowerCase(buffer, num2, runEntry.Length); } else if (runEntry.Type == (RunType)3221225472u) { hashCode.AdvanceLowerCase(runEntry.Value); } num2 += runEntry.Length; }while (++num != fragment.tail); return(hashCode.FinalizeHash()); }
protected internal int GetLength(LexicalUnit unit) { int run = unit.head; int length = 0; if (run != -1) { RunEntry runEntry = this.runList[run]; uint kind = runEntry.MajorKind; do { if (runEntry.Type == RunType.Normal) { length += runEntry.Length; } else if (runEntry.Type == RunType.Literal) { length += Token.LiteralLength(runEntry.Value); } runEntry = this.runList[++run]; }while (runEntry.MajorKindPlusStartFlag == kind); } return(length); }
protected internal int CalculateHashLowerCase(LexicalUnit unit) { int num = unit.head; if (num == -1) { return(HashCode.CalculateEmptyHash()); } int num2 = unit.headOffset; RunEntry runEntry = runList[num]; uint majorKind = runEntry.MajorKind; if (runEntry.Type == (RunType)2147483648u && majorKind != runList[num + 1].MajorKindPlusStartFlag) { return(HashCode.CalculateLowerCase(buffer, num2, runEntry.Length)); } HashCode hashCode = new HashCode(true); do { if (runEntry.Type == (RunType)2147483648u) { hashCode.AdvanceLowerCase(buffer, num2, runEntry.Length); } else if (runEntry.Type == (RunType)3221225472u) { hashCode.AdvanceLowerCase(runEntry.Value); } num2 += runEntry.Length; runEntry = runList[++num]; }while (runEntry.MajorKindPlusStartFlag == majorKind); return(hashCode.FinalizeHash()); }
public void AddRun(TestCase testCase, Benchmark benchmark, string text) { if (string.IsNullOrEmpty(text)) return; var runEntry = new RunEntry() { TestCase = testCase, Benchmark = benchmark, RawLog = text }; RunEntries.Add(runEntry); ParseInfolog(text, runEntry); if (testCase.BenchmarkArg > 0) ParseBenchmarkData(runEntry); }
protected internal bool SkipLeadingWhitespace(LexicalUnit unit, ref FragmentPosition position) { int num = unit.head; if (num != -1) { int num2 = unit.headOffset; RunEntry runEntry = runList[num]; uint majorKind = runEntry.MajorKind; int runDeltaOffset = 0; int i; do { if (runEntry.Type == (RunType)3221225472u) { if (runEntry.Value > 65535) { break; } CharClass charClass = ParseSupport.GetCharClass((char)runEntry.Value); if (!ParseSupport.WhitespaceCharacter(charClass)) { break; } } else if (runEntry.Type == (RunType)2147483648u) { for (i = num2; i < num2 + runEntry.Length; i++) { CharClass charClass = ParseSupport.GetCharClass(buffer[i]); if (!ParseSupport.WhitespaceCharacter(charClass)) { break; } } if (i < num2 + runEntry.Length) { goto Block_7; } } num2 += runEntry.Length; runEntry = runList[++num]; }while (runEntry.MajorKindPlusStartFlag == majorKind); goto IL_EF; Block_7: runDeltaOffset = i - num2; IL_EF: position.run = num; position.runOffset = num2; position.runDeltaOffset = runDeltaOffset; if (num == unit.head || runEntry.MajorKindPlusStartFlag == majorKind) { return(true); } } return(false); }
static void ParseInfolog(string text, RunEntry runEntry) { string gameId = null; foreach (var cycleline in text.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)) { var line = cycleline; var gameframe = 0; if (line.StartsWith("[f=")) { var idx = line.IndexOf("] "); if (idx > 0) { int.TryParse(line.Substring(3, idx - 3), out gameframe); if (idx >= 0) { line = line.Substring(idx + 2); } } } if (gameId != null) { var match = Regex.Match(line, "!transmitlobby (.+):[ ]*([0-9.]+)"); if (match.Success) { var key = match.Groups[1].Value.Trim(); var value = match.Groups[2].Value.Trim(); var valNum = 0.0; if (!invalidKeys.Contains(key) && !key.Contains(":")) { if (double.TryParse(value, out valNum)) { runEntry.RawValues.Add(new ValueEntry() { GameFrame = gameframe, Key = key, Value = valNum }); } } } } if (line.StartsWith("GameID: ") && gameId == null) { gameId = line.Substring(8).Trim(); } } }
protected internal void WriteOriginalTo(ref Fragment fragment, ITextSink sink) { int num = fragment.head; if (num != fragment.tail) { int num2 = fragment.headOffset; do { RunEntry runEntry = runList[num]; if (runEntry.Type == (RunType)2147483648u || runEntry.Type == (RunType)3221225472u) { sink.Write(buffer, num2, runEntry.Length); } num2 += runEntry.Length; }while (++num != fragment.tail && !sink.IsEnough); } }
public void AddRun(TestCase testCase, Benchmark benchmark, string text) { if (string.IsNullOrEmpty(text)) { return; } var runEntry = new RunEntry() { TestCase = testCase, Benchmark = benchmark, RawLog = text }; RunEntries.Add(runEntry); ParseInfolog(text, runEntry); if (testCase.BenchmarkArg > 0) { ParseBenchmarkData(runEntry); } }
protected internal bool IsFragmentEmpty(ref Fragment fragment) { int run = fragment.head; if (run != fragment.tail) { do { RunEntry runEntry = this.runList[run]; if (runEntry.Type == RunType.Normal || runEntry.Type == RunType.Literal) { InternalDebug.Assert(0 != runEntry.Length); return(false); } }while (++run != fragment.tail); } return(true); }
protected internal bool IsFragmentEmpty(LexicalUnit unit) { int num = unit.head; if (num != -1) { RunEntry runEntry = runList[num]; uint majorKind = runEntry.MajorKind; while (runEntry.Type != (RunType)2147483648u && runEntry.Type != (RunType)3221225472u) { runEntry = runList[++num]; if (runEntry.MajorKindPlusStartFlag != majorKind) { return(true); } } return(false); } return(true); }
protected internal bool IsFragmentEmpty(ref Fragment fragment) { int num = fragment.head; if (num != fragment.tail) { while (true) { RunEntry runEntry = runList[num]; if (runEntry.Type == (RunType)2147483648u || runEntry.Type == (RunType)3221225472u) { break; } if (++num == fragment.tail) { return(true); } } return(false); } return(true); }
protected internal int GetLength(ref Fragment fragment) { int num = fragment.head; int num2 = 0; if (num != fragment.tail) { do { RunEntry runEntry = runList[num]; if (runEntry.Type == (RunType)2147483648u) { num2 += runEntry.Length; } else if (runEntry.Type == (RunType)3221225472u) { num2 += LiteralLength(runEntry.Value); } }while (++num != fragment.tail); } return(num2); }
protected internal int CalculateHashLowerCase(LexicalUnit unit) { int run = unit.head; if (run != -1) { int runOffset = unit.headOffset; RunEntry runEntry = this.runList[run]; uint kind = runEntry.MajorKind; if (runEntry.Type == RunType.Normal && kind != this.runList[run + 1].MajorKindPlusStartFlag) { return(HashCode.CalculateLowerCase(this.buffer, runOffset, runEntry.Length)); } HashCode hashCode = new HashCode(true); do { if (runEntry.Type == RunType.Normal) { hashCode.AdvanceLowerCase(this.buffer, runOffset, runEntry.Length); } else if (runEntry.Type == RunType.Literal) { hashCode.AdvanceLowerCase(runEntry.Value); } runOffset += runEntry.Length; runEntry = this.runList[++run]; }while (runEntry.MajorKindPlusStartFlag == kind); return(hashCode.FinalizeHash()); } return(HashCode.CalculateEmptyHash()); }
protected internal bool IsFragmentEmpty(LexicalUnit unit) { int run = unit.head; if (run != -1) { RunEntry runEntry = this.runList[run]; uint kind = runEntry.MajorKind; do { if (runEntry.Type == RunType.Normal || runEntry.Type == RunType.Literal) { InternalDebug.Assert(0 != runEntry.Length); return(false); } runEntry = this.runList[++run]; }while (runEntry.MajorKindPlusStartFlag == kind); } return(true); }
void ParseBenchmarkData(RunEntry runEntry) { var path = Path.Combine(runEntry.TestCase.Config.ConfigPath, "benchmark.data"); if (File.Exists(path)) { var data = File.ReadAllLines(path); var headers = data.First().Split(' ').Skip(1).ToList(); foreach (var line in data.Skip(1)) { var lineData = line.Split(' ').ToList(); var gameFrame = double.Parse(lineData[0]); for (var i = 1; i < lineData.Count; i++) { runEntry.RawValues.Add(new ValueEntry() { GameFrame = gameFrame, Key = headers[i], Value = double.Parse(lineData[i]) }); } } } }
protected internal void WriteTo(LexicalUnit unit, ITextSink sink) { int num = unit.head; if (num != -1) { int num2 = unit.headOffset; RunEntry runEntry = runList[num]; uint majorKind = runEntry.MajorKind; do { if (runEntry.Type == (RunType)2147483648u) { sink.Write(buffer, num2, runEntry.Length); } else if (runEntry.Type == (RunType)3221225472u) { sink.Write(runEntry.Value); } num2 += runEntry.Length; runEntry = runList[++num]; }while (runEntry.MajorKindPlusStartFlag == majorKind && !sink.IsEnough); } }
protected internal int GetLength(LexicalUnit unit) { int num = unit.head; int num2 = 0; if (num != -1) { RunEntry runEntry = runList[num]; uint majorKind = runEntry.MajorKind; do { if (runEntry.Type == (RunType)2147483648u) { num2 += runEntry.Length; } else if (runEntry.Type == (RunType)3221225472u) { num2 += LiteralLength(runEntry.Value); } runEntry = runList[++num]; }while (runEntry.MajorKindPlusStartFlag == majorKind); } return(num2); }
protected internal void WriteEscapedOriginalTo(ref Fragment fragment, ITextSink sink) { int run = fragment.head; if (run != fragment.tail) { int runOffset = fragment.headOffset; do { RunEntry runEntry = this.runList[run]; if (runEntry.Type == RunType.Normal || runEntry.Type == RunType.Literal) { this.EscapeAndWriteBuffer( this.buffer, runOffset, runEntry.Length, sink); } runOffset += runEntry.Length; }while (++run != fragment.tail && !sink.IsEnough); } }
protected internal int CalculateHashLowerCase(Fragment fragment) { int run = fragment.head; if (run != fragment.tail) { int runOffset = fragment.headOffset; if (run + 1 == fragment.tail && this.runList[run].Type == RunType.Normal) { return(HashCode.CalculateLowerCase(this.buffer, runOffset, this.runList[run].Length)); } HashCode hashCode = new HashCode(true); do { RunEntry runEntry = this.runList[run]; if (runEntry.Type == RunType.Normal) { hashCode.AdvanceLowerCase(this.buffer, runOffset, runEntry.Length); } else if (runEntry.Type == RunType.Literal) { hashCode.AdvanceLowerCase(runEntry.Value); } runOffset += runEntry.Length; }while (++run != fragment.tail); return(hashCode.FinalizeHash()); } return(HashCode.CalculateEmptyHash()); }
protected internal int GetLength(ref Fragment fragment) { int run = fragment.head; int length = 0; if (run != fragment.tail) { do { RunEntry runEntry = this.runList[run]; if (runEntry.Type == RunType.Normal) { length += runEntry.Length; } else if (runEntry.Type == RunType.Literal) { length += Token.LiteralLength(runEntry.Value); } }while (++run != fragment.tail); } return(length); }
protected internal int Read(LexicalUnit unit, ref FragmentPosition position, char[] buffer, int offset, int count) { int num = offset; if (unit.head != -1) { uint majorKind = runList[unit.head].MajorKind; int num2 = position.run; if (num2 == unit.head - 1) { num2 = (position.run = unit.head); } RunEntry runEntry = runList[num2]; if (num2 == unit.head || runEntry.MajorKindPlusStartFlag == majorKind) { int num3 = position.runOffset; int num4 = position.runDeltaOffset; int num6; while (true) { if (runEntry.Type == (RunType)3221225472u) { int num5 = LiteralLength(runEntry.Value); if (num4 != num5) { if (num5 == 1) { buffer[offset++] = (char)runEntry.Value; count--; } else if (num4 != 0) { buffer[offset++] = LiteralLastChar(runEntry.Value); count--; } else { buffer[offset++] = LiteralFirstChar(runEntry.Value); count--; if (count == 0) { break; } buffer[offset++] = LiteralLastChar(runEntry.Value); count--; } } } else if (runEntry.Type == (RunType)2147483648u) { num6 = Math.Min(count, runEntry.Length - num4); Buffer.BlockCopy(this.buffer, (num3 + num4) * 2, buffer, offset * 2, num6 * 2); offset += num6; count -= num6; if (num4 + num6 != runEntry.Length) { goto Block_10; } } num3 += runEntry.Length; num4 = 0; runEntry = runList[++num2]; if (runEntry.MajorKindPlusStartFlag != majorKind || count == 0) { goto IL_1CF; } } num4 = 1; goto IL_1CF; Block_10: num4 += num6; IL_1CF: position.run = num2; position.runOffset = num3; position.runDeltaOffset = num4; } } return(offset - num); }
static void ParseInfolog(string text, RunEntry runEntry) { string gameId = null; foreach (var cycleline in text.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)) { var line = cycleline; var gameframe = 0; if (line.StartsWith("[f=")) { var idx = line.IndexOf("] "); if (idx > 0) { int.TryParse(line.Substring(3, idx - 3), out gameframe); if (idx >= 0) line = line.Substring(idx + 2); } } if (gameId != null) { var match = Regex.Match(line, "!transmitlobby (.+):[ ]*([0-9.]+)"); if (match.Success) { var key = match.Groups[1].Value.Trim(); var value = match.Groups[2].Value.Trim(); var valNum = 0.0; if (!invalidKeys.Contains(key) && !key.Contains(":")) if (double.TryParse(value, out valNum)) runEntry.RawValues.Add(new ValueEntry() { GameFrame = gameframe, Key = key, Value = valNum }); } } if (line.StartsWith("GameID: ") && gameId == null) gameId = line.Substring(8).Trim(); } }
protected internal bool SkipLeadingWhitespace(LexicalUnit unit, ref FragmentPosition position) { int run = unit.head; if (run != -1) { int runOffset = unit.headOffset; CharClass charClass; RunEntry runEntry = this.runList[run]; uint kind = runEntry.MajorKind; int deltaOffset = 0; do { if (runEntry.Type == RunType.Literal) { if (runEntry.Value > 0xFFFF) { break; } charClass = ParseSupport.GetCharClass((char)runEntry.Value); if (!ParseSupport.WhitespaceCharacter(charClass)) { break; } } else if (runEntry.Type == RunType.Normal) { int offset = runOffset; while (offset < runOffset + runEntry.Length) { charClass = ParseSupport.GetCharClass(this.buffer[offset]); if (!ParseSupport.WhitespaceCharacter(charClass)) { break; } offset++; } if (offset < runOffset + runEntry.Length) { deltaOffset = offset - runOffset; break; } } runOffset += runEntry.Length; runEntry = this.runList[++run]; }while (runEntry.MajorKindPlusStartFlag == kind); position.run = run; position.runOffset = runOffset; position.runDeltaOffset = deltaOffset; if (run == unit.head || runEntry.MajorKindPlusStartFlag == kind) { return(true); } } return(false); }
void ParseBenchmarkData(RunEntry runEntry) { var path = Path.Combine(runEntry.TestCase.Config.ConfigPath, "benchmark.data"); if (File.Exists(path)) { var data = File.ReadAllLines(path); var headers = data.First().Split(' ').Skip(1).ToList(); foreach (var line in data.Skip(1)) { var lineData = line.Split(' ').ToList(); var gameFrame = double.Parse(lineData[0]); for (var i = 1; i < lineData.Count; i++) runEntry.RawValues.Add(new ValueEntry() { GameFrame = gameFrame, Key = headers[i], Value = double.Parse(lineData[i]) }); } } }
protected internal int Read(LexicalUnit unit, ref FragmentPosition position, char[] buffer, int offset, int count) { InternalDebug.Assert(count != 0); int startOffset = offset; if (unit.head != -1) { uint kind = this.runList[unit.head].MajorKind; int run = position.run; if (run == unit.head - 1) { run = position.run = unit.head; } RunEntry runEntry = this.runList[run]; if (run == unit.head || runEntry.MajorKindPlusStartFlag == kind) { int runOffset = position.runOffset; int runDeltaOffset = position.runDeltaOffset; do { InternalDebug.Assert(count != 0); if (runEntry.Type == RunType.Literal) { int literalLength = Token.LiteralLength(runEntry.Value); if (runDeltaOffset != literalLength) { if (literalLength == 1) { InternalDebug.Assert(runDeltaOffset == 0); buffer[offset++] = (char)runEntry.Value; count--; } else { InternalDebug.Assert(literalLength == 2); if (runDeltaOffset != 0) { InternalDebug.Assert(runDeltaOffset == 1); buffer[offset++] = Token.LiteralLastChar(runEntry.Value); count--; } else { buffer[offset++] = Token.LiteralFirstChar(runEntry.Value); count--; if (count == 0) { runDeltaOffset = 1; break; } buffer[offset++] = Token.LiteralLastChar(runEntry.Value); count--; } } } } else if (runEntry.Type == RunType.Normal) { InternalDebug.Assert(runDeltaOffset >= 0 && runDeltaOffset < runEntry.Length); int copyCount = Math.Min(count, runEntry.Length - runDeltaOffset); InternalDebug.Assert(copyCount != 0); { Buffer.BlockCopy(this.buffer, (runOffset + runDeltaOffset) * 2, buffer, offset * 2, copyCount * 2); offset += copyCount; count -= copyCount; if (runDeltaOffset + copyCount != runEntry.Length) { runDeltaOffset += copyCount; break; } } } runOffset += runEntry.Length; runDeltaOffset = 0; runEntry = this.runList[++run]; }while (runEntry.MajorKindPlusStartFlag == kind && count != 0); position.run = run; position.runOffset = runOffset; position.runDeltaOffset = runDeltaOffset; } } return(offset - startOffset); }