Skip to content

Commit 482bd26

Browse files
committed
data benchmark
1 parent ac87583 commit 482bd26

8 files changed

Lines changed: 828 additions & 119 deletions

File tree

Assets/Mirror/Examples/DataBenchmark.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.Security.Cryptography;
5+
using UnityEngine;
6+
namespace Mirror.Examples.DataBenchmark
7+
{
8+
public class BenchmarkSender : NetworkBehaviour
9+
{
10+
11+
public int DataSize = 256;
12+
public int SendsPerFrame = 100;
13+
[ReadOnly]
14+
public int DataPerFrame;
15+
16+
public bool Reliable = true;
17+
private byte[] data;
18+
private void Awake()
19+
{
20+
data = new byte[DataSize];
21+
22+
using (RandomNumberGenerator rng = RandomNumberGenerator.Create())
23+
{
24+
rng.GetBytes(data);
25+
}
26+
}
27+
// Start is called before the first frame update
28+
void Start()
29+
{
30+
31+
}
32+
33+
// Update is called once per frame
34+
void Update()
35+
{
36+
if (!NetworkServer.active)
37+
{
38+
return;
39+
}
40+
for (int i = 0; i < SendsPerFrame; i++)
41+
{
42+
if (Reliable)
43+
{
44+
RpcSendReliable(new ArraySegment<byte>(data));
45+
}
46+
else
47+
{
48+
RpcSendUnreliable(new ArraySegment<byte>(data));
49+
}
50+
}
51+
}
52+
53+
54+
[ClientRpc(channel = Channels.Reliable)]
55+
void RpcSendReliable(ArraySegment<byte> data)
56+
{
57+
58+
}
59+
60+
[ClientRpc(channel = Channels.Unreliable)]
61+
void RpcSendUnreliable(ArraySegment<byte> data)
62+
{
63+
64+
}
65+
66+
protected override void OnValidate()
67+
{
68+
base.OnValidate();
69+
DataPerFrame = DataSize * SendsPerFrame;
70+
}
71+
}
72+
}

Assets/Mirror/Examples/DataBenchmark/BenchmarkSender.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)