StringBuilderPool reduced memory allocation in 3000 times

This commit is contained in:
2025-04-05 08:27:58 +05:00
parent b0fefbf667
commit f3106769d9
4 changed files with 111 additions and 31 deletions
+16
View File
@@ -12,6 +12,7 @@ global using Directory = DTLib.Filesystem.Directory;
global using File = DTLib.Filesystem.File;
global using Path = DTLib.Filesystem.Path;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.IO;
using System.Text.Encodings.Web;
using DTLib.Dtsod;
@@ -54,6 +55,21 @@ public static partial class Program
try
{
Stopwatch stopwatch = new();
using var save = File.OpenRead("data/gamestate");
stopwatch.Start();
var parser = new SaveParserEU4(save, SearchExpressionCompiler.Compile("saved_event_target"));
var result = parser.Parse();
stopwatch.Stop();
using (var resultFile = File.OpenWrite("data/parsed.json"))
{
JsonSerializer.Serialize(resultFile, result, _saveSerializerOptions);
}
Console.WriteLine($"get: {parser.SBPoolGetCount} return: {parser.SBPoolReturnCount} " +
$"delta: {parser.SBPoolGetCount - parser.SBPoolReturnCount}");
Console.WriteLine(stopwatch.Elapsed);
return;
// config
if (!File.Exists(_configPath))
{