protected override Log GetLog() { if (processedLog == null) { var parser = new EVTCParser(); var processor = new LogProcessor(); var parsedLog = parser.ParseLog(filename); processedLog = processor.GetProcessedLog(parsedLog); } return(processedLog); }
protected override Log GetLog() { byte[] bytes; using (var memoryStream = new MemoryStream()) { stream.CopyTo(memoryStream); bytes = memoryStream.ToArray(); } if (processedLog == null) { var parser = new EVTCParser(); var processor = new LogProcessor(); var parsedLog = parser.ParseLog(bytes); processedLog = processor.GetProcessedLog(parsedLog); } return(processedLog); }
private static void MeasureTimes(string filename, EVTCParser parser, LogProcessor processor, LogAnalyser analyser, GW2ApiData apiData, TextWriter outputWriter) { var stopwatch = Stopwatch.StartNew(); var log = parser.ParseLog(filename); var parsedTime = stopwatch.Elapsed; stopwatch.Restart(); var processedLog = processor.GetProcessedLog(log); var processedTime = stopwatch.Elapsed; stopwatch.Restart(); var statistics = analyser.GetStatistics(processedLog, apiData); var statisticsTime = stopwatch.Elapsed; var totalTime = parsedTime + processedTime + statisticsTime; outputWriter.WriteLine( $"{filename},{parsedTime.TotalMilliseconds},{processedTime.TotalMilliseconds},{statisticsTime.TotalMilliseconds},{totalTime.TotalMilliseconds}"); outputWriter.Flush(); }
} = null; // TODO: Add support public MakerForm() { Title = "Scratch HTML log maker"; ClientSize = new Size(800, 600); var formLayout = new DynamicLayout(); Content = formLayout; var openFileDialog = new OpenFileDialog { MultiSelect = true }; openFileDialog.Filters.Add(new FileFilter("EVTC logs", ".evtc", ".evtc.zip", ".zevtc")); var openFilesButton = new Button { Text = "Select EVTC logs" }; var processButton = new Button { Text = "Create HTML logs" }; var notDoneListBox = new ListBox(); var doneListBox = new ListBox(); doneListBox.DataStore = finishedFileNames.ToArray(); var splitter = new Splitter { Panel1 = notDoneListBox, Panel2 = doneListBox, Position = 400 }; formLayout.BeginVertical(spacing: new Size(10, 10)); formLayout.AddRow(openFilesButton, processButton); formLayout.EndVertical(); formLayout.BeginVertical(); formLayout.Add(splitter); formLayout.EndVertical(); openFilesButton.Click += (sender, args) => { if (openFileDialog.ShowDialog((Control)sender) == DialogResult.Ok) { foreach (var file in openFileDialog.Filenames) { notFinishedFileNames.Enqueue(file); } notDoneListBox.DataStore = notFinishedFileNames.Select(Path.GetFileName).ToArray(); } }; processButton.Click += (sender, args) => { Task.Run(() => { var times = new List <(string taskName, double milliseconds)>(); var totalTimeStopwatch = Stopwatch.StartNew(); var parser = new EVTCParser(); var processor = new LogProcessor(); var analysis = new LogAnalyser(); var generator = new HtmlGenerator(ApiData); int finishedTaskCount = 0; while (notFinishedFileNames.Count > 0) { var taskStopwatch = Stopwatch.StartNew(); string filename = ""; filename = notFinishedFileNames.Dequeue(); var fileDirectory = Path.GetDirectoryName(filename); var newName = Path.GetFileNameWithoutExtension(filename); if (newName.EndsWith(".evtc")) { newName = newName.Substring(0, newName.Length - 5); } var resultFilename = Path.Combine(fileDirectory, ResultFilePrefix + newName + ".html"); try { var lastElapsed = taskStopwatch.Elapsed; var parsedLog = parser.ParseLog(filename); times.Add(("parsing", (taskStopwatch.Elapsed - lastElapsed).TotalMilliseconds)); lastElapsed = taskStopwatch.Elapsed; var processedLog = processor.GetProcessedLog(parsedLog); times.Add(("processing", (taskStopwatch.Elapsed - lastElapsed).TotalMilliseconds)); lastElapsed = taskStopwatch.Elapsed; var stats = analysis.GetStatistics(processedLog, ApiData); times.Add(("stats", (taskStopwatch.Elapsed - lastElapsed).TotalMilliseconds)); lastElapsed = taskStopwatch.Elapsed; using (var htmlStringWriter = new StreamWriter(resultFilename)) { generator.WriteHtml(htmlStringWriter, stats); } times.Add(("html", (taskStopwatch.Elapsed - lastElapsed).TotalMilliseconds)); lastElapsed = taskStopwatch.Elapsed; finishedFileNames.Add(resultFilename); Application.Instance.Invoke(() => { notDoneListBox.DataStore = notFinishedFileNames.Select(Path.GetFileName).ToArray(); doneListBox.DataStore = finishedFileNames.Select(Path.GetFileName).ToArray(); }); } catch (Exception e) { finishedFileNames.Add($"FAILED: {resultFilename} ({e.Message})"); Application.Instance.Invoke(() => { notDoneListBox.DataStore = notFinishedFileNames.Select(Path.GetFileName).ToArray(); doneListBox.DataStore = finishedFileNames.Select(Path.GetFileName).ToArray(); }); } Console.WriteLine($"{newName} done, time {taskStopwatch.Elapsed}"); finishedTaskCount++; } Console.WriteLine($"All done, total time {totalTimeStopwatch.Elapsed}"); foreach ((string taskName, double totalMs) in times.GroupBy(x => x.taskName).Select(x => (x.Key, x.Sum(y => y.milliseconds))).OrderByDescending(x => x.Item2)) { Console.WriteLine($"{taskName}, total {totalMs}ms, average {totalMs/Math.Max(finishedTaskCount, 1)}ms"); } }); }; }