Performance optimization for integer value serialization. (#1544)
* Performance optimization for integer serialization. * Add int32 overloads for integer formatter. * fix parameter name * Prefer using the faster, 32 bit division code path, when possible. * fix code formatting * fix uint range check, add test coverage
This commit is contained in:
committed by
James Newton-King
parent
a8245a5b9e
commit
3ea750d6d6
@@ -45,6 +45,20 @@ namespace Newtonsoft.Json.Tests.Benchmarks
|
||||
|
||||
return sw.ToString();
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public string SerializeIntegers()
|
||||
{
|
||||
StringWriter sw = new StringWriter();
|
||||
JsonTextWriter jsonTextWriter = new JsonTextWriter(sw);
|
||||
for (int i = 0; i < 10000; i++)
|
||||
{
|
||||
jsonTextWriter.WriteValue(i);
|
||||
}
|
||||
jsonTextWriter.Flush();
|
||||
|
||||
return sw.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user