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);
        }
示例#2
0
        public static JsonToken[] Tokenize(string json)
        {
            IJsonReader jsonReader = JsonReader.Create(Encoding.UTF8.GetBytes(json));

            return(JsonPerfMeasurement.Tokenize(jsonReader, json));
        }
示例#3
0
 public static TimeSpan MeasureWritePerformance(IJsonWriter jsonWriter, string json, int numberOfIterations = 1)
 {
     JsonToken[] tokens = JsonPerfMeasurement.Tokenize(json);
     return(JsonPerfMeasurement.MeasureWritePerformance(tokens, jsonWriter, numberOfIterations));
 }