diff --git a/src/benchmarks/micro/Serializers/DataGenerator.cs b/src/benchmarks/micro/Serializers/DataGenerator.cs index 852a5ef98f..07efd7e49c 100644 --- a/src/benchmarks/micro/Serializers/DataGenerator.cs +++ b/src/benchmarks/micro/Serializers/DataGenerator.cs @@ -4,9 +4,11 @@ using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.Linq; using System.Xml; using System.Xml.Serialization; +using BenchmarkDotNet.Extensions; using MessagePack; using ProtoBuf; @@ -34,6 +36,12 @@ internal static T Generate() return (T)(object)new SimpleStructWithProperties { Num = 1, Text = "Foo" }; if (typeof(T) == typeof(ClassImplementingIXmlSerialiable)) return (T)(object)new ClassImplementingIXmlSerialiable { StringValue = "Hello world" }; + if (typeof(T) == typeof(Dictionary)) + return (T)(object)ValuesGenerator.ArrayOfUniqueValues(100).ToDictionary(value => value); + if (typeof(T) == typeof(ImmutableDictionary)) + return (T)(object)ImmutableDictionary.CreateRange(ValuesGenerator.ArrayOfUniqueValues(100).ToDictionary(value => value)); + if (typeof(T) == typeof(ImmutableSortedDictionary)) + return (T)(object)ImmutableSortedDictionary.CreateRange(ValuesGenerator.ArrayOfUniqueValues(100).ToDictionary(value => value)); throw new NotImplementedException(); } diff --git a/src/benchmarks/micro/corefx/System.Text.Json/Serializer/ReadJson.cs b/src/benchmarks/micro/corefx/System.Text.Json/Serializer/ReadJson.cs index aed4ef2a2c..13845006fd 100644 --- a/src/benchmarks/micro/corefx/System.Text.Json/Serializer/ReadJson.cs +++ b/src/benchmarks/micro/corefx/System.Text.Json/Serializer/ReadJson.cs @@ -5,6 +5,8 @@ using BenchmarkDotNet.Attributes; using MicroBenchmarks; using MicroBenchmarks.Serializers; +using System.Collections.Generic; +using System.Collections.Immutable; using System.IO; using System.Threading.Tasks; @@ -15,6 +17,9 @@ namespace System.Text.Json.Serialization.Tests [GenericTypeArguments(typeof(IndexViewModel))] [GenericTypeArguments(typeof(MyEventsListerViewModel))] [GenericTypeArguments(typeof(BinaryData))] + [GenericTypeArguments(typeof(Dictionary))] + [GenericTypeArguments(typeof(ImmutableDictionary))] + [GenericTypeArguments(typeof(ImmutableSortedDictionary))] public class ReadJson { private string _serialized; diff --git a/src/benchmarks/micro/corefx/System.Text.Json/Serializer/WriteJson.cs b/src/benchmarks/micro/corefx/System.Text.Json/Serializer/WriteJson.cs index 1afceb3c18..e0ca8ad8c3 100644 --- a/src/benchmarks/micro/corefx/System.Text.Json/Serializer/WriteJson.cs +++ b/src/benchmarks/micro/corefx/System.Text.Json/Serializer/WriteJson.cs @@ -5,6 +5,8 @@ using BenchmarkDotNet.Attributes; using MicroBenchmarks; using MicroBenchmarks.Serializers; +using System.Collections.Generic; +using System.Collections.Immutable; using System.IO; using System.Threading.Tasks; @@ -15,6 +17,9 @@ namespace System.Text.Json.Serialization.Tests [GenericTypeArguments(typeof(IndexViewModel))] [GenericTypeArguments(typeof(MyEventsListerViewModel))] [GenericTypeArguments(typeof(BinaryData))] + [GenericTypeArguments(typeof(Dictionary))] + [GenericTypeArguments(typeof(ImmutableDictionary))] + [GenericTypeArguments(typeof(ImmutableSortedDictionary))] public class WriteJson { private T _value;