public ComplexTypeBenchmarks() { _orleansSerializer = new ClientBuilder() .ConfigureDefaults() .UseLocalhostClustering() .ConfigureServices(s => s.ToList().ForEach(r => { if (r.ServiceType == typeof(IConfigurationValidator)) { _ = s.Remove(r); } })) .Configure <ClusterOptions>(o => o.ClusterId = o.ServiceId = "test") .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(SimpleClass).Assembly).WithCodeGeneration()) .Build().ServiceProvider.GetRequiredService <SerializationManager>(); var services = new ServiceCollection(); _ = services .AddHagar(hagar => hagar.AddISerializableSupport().AddAssembly(typeof(Program).Assembly)); var serviceProvider = services.BuildServiceProvider(); _hagarSerializer = serviceProvider.GetRequiredService <Serializer <ComplexClass> >(); _structSerializer = serviceProvider.GetRequiredService <Serializer <SimpleStruct> >(); _sessionPool = serviceProvider.GetRequiredService <SerializerSessionPool>(); _value = new ComplexClass { BaseInt = 192, Int = 501, String = "bananas", //Array = Enumerable.Range(0, 60).ToArray(), //MultiDimensionalArray = new[,] {{0, 2, 4}, {1, 5, 6}} }; _value.AlsoSelf = _value.BaseSelf = _value.Self = _value; _structValue = new SimpleStruct { Int = 42, Bool = true, Guid = Guid.NewGuid() }; _session = _sessionPool.GetSession(); var writer = HagarBuffer.CreateWriter(_session); _hagarSerializer.Serialize(_value, ref writer); var bytes = new byte[writer.Output.GetMemory().Length]; writer.Output.GetReadOnlySequence().CopyTo(bytes); _hagarBytes = new ReadOnlySequence <byte>(bytes); HagarBuffer.Reset(); var writer2 = new BinaryTokenStreamWriter(); _orleansSerializer.Serialize(_value, writer2); _orleansBytes = writer2.ToBytes(); _readBytesLength = Math.Min(bytes.Length, _orleansBytes.Sum(x => x.Count)); }
public ComplexTypeBenchmarks() { this.orleansSerializer = new ClientBuilder() .ConfigureDefaults() .UseLocalhostClustering() .Configure <ClusterOptions>(o => o.ClusterId = o.ServiceId = "test") .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(SimpleClass).Assembly).WithCodeGeneration()) .Build().ServiceProvider.GetRequiredService <SerializationManager>(); var services = new ServiceCollection(); services .AddHagar() .AddISerializableSupport() .AddSerializers(typeof(Program).Assembly); var serviceProvider = services.BuildServiceProvider(); this.hagarSerializer = serviceProvider.GetRequiredService <Serializer <ComplexClass> >(); this.structSerializer = serviceProvider.GetRequiredService <Serializer <SimpleStruct> >(); this.sessionPool = serviceProvider.GetRequiredService <SessionPool>(); this.value = new ComplexClass { BaseInt = 192, Int = 501, String = "bananas", //Array = Enumerable.Range(0, 60).ToArray(), //MultiDimensionalArray = new[,] {{0, 2, 4}, {1, 5, 6}} }; this.value.AlsoSelf = this.value.BaseSelf = this.value.Self = this.value; this.structValue = new SimpleStruct { Int = 42, Bool = true, Guid = Guid.NewGuid() }; this.session = sessionPool.GetSession(); var writer = new Writer(HagarBuffer); this.hagarSerializer.Serialize(this.value, session, ref writer); var bytes = new byte[HagarBuffer.GetMemory().Length]; HagarBuffer.GetReadOnlySequence().CopyTo(bytes); this.hagarBytes = new ReadOnlySequence <byte>(bytes); HagarBuffer.Reset(); var writer2 = new BinaryTokenStreamWriter(); this.orleansSerializer.Serialize(this.value, writer2); this.orleansBytes = writer2.ToBytes(); this.readBytesLength = Math.Min(bytes.Length, orleansBytes.Sum(x => x.Count)); }