private void TestWriterToReader(JsonToken[] tokens) { IJsonWriter jsonWriter = JsonWriter.Create(JsonSerializationFormat.Text); JsonPerfMeasurement.MeasureWritePerformance(tokens, jsonWriter); string writerResults = Encoding.UTF8.GetString(jsonWriter.GetResult().ToArray()); IJsonReader jsonReader = JsonReader.Create(Encoding.UTF8.GetBytes(writerResults)); JsonToken[] tokenArrayFromReader = JsonPerfMeasurement.Tokenize(jsonReader, writerResults); tokenArrayFromReader.SequenceEqual(tokens); }
public static JsonToken[] Tokenize(string json) { IJsonReader jsonReader = JsonReader.Create(Encoding.UTF8.GetBytes(json)); return(JsonPerfMeasurement.Tokenize(jsonReader, json)); }
public static TimeSpan MeasureWritePerformance(IJsonWriter jsonWriter, string json, int numberOfIterations = 1) { JsonToken[] tokens = JsonPerfMeasurement.Tokenize(json); return(JsonPerfMeasurement.MeasureWritePerformance(tokens, jsonWriter, numberOfIterations)); }