Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Assets/Mirror/Examples/DataBenchmark.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions Assets/Mirror/Examples/DataBenchmark/BenchmarkSender.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using UnityEngine;
namespace Mirror.Examples.DataBenchmark
{
public class BenchmarkSender : NetworkBehaviour
{

public int DataSize = 256;
public int SendsPerFrame = 100;
[ReadOnly]
public int DataPerFrame;

public bool Reliable = true;
private byte[] data;
private void Awake()
{
data = new byte[DataSize];

using (RandomNumberGenerator rng = RandomNumberGenerator.Create())
{
rng.GetBytes(data);
}
}
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
if (!NetworkServer.active)
{
return;
}
for (int i = 0; i < SendsPerFrame; i++)
{
if (Reliable)
{
RpcSendReliable(new ArraySegment<byte>(data));
}
else
{
RpcSendUnreliable(new ArraySegment<byte>(data));
}
}
}


[ClientRpc(channel = Channels.Reliable)]
void RpcSendReliable(ArraySegment<byte> data)
{

}

[ClientRpc(channel = Channels.Unreliable)]
void RpcSendUnreliable(ArraySegment<byte> data)
{

}

protected override void OnValidate()
{
base.OnValidate();
DataPerFrame = DataSize * SendsPerFrame;
}
}
}
11 changes: 11 additions & 0 deletions Assets/Mirror/Examples/DataBenchmark/BenchmarkSender.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading