mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
benchmark improvements
This commit is contained in:
parent
471dfbaf95
commit
54883e5787
@ -28,22 +28,24 @@ public static Bounds MinMax(float min, float max) =>
|
||||
// simple benchmark to compare some optimizations later.
|
||||
// 64 entries are much more than we would usually use.
|
||||
//
|
||||
// Unity 2021.3 LTS, release mode, 10_000 x 64:
|
||||
// native O(N) implementation: 4067 ms
|
||||
// Unity 2021.3 LTS, release mode, 10_000 x 64 x 8:
|
||||
// native O(N) implementation: 1005 ms
|
||||
[Test]
|
||||
[TestCase(10_000, 64)]
|
||||
public void Benchmark(int iterations, int entriesPerIteration)
|
||||
[TestCase(10_000, 64, 8)]
|
||||
public void Benchmark(int iterations, int insertions, int limit)
|
||||
{
|
||||
// insert 'entriesPerIteration' bounds 'iterations' times
|
||||
for (int i = 0; i < iterations; ++i)
|
||||
// repeat the test 'iterations' x times
|
||||
for (int iteration = 0; iteration < iterations; ++iteration)
|
||||
{
|
||||
// each test captures 'insertions' bounds,
|
||||
// with a history of 'limit' bounds.
|
||||
history.Clear();
|
||||
for (int j = 0; j < entriesPerIteration; ++j)
|
||||
for (int i = 0; i < insertions; ++i)
|
||||
{
|
||||
float min = Random.Range(-1, 1);
|
||||
float max = Random.Range(min, 1);
|
||||
Bounds bounds = MinMax(min, max);
|
||||
Bounds total = HistoryBounds.Insert(history, entriesPerIteration, bounds);
|
||||
Bounds total = HistoryBounds.Insert(history, limit, bounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user