-Fixed build
This commit is contained in:
@@ -44,6 +44,12 @@ namespace Newtonsoft.Json.Tests.Converters
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class JsonValueConverterTests : TestFixtureBase
|
public class JsonValueConverterTests : TestFixtureBase
|
||||||
{
|
{
|
||||||
|
public class Computer
|
||||||
|
{
|
||||||
|
public string Cpu { get; set; }
|
||||||
|
public List<string> Drives { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WriteJson()
|
public void WriteJson()
|
||||||
{
|
{
|
||||||
@@ -270,17 +276,19 @@ namespace Newtonsoft.Json.Tests.Converters
|
|||||||
[Test]
|
[Test]
|
||||||
public void DeserializePerformance()
|
public void DeserializePerformance()
|
||||||
{
|
{
|
||||||
Stopwatch timer = new Stopwatch();
|
string json = @"{
|
||||||
timer.Start();
|
|
||||||
for (int i = 0; i < 100000; i++)
|
|
||||||
{
|
|
||||||
JsonObject o = JsonObject.Parse(@"{
|
|
||||||
""CPU"": ""Intel"",
|
""CPU"": ""Intel"",
|
||||||
""Drives"": [
|
""Drives"": [
|
||||||
""DVD read/writer"",
|
""DVD read/writer"",
|
||||||
""500 gigabyte hard drive""
|
""500 gigabyte hard drive""
|
||||||
]
|
]
|
||||||
}");
|
}";
|
||||||
|
|
||||||
|
Stopwatch timer = new Stopwatch();
|
||||||
|
timer.Start();
|
||||||
|
for (int i = 0; i < 100000; i++)
|
||||||
|
{
|
||||||
|
JsonObject o = JsonObject.Parse(json);
|
||||||
}
|
}
|
||||||
timer.Stop();
|
timer.Stop();
|
||||||
|
|
||||||
@@ -290,29 +298,20 @@ namespace Newtonsoft.Json.Tests.Converters
|
|||||||
timer.Start();
|
timer.Start();
|
||||||
for (int i = 0; i < 100000; i++)
|
for (int i = 0; i < 100000; i++)
|
||||||
{
|
{
|
||||||
JObject o = JObject.Parse(@"{
|
JObject o = JObject.Parse(json);
|
||||||
""CPU"": ""Intel"",
|
|
||||||
""Drives"": [
|
|
||||||
""DVD read/writer"",
|
|
||||||
""500 gigabyte hard drive""
|
|
||||||
]
|
|
||||||
}");
|
|
||||||
}
|
}
|
||||||
timer.Stop();
|
timer.Stop();
|
||||||
|
|
||||||
string linq = timer.Elapsed.TotalSeconds.ToString();
|
string linq = timer.Elapsed.TotalSeconds.ToString();
|
||||||
|
|
||||||
|
// warm up
|
||||||
|
JsonConvert.DeserializeObject<Computer>(json);
|
||||||
|
|
||||||
timer = new Stopwatch();
|
timer = new Stopwatch();
|
||||||
timer.Start();
|
timer.Start();
|
||||||
for (int i = 0; i < 100000; i++)
|
for (int i = 0; i < 100000; i++)
|
||||||
{
|
{
|
||||||
JsonObject o = JsonConvert.DeserializeObject<JsonObject>(@"{
|
Computer o = JsonConvert.DeserializeObject<Computer>(json);
|
||||||
""CPU"": ""Intel"",
|
|
||||||
""Drives"": [
|
|
||||||
""DVD read/writer"",
|
|
||||||
""500 gigabyte hard drive""
|
|
||||||
]
|
|
||||||
}");
|
|
||||||
}
|
}
|
||||||
timer.Stop();
|
timer.Stop();
|
||||||
|
|
||||||
@@ -326,21 +325,17 @@ namespace Newtonsoft.Json.Tests.Converters
|
|||||||
[Test]
|
[Test]
|
||||||
public void SerializePerformance()
|
public void SerializePerformance()
|
||||||
{
|
{
|
||||||
JsonObject o = JsonObject.Parse(@"{
|
string json = @"{
|
||||||
""CPU"": ""Intel"",
|
""CPU"": ""Intel"",
|
||||||
""Drives"": [
|
""Drives"": [
|
||||||
""DVD read/writer"",
|
""DVD read/writer"",
|
||||||
""500 gigabyte hard drive""
|
""500 gigabyte hard drive""
|
||||||
]
|
]
|
||||||
}");
|
}";
|
||||||
|
|
||||||
JObject o1 = JObject.Parse(@"{
|
JsonObject o = JsonObject.Parse(json);
|
||||||
""CPU"": ""Intel"",
|
JObject o1 = JObject.Parse(json);
|
||||||
""Drives"": [
|
Computer o2 = JsonConvert.DeserializeObject<Computer>(json);
|
||||||
""DVD read/writer"",
|
|
||||||
""500 gigabyte hard drive""
|
|
||||||
]
|
|
||||||
}");
|
|
||||||
|
|
||||||
Stopwatch timer = new Stopwatch();
|
Stopwatch timer = new Stopwatch();
|
||||||
timer.Start();
|
timer.Start();
|
||||||
|
|||||||
@@ -161,7 +161,13 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
bool hasNext = (i + 1 < s.Length);
|
bool hasNext = (i + 1 < s.Length);
|
||||||
if ((i == 0 || !hasNext) || char.IsUpper(s[i + 1]))
|
if ((i == 0 || !hasNext) || char.IsUpper(s[i + 1]))
|
||||||
{
|
{
|
||||||
char lowerCase = char.ToLower(s[i], CultureInfo.InvariantCulture);
|
char lowerCase;
|
||||||
|
#if !NETFX_CORE
|
||||||
|
lowerCase = char.ToLower(s[i], CultureInfo.InvariantCulture);
|
||||||
|
#else
|
||||||
|
lowerCase = char.ToLower(s[i]);
|
||||||
|
#endif
|
||||||
|
|
||||||
sb.Append(lowerCase);
|
sb.Append(lowerCase);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user