Adds back in old benchmarks. Cleans up tests. (#270)
This commit is contained in:
parent
09d80916b8
commit
4e799ddbd7
29 changed files with 498 additions and 160 deletions
36
Projects/Benchmarks/Packets/SpanWriter.cs
Normal file
36
Projects/Benchmarks/Packets/SpanWriter.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using System.Buffers.Binary;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Server;
|
||||
|
||||
namespace Benchmarks
|
||||
{
|
||||
public ref struct SpanWriter
|
||||
{
|
||||
public Span<byte> Span;
|
||||
public int Pos;
|
||||
|
||||
public SpanWriter(Span<byte> span)
|
||||
{
|
||||
Span = span;
|
||||
Pos = 0;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Write(Serial serial)
|
||||
{
|
||||
BinaryPrimitives.WriteUInt32BigEndian(Span.Slice(Pos), serial);
|
||||
Pos += 4;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Write(ushort value)
|
||||
{
|
||||
BinaryPrimitives.WriteUInt16BigEndian(Span.Slice(Pos), value);
|
||||
Pos += 2;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Write(byte value) => Span[Pos++] = value;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue