public void Pack_Allocate() { for (int i = 0; i < 10000; i++) { if (cryptoChannelStore.TryGetChannel("Benchmark", out CryptoDtoChannel channel)) { var packetBytes = serializer.Pack(channel, CryptoDtoMode.ChaCha20Poly1305, typeNameBytes, dtoBytes); } } }
public void Setup() { cryptoChannelStore = new CryptoDtoChannelStore(); cryptoChannelStore.CreateChannel("Benchmark"); var dto = new BenchmarkDto() { Callsign = "Benchmark", SequenceCounter = 0, Audio = new byte[200], LastPacket = false }; Random rnd = new Random(); rnd.NextBytes(dto.Audio); MemoryStream ms = new MemoryStream(); MessagePackSerializer.Serialize(ms, dto); cryptoChannelStore.TryGetChannel("Benchmark", out var channel); var config = channel.GetRemoteEndpointChannelConfig(); remoteChannel = new CryptoDtoChannel(config); cryptoDtoPacket = serializer.Serialize(cryptoChannelStore, "Benchmark", CryptoDtoMode.ChaCha20Poly1305, dto); }