XFEExtension
【DLL】XFE各类拓展是一个C#的DLL库,旨在优化C#代码中常用语句的使用,并提供更简洁的访问方式,同时提供Xunit测试框架,快速搭建服务器/客户端,免费ChatGPTAPI接口,免费通讯服务器,XFE下载器,新增格式等
关注
0
Fork
0
Star
0
using System.Diagnostics;
using BenchmarkDotNet.Running;
using XFEExtension.NetCore.Benchmarks;
using XFEExtension.NetCore.XFETransform.Json;
if (args is ["--sample", var samplePath])
{
var json = File.ReadAllText(samplePath);
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
var before = GC.GetAllocatedBytesForCurrentThread();
var stopwatch = Stopwatch.StartNew();
var node = XFEJson.Parse(json);
var value = (node > "data" > "cursor" > "is_begin")?.GetBoolean();
stopwatch.Stop();
var queryMilliseconds = stopwatch.Elapsed.TotalMilliseconds;
var queryAllocations = GC.GetAllocatedBytesForCurrentThread() - before;
stopwatch.Restart();
XFEJson.Validate(json);
stopwatch.Stop();
Console.WriteLine($"chars={json.Length}; value={value}; query_ms={queryMilliseconds:F3}; query_allocated_bytes={queryAllocations}; validate_ms={stopwatch.Elapsed.TotalMilliseconds:F3}");
return;
}
BenchmarkSwitcher.FromAssembly(typeof(JsonBenchmarks).Assembly).Run(args);
using System.Diagnostics;
using BenchmarkDotNet.Running;
using XFEExtension.NetCore.Benchmarks;
using XFEExtension.NetCore.XFETransform.Json;
if (args is ["--sample", var samplePath])
{
var json = File.ReadAllText(samplePath);
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
var before = GC.GetAllocatedBytesForCurrentThread();
var stopwatch = Stopwatch.StartNew();
var node = XFEJson.Parse(json);
var value = (node > "data" > "cursor" > "is_begin")?.GetBoolean();
stopwatch.Stop();
var queryMilliseconds = stopwatch.Elapsed.TotalMilliseconds;
var queryAllocations = GC.GetAllocatedBytesForCurrentThread() - before;
stopwatch.Restart();
XFEJson.Validate(json);
stopwatch.Stop();
Console.WriteLine($"chars={json.Length}; value={value}; query_ms={queryMilliseconds:F3}; query_allocated_bytes={queryAllocations}; validate_ms={stopwatch.Elapsed.TotalMilliseconds:F3}");
return;
}
BenchmarkSwitcher.FromAssembly(typeof(JsonBenchmarks).Assembly).Run(args);