Converts Item & Entity Packets (#326)
- [X] Converts World Item packets - [X] Converter Remove Entity packets - [X] Updates `LOSBlocker` and `Blocker` - [X] Fixes a few bugs - [X] Converts container packets Bumps release version
This commit is contained in:
parent
c41906d3c7
commit
77f665502b
26 changed files with 1351 additions and 1606 deletions
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.InteropServices;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using Server;
|
||||
|
|
@ -69,16 +68,14 @@ namespace Benchmarks
|
|||
return writer.Position;
|
||||
}
|
||||
|
||||
private Pipe<byte>[] _pipes = new Pipe<byte>[512];
|
||||
private IntPtr[] _pointers = new IntPtr[512];
|
||||
private Pipe<byte>[] _pipes = new Pipe<byte>[25000];
|
||||
|
||||
[IterationSetup]
|
||||
public void SetUp()
|
||||
{
|
||||
for (var i = 0; i < _pipes.Length; i++)
|
||||
{
|
||||
_pipes[i] = new Pipe<byte>(new byte[8192]);
|
||||
_pointers[i] = Marshal.AllocHGlobal(8192);
|
||||
_pipes[i] = new Pipe<byte>(new byte[4096]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -88,7 +85,6 @@ namespace Benchmarks
|
|||
for (var i = 0; i < _pipes.Length; i++)
|
||||
{
|
||||
_pipes[i] = null;
|
||||
Marshal.FreeHGlobal(_pointers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -151,30 +147,28 @@ namespace Benchmarks
|
|||
return _pipes.Length;
|
||||
}
|
||||
|
||||
private static void SendUnicodeMessageWithSpan(Pipe<byte> pipe, string text)
|
||||
{
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)];
|
||||
var length = CreateUnicodeMessage(
|
||||
ref buffer,
|
||||
Serial.MinusOne, -1, MessageType.Regular, 0x3B2, 3, "ENU", "System", text
|
||||
);
|
||||
|
||||
buffer = buffer.Slice(0, length);
|
||||
var result = pipe.Writer.TryGetMemory();
|
||||
result.CopyFrom(buffer);
|
||||
pipe.Writer.Advance((uint)buffer.Length);
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public int TestSpanWriterAllocH()
|
||||
public int TestSpanWriterLooped()
|
||||
{
|
||||
var text = "This is some really long text that we want to handle. It should take a little bit to encode this.";
|
||||
|
||||
foreach (var pointer in _pointers)
|
||||
foreach (var pipe in _pipes)
|
||||
{
|
||||
Span<byte> buffer;
|
||||
unsafe
|
||||
{
|
||||
buffer = new Span<byte>(pointer.ToPointer(), 8192);
|
||||
}
|
||||
|
||||
CreateUnicodeMessage(
|
||||
ref buffer,
|
||||
Serial.MinusOne,
|
||||
-1,
|
||||
MessageType.Regular,
|
||||
0x3B2,
|
||||
3,
|
||||
"ENU",
|
||||
"System",
|
||||
text
|
||||
);
|
||||
SendUnicodeMessageWithSpan(pipe, text);
|
||||
}
|
||||
|
||||
return _pipes.Length;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue