-Reduced allocations of JToken.Path

This commit is contained in:
James Newton-King
2016-03-28 19:26:27 +13:00
parent 3a412e5ab2
commit 795ef28e0a
3 changed files with 41 additions and 15 deletions
+25 -1
View File
@@ -31,6 +31,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Tests;
using Newtonsoft.Json.Tests.Converters;
@@ -52,6 +53,7 @@ namespace Newtonsoft.Json.TestConsole
//t.DeserializeLargeJson();
//PerformanceTests t = new PerformanceTests();
LargeArrayJTokenPathPerformance();
//t.Iterations = 50000;
//t.BenchmarkDeserializeMethod<TestClass>(PerformanceTests.SerializeMethod.JsonNet, PerformanceTests.JsonText);
@@ -62,7 +64,7 @@ namespace Newtonsoft.Json.TestConsole
//ReadLargeJson();
//WriteLargeJson();
DeserializeJson();
//DeserializeJson();
//ReadLargeJson();
//ReadLargeJsonJavaScriptSerializer();
@@ -72,6 +74,28 @@ namespace Newtonsoft.Json.TestConsole
Console.ReadKey();
}
public static void LargeArrayJTokenPathPerformance()
{
JArray a = new JArray();
for (int i = 0; i < 100000; i++)
{
a.Add(i);
}
JToken last = a.Last;
int interations = 1000;
Console.WriteLine("Ready!!!");
Console.ReadKey();
string p = null;
for (int i = 0; i < interations; i++)
{
p = last.Path;
}
}
public static void DeserializeJson()
{
PerformanceTests t = new PerformanceTests();