tests
This commit is contained in:
74
Tests/MapParser/MapParserTests.cs
Normal file
74
Tests/MapParser/MapParserTests.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
using Cabrito;
|
||||
using FlaxEngine;
|
||||
using Game;
|
||||
|
||||
namespace GoakeTests.MapParser
|
||||
{
|
||||
public class MapParserTests
|
||||
{
|
||||
private byte[] aerowalkBytes;
|
||||
private MapEntity aerowalkRoot;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
aerowalkBytes = File.ReadAllBytes(@"C:\dev\Goake\maps\aerowalk\aerowalk.map");
|
||||
aerowalkRoot = Game.MapParser.Parse(aerowalkBytes);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void CleanUp()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Perf_LoadAerowalk()
|
||||
{
|
||||
List<Game.MapEntity> mapEntities = new List<Game.MapEntity>(100);
|
||||
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
var root = Game.MapParser.Parse(aerowalkBytes);
|
||||
mapEntities.Add(root);
|
||||
}
|
||||
|
||||
sw.Stop();
|
||||
|
||||
var elapsedMs = sw.Elapsed.TotalMilliseconds;
|
||||
TestContext.Out.WriteLine("Map parsing time: " + elapsedMs/100 + "ms");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Perf_TriangulateAerowalk()
|
||||
{
|
||||
// warmup?
|
||||
//var roott = Game.MapParser.Parse(aerowalkBytes);
|
||||
|
||||
List<Game.MapEntity> mapEntities = new List<Game.MapEntity>(100);
|
||||
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
|
||||
for (int i = 0; i < 1; i++)
|
||||
{
|
||||
foreach (var ent in aerowalkRoot.entities)
|
||||
foreach (var brush in ent.brushes)
|
||||
{
|
||||
Q3MapImporter.TriangulateBrush3(brush, out Vector3[] verts);
|
||||
Assert.IsTrue(verts.Length > 0);
|
||||
}
|
||||
}
|
||||
|
||||
sw.Stop();
|
||||
|
||||
var elapsedMs = sw.Elapsed.TotalMilliseconds;
|
||||
TestContext.Out.WriteLine("Triangulation time: " + elapsedMs + "ms");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user