update perf tests to use the same source for all formats

This commit is contained in:
13xforever
2020-11-13 19:59:34 +05:00
parent 6e903a5a7c
commit cfe0dc88c9
2 changed files with 17 additions and 16 deletions

View File

@@ -31,10 +31,7 @@ namespace CompatBot.Utils
readBuf = ArrayPool<byte>.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();
}

View File

@@ -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("~~~~~~~~~~~~~~~~~~~~");