feature/72-channelselection-and-character-creation #82

Merged
rainote merged 35 commits from feature/72-channelselection-and-character-creation into master 2023-11-14 19:47:01 +00:00
2 changed files with 27 additions and 9 deletions
Showing only changes of commit 293b65a856 - Show all commits

View file

@ -10,16 +10,18 @@ public class BinaryConversionBenchmarks
{
private byte[] _data = null!;
private int _offset;
private int _writeBuffer;
[GlobalSetup]
public void Setup()
{
this._data = RandomNumberGenerator.GetBytes(4000);
this._offset = RandomNumberGenerator.GetInt32(0, 3500);
this._writeBuffer = RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);
}
[Benchmark]
public short BitConverterTest() => BitConverter.ToInt16(this._data, this._offset);
public short BitConverterParseTest() => BitConverter.ToInt16(this._data, this._offset);
[Benchmark]
public short BinaryReader()
@ -31,7 +33,30 @@ public class BinaryConversionBenchmarks
}
[Benchmark]
public short BinaryPrimitives() =>
public short BinaryPrimitivesRead() =>
System.Buffers.Binary.BinaryPrimitives.ReadInt16LittleEndian(
new ArraySegment<byte>(this._data, this._offset, sizeof(short)));
[Benchmark]
public void BinaryPrimitivesWrite()
{
System.Buffers.Binary.BinaryPrimitives.WriteInt32LittleEndian(this._data.AsSpan(_offset, 4),
this._writeBuffer);
}
[Benchmark]
public void BitConverterCopy()
{
BitConverter.GetBytes(this._writeBuffer).CopyTo(this._data, this._offset);
}
[Benchmark]
public void BitConverterAssignment()
{
var bytes = BitConverter.GetBytes(this._writeBuffer);
this._data[this._offset] = bytes[0];
this._data[this._offset + 1] = bytes[1];
this._data[this._offset + 2] = bytes[2];
this._data[this._offset + 3] = bytes[3];
}
}

View file

@ -27,12 +27,5 @@ public class GenericConfig : ManualConfig
.AddAnalyser(MinIterationTimeAnalyser.Default, OutliersAnalyser.Default,
RuntimeErrorAnalyser.Default, EnvironmentAnalyser.Default)
.AddColumn(RankColumn.Arabic).AddExporter(CsvExporter.Default, MarkdownExporter.Default);
AddJob(Job.Default
.WithRuntime(CoreRuntime.Core60))
.AddDiagnoser(ThreadingDiagnoser.Default, MemoryDiagnoser.Default,
EventPipeProfiler.Default)
.AddAnalyser(MinIterationTimeAnalyser.Default, OutliersAnalyser.Default,
RuntimeErrorAnalyser.Default, EnvironmentAnalyser.Default)
.AddColumn(RankColumn.Arabic).AddExporter(CsvExporter.Default, MarkdownExporter.Default);
}
}