From cfe0dc88c9d376df1b6728c41009efb8538bf615 Mon Sep 17 00:00:00 2001 From: 13xforever Date: Fri, 13 Nov 2020 19:59:34 +0500 Subject: [PATCH] update perf tests to use the same source for all formats --- CompatBot/Utils/BufferCopyStream.cs | 19 +++++-------------- Tests/LogParsingProfiler.cs | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/CompatBot/Utils/BufferCopyStream.cs b/CompatBot/Utils/BufferCopyStream.cs index e455a1f3..3e571654 100644 --- a/CompatBot/Utils/BufferCopyStream.cs +++ b/CompatBot/Utils/BufferCopyStream.cs @@ -31,10 +31,7 @@ namespace CompatBot.Utils readBuf = ArrayPool.Shared.Rent(16); } - public override void Flush() - { - baseStream.Flush(); - } + public override void Flush() => baseStream.Flush(); public override int Read(byte[] buffer, int offset, int count) { @@ -65,15 +62,9 @@ namespace CompatBot.Utils } } - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotImplementedException(); - } + public override long Seek(long offset, SeekOrigin origin) => throw new NotImplementedException(); - public override void SetLength(long value) - { - throw new NotImplementedException(); - } + public override void SetLength(long value) => throw new NotImplementedException(); public override void Write(byte[] buffer, int offset, int count) { @@ -98,7 +89,7 @@ namespace CompatBot.Utils disposed = true; } } - baseStream?.Dispose(); + baseStream.Dispose(); base.Dispose(disposing); } @@ -114,7 +105,7 @@ namespace CompatBot.Utils disposed = true; } } - baseStream?.Dispose(); + baseStream.Dispose(); base.Dispose(); } diff --git a/Tests/LogParsingProfiler.cs b/Tests/LogParsingProfiler.cs index de643fae..9d0f2d7e 100644 --- a/Tests/LogParsingProfiler.cs +++ b/Tests/LogParsingProfiler.cs @@ -1,4 +1,6 @@ using System; +using System.Diagnostics; +using System.IO; using System.IO.Pipelines; using System.Linq; using System.Threading; @@ -24,10 +26,16 @@ namespace Tests }; [Explicit("For performance profiling only")] - [TestCase(@"C:\Documents\Downloads\RPCS3(7).rar")] - [TestCase(@"C:\Documents\Downloads\RPCS3(208).log.gz")] + [TestCase(@"C:\Documents\Downloads\RPCS3_20.log", TestName = "Plaintext")] + [TestCase(@"C:\Documents\Downloads\RPCS3_20.log.gz", TestName = "gz")] + [TestCase(@"C:\Documents\Downloads\RPCS3_20.zip", TestName = "zip")] + [TestCase(@"C:\Documents\Downloads\RPCS3_20.rar", TestName = "rar")] + [TestCase(@"C:\Documents\Downloads\RPCS3_20.7z", TestName = "7z")] public async Task PerformanceTest(string path) { + Config.inMemorySettings[nameof(Config.AttachmentSizeLimit)] = int.MaxValue.ToString(); + Config.RebuildConfiguration(); + var timer = Stopwatch.StartNew(); var cts = new CancellationTokenSource(); var source = await FileSource.DetectArchiveHandlerAsync(path, archiveHandlers).ConfigureAwait(false); var pipe = new Pipe(); @@ -35,6 +43,8 @@ namespace Tests var readPipeTask = LogParser.ReadPipeAsync(pipe.Reader, cts.Token); var result = await readPipeTask.ConfigureAwait(false); await fillPipeTask.ConfigureAwait(false); + timer.Stop(); + Config.Log.Info($"Total time {Path.GetExtension(path)}: {timer.Elapsed.TotalSeconds}s"); result.TotalBytes = source.LogFileSize; #if DEBUG Config.Log.Debug("~~~~~~~~~~~~~~~~~~~~");