private static void ExecuteNavigateMicroBenchmark(
            BenchmarkPayload payload,
            BenchmarkSerializationFormat benchmarkSerializationFormat)
        {
            IJsonNavigator jsonNavigator = benchmarkSerializationFormat switch
            {
                BenchmarkSerializationFormat.Text => JsonNavigator.Create(payload.Text),
                BenchmarkSerializationFormat.Binary => JsonNavigator.Create(payload.Binary),
                _ => throw new ArgumentOutOfRangeException($"Unknown {nameof(BenchmarkSerializationFormat)}: '{benchmarkSerializationFormat}'."),
            };

            Utils.DrainNavigator(jsonNavigator);
        }
Beispiel #2
0
 public IEnumerable <object[]> Arguments()
 {
     foreach (FieldInfo fieldInfo in typeof(Payloads).GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
     {
         BenchmarkPayload payload = (BenchmarkPayload)fieldInfo.GetValue(null);
         foreach (BenchmarkSerializationFormat sourceFormat in Enum.GetValues(typeof(BenchmarkSerializationFormat)))
         {
             foreach (bool materializeValue in new bool[] { false, true })
             {
                 yield return(new object[] { payload, sourceFormat, materializeValue });
             }
         }
     }
 }
        private static void ExecuteReadMicroBenchmark(
            BenchmarkPayload payload,
            BenchmarkSerializationFormat benchmarkSerializationFormat,
            bool materializeValue)
        {
            IJsonReader jsonReader = benchmarkSerializationFormat switch
            {
                BenchmarkSerializationFormat.Text => JsonReader.Create(payload.Text),
                BenchmarkSerializationFormat.Binary => JsonReader.Create(payload.Binary),
                BenchmarkSerializationFormat.Newtonsoft => NewtonsoftToCosmosDBReader.CreateFromBuffer(payload.Newtonsoft),
                _ => throw new ArgumentOutOfRangeException($"Unknown {nameof(BenchmarkSerializationFormat)}: '{benchmarkSerializationFormat}'."),
            };

            Utils.DrainReader(jsonReader, materializeValue);
        }