mirror of
https://github.com/dcronqvist/DotTiled.git
synced 2025-05-09 02:46:04 +03:00
Add more benchmarking information and fix paths in benchmarks
This commit is contained in:
parent
dad5f2c42c
commit
32de90a566
2 changed files with 31 additions and 14 deletions
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
@ -18,18 +19,24 @@ namespace MyBenchmarks
|
|||
[HideColumns(["StdDev", "Error", "RatioSD"])]
|
||||
public class MapLoading
|
||||
{
|
||||
private string _tmxPath = @"C:\Users\Daniel\winrepos\DotTiled\DotTiled.Tests\Serialization\TestData\Map\empty-map-csv.tmx";
|
||||
private string _tmxPath = @"DotTiled.Tests/Serialization/TestData/Map/default-map/default-map.tmx";
|
||||
private string _tmxContents = "";
|
||||
|
||||
private string _tmjPath = @"C:\Users\Daniel\winrepos\DotTiled\DotTiled.Tests\Serialization\TestData\Map\empty-map-csv.tmj";
|
||||
private string _tmjPath = @"DotTiled.Tests/Serialization/TestData/Map/default-map/default-map.tmj";
|
||||
private string _tmjContents = "";
|
||||
|
||||
public MapLoading()
|
||||
{
|
||||
_tmxContents = System.IO.File.ReadAllText(_tmxPath);
|
||||
_tmjContents = System.IO.File.ReadAllText(_tmjPath);
|
||||
var basePath = Path.GetDirectoryName(WhereAmI())!;
|
||||
var tmxPath = Path.Combine(basePath, $"../{_tmxPath}");
|
||||
var tmjPath = Path.Combine(basePath, $"../{_tmjPath}");
|
||||
|
||||
_tmxContents = System.IO.File.ReadAllText(tmxPath);
|
||||
_tmjContents = System.IO.File.ReadAllText(tmjPath);
|
||||
}
|
||||
|
||||
static string WhereAmI([CallerFilePath] string callerFilePath = "") => callerFilePath;
|
||||
|
||||
[BenchmarkCategory("MapFromInMemoryTmxString")]
|
||||
[Benchmark(Baseline = true, Description = "DotTiled")]
|
||||
public DotTiled.Map LoadWithDotTiledFromInMemoryTmxString()
|
||||
|
@ -56,6 +63,14 @@ namespace MyBenchmarks
|
|||
return TiledLib.Map.FromStream(memStream);
|
||||
}
|
||||
|
||||
[BenchmarkCategory("MapFromInMemoryTmjString")]
|
||||
[Benchmark(Description = "TiledLib")]
|
||||
public TiledLib.Map LoadWithTiledLibFromInMemoryTmjString()
|
||||
{
|
||||
using var memStream = new MemoryStream(Encoding.UTF8.GetBytes(_tmjContents));
|
||||
return TiledLib.Map.FromStream(memStream);
|
||||
}
|
||||
|
||||
[BenchmarkCategory("MapFromInMemoryTmxString")]
|
||||
[Benchmark(Description = "TiledCSPlus")]
|
||||
public TiledCSPlus.TiledMap LoadWithTiledCSPlusFromInMemoryTmxString()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue