From 34566d401ca9599462e7538a219bd2ff3ede6cb1 Mon Sep 17 00:00:00 2001 From: Bartosz Sypytkowski Date: Sat, 17 Jun 2017 18:44:33 +0200 Subject: [PATCH 1/2] moved to BenchmarkDotNet --- .../Hyperion.Benchmarks.csproj | 17 + Hyperion.Benchmarks/Program.cs | 15 + Hyperion.Benchmarks/Prolog.cs | 82 +++ .../SerializeClassesBenchmark.cs | 192 ++++++ .../SerializeCollectionsBenchmark.cs | 30 + .../SerializeFSharpDataTypesBenchmark.cs | 54 ++ .../SerializeImmutableCollectionsBenchmark.cs | 31 + .../SerializePrimitivesBenchmark.cs | 71 +++ .../SerializeStructsBenchmark.cs | 80 +++ .../Hyperion.FSharpTestTypes.fsproj | 24 - Hyperion.FSharpTestTypes/Script.fsx | 8 - Hyperion.PerfTest/App.config | 26 - Hyperion.PerfTest/Hyperion.PerfTest.csproj | 32 - .../ManualSerializer/CustomBinaryFormatter.cs | 121 ---- Hyperion.PerfTest/Properties/AssemblyInfo.cs | 36 -- Hyperion.PerfTest/Tests/GuidArrayTest.cs | 27 - Hyperion.PerfTest/Tests/GuidTest.cs | 21 - Hyperion.PerfTest/Tests/LargeStructTest.cs | 21 - Hyperion.PerfTest/Tests/TestBase.cs | 469 --------------- .../Tests/TypicalMessageArrayTest.cs | 37 -- Hyperion.PerfTest/Tests/TypicalMessageTest.cs | 91 --- .../Tests/TypicalPersonArrayTest.cs | 27 - Hyperion.PerfTest/Tests/TypicalPersonTest.cs | 21 - Hyperion.PerfTest/Types/LargeStruct.cs | 69 --- Hyperion.PerfTest/Types/TypicalMessage.cs | 37 -- Hyperion.PerfTest/Types/TypicalPerson.cs | 276 --------- .../Hyperion.PerformanceTests.csproj | 28 - .../Properties/AssemblyInfo.cs | 33 - .../SpeedAndSizeTests.cs | 354 ----------- .../Hyperion.Tests.FSharpData.fsproj | 11 + .../Types.fs | 19 +- Hyperion.Tests.Performance/BenchmarkHelper.cs | 14 - .../DeserializeCollectionsBenchmark.cs | 173 ------ .../DeserializeComplexObjectsBenchmark.cs | 87 --- .../DeserializeFSharpTypesBenchmark.cs | 134 ----- ...eserializeImmutableCollectionsBenchmark.cs | 134 ----- .../DeserializePrimitivesBenchmark.cs | 569 ------------------ .../Hyperion.Tests.Performance.csproj | 28 - Hyperion.Tests.Performance/PerfTestBase.cs | 77 --- .../Properties/AssemblyInfo.cs | 30 - .../SerializeCollectionsBenchmark.cs | 110 ---- .../SerializeComplexObjectsBenchmark.cs | 72 --- .../SerializeFSharpTypesBenchmark.cs | 86 --- .../SerializeImmutableCollectionsBenchmark.cs | 90 --- .../SerializePrimitivesBenchmark.cs | 318 ---------- Hyperion.Tests.Performance/Types/Cyclic.cs | 25 - .../Types/LargeStruct.cs | 56 -- .../Types/TestMessage.cs | 24 - .../Types/TestPerson.cs | 143 ----- Hyperion.Tests.Performance/app.config | 11 - Hyperion.Tests/AttributeTests.cs | 58 ++ Hyperion.Tests/Bugs.cs | 65 +- Hyperion.Tests/CollectionTests.cs | 18 +- Hyperion.Tests/CustomObjectTests.cs | 33 +- Hyperion.Tests/ExpressionTests.cs | 1 - Hyperion.Tests/FSharpTests.cs | 53 +- Hyperion.Tests/Hyperion.Tests.csproj | 37 +- Hyperion.Tests/ImmutableCollectionsTests.cs | 1 - Hyperion.Tests/Properties/AssemblyInfo.cs | 24 - .../UnsupportedTypeSerializerTests.cs | 1 - Hyperion.sln | 53 +- Hyperion/Attributes.cs | 22 + Hyperion/ByteArrayKey.cs | 2 +- Hyperion/ByteArrayKeyComparer.cs | 2 +- Hyperion/Compilation/Compiler.cs | 38 +- Hyperion/Compilation/ExpressionEx.cs | 2 +- Hyperion/Compilation/IlBuilder.cs | 6 +- Hyperion/Compilation/IlCompiler.cs | 2 +- Hyperion/Compilation/IlCompilerContext.cs | 4 +- Hyperion/Compilation/IlExpression.cs | 28 +- Hyperion/DefaultCodeGenerator.cs | 5 +- Hyperion/DeserializeSession.cs | 3 +- Hyperion/Extensions/ReflectionEx.cs | 5 +- Hyperion/Extensions/StreamEx.cs | 2 +- Hyperion/Extensions/TypeEx.cs | 2 +- Hyperion/Properties/AssemblyInfo.cs | 2 + Hyperion/Serializer.cs | 11 +- .../ArraySerializerFactory.cs | 5 +- .../ConsistentArraySerializerFactory.cs | 2 +- .../ConstructorInfoSerializerFactory.cs | 2 +- .../DefaultDictionarySerializerFactory.cs | 2 +- .../DelegateSerializerFactory.cs | 2 +- .../DictionarySerializerFactory.cs | 2 +- .../EnumerableSerializerFactory.cs | 2 +- .../ExceptionSerializerFactory.cs | 2 +- .../ExpandoObjectSerializerFactory.cs | 2 +- .../FSharpListSerializerFactory.cs | 2 +- .../FSharpMapSerializerFactory.cs | 2 +- .../FieldInfoSerializerFactory.cs | 2 +- .../FromSurrogateSerializerFactory.cs | 2 +- .../ISerializableSerializerFactory.cs | 2 +- .../ImmutableCollectionsSerializerFactory.cs | 2 +- .../MethodInfoSerializerFactory.cs | 2 +- .../PropertyInfoSerializerFactory.cs | 2 +- .../ToSurrogateSerializerFactory.cs | 2 +- Hyperion/ValueSerializers/BoolSerializer.cs | 2 +- .../ValueSerializers/ByteArraySerializer.cs | 2 +- Hyperion/ValueSerializers/ByteSerializer.cs | 2 +- Hyperion/ValueSerializers/CharSerializer.cs | 2 +- .../ConsistentArraySerializer.cs | 2 +- .../ValueSerializers/DateTimeSerializer.cs | 2 +- .../ValueSerializers/DecimalSerializer.cs | 2 +- Hyperion/ValueSerializers/DoubleSerializer.cs | 2 +- Hyperion/ValueSerializers/FloatSerializer.cs | 2 +- .../FromSurrogateSerializer.cs | 2 +- Hyperion/ValueSerializers/GuidSerializer.cs | 2 +- Hyperion/ValueSerializers/Int16Serializer.cs | 2 +- Hyperion/ValueSerializers/Int32Serializer.cs | 2 +- Hyperion/ValueSerializers/Int64Serializer.cs | 2 +- Hyperion/ValueSerializers/NullSerializer.cs | 2 +- Hyperion/ValueSerializers/SByteSerializer.cs | 2 +- Hyperion/ValueSerializers/StringSerializer.cs | 2 +- .../SystemObjectSerializer.cs | 2 +- .../ValueSerializers/ToSurrogateSerializer.cs | 2 +- Hyperion/ValueSerializers/TypeSerializer.cs | 2 +- Hyperion/ValueSerializers/UInt16Serializer.cs | 2 +- Hyperion/ValueSerializers/UInt32Serializer.cs | 2 +- Hyperion/ValueSerializers/UInt64Serializer.cs | 2 +- .../UnsupportedTypeSerializer.cs | 3 +- build.fsx | 36 +- build.ps1 | 10 +- build.sh | 6 +- common.props | 1 + 123 files changed, 979 insertions(+), 4183 deletions(-) create mode 100644 Hyperion.Benchmarks/Hyperion.Benchmarks.csproj create mode 100644 Hyperion.Benchmarks/Program.cs create mode 100644 Hyperion.Benchmarks/Prolog.cs create mode 100644 Hyperion.Benchmarks/SerializeClassesBenchmark.cs create mode 100644 Hyperion.Benchmarks/SerializeCollectionsBenchmark.cs create mode 100644 Hyperion.Benchmarks/SerializeFSharpDataTypesBenchmark.cs create mode 100644 Hyperion.Benchmarks/SerializeImmutableCollectionsBenchmark.cs create mode 100644 Hyperion.Benchmarks/SerializePrimitivesBenchmark.cs create mode 100644 Hyperion.Benchmarks/SerializeStructsBenchmark.cs delete mode 100644 Hyperion.FSharpTestTypes/Hyperion.FSharpTestTypes.fsproj delete mode 100644 Hyperion.FSharpTestTypes/Script.fsx delete mode 100644 Hyperion.PerfTest/App.config delete mode 100644 Hyperion.PerfTest/Hyperion.PerfTest.csproj delete mode 100644 Hyperion.PerfTest/ManualSerializer/CustomBinaryFormatter.cs delete mode 100644 Hyperion.PerfTest/Properties/AssemblyInfo.cs delete mode 100644 Hyperion.PerfTest/Tests/GuidArrayTest.cs delete mode 100644 Hyperion.PerfTest/Tests/GuidTest.cs delete mode 100644 Hyperion.PerfTest/Tests/LargeStructTest.cs delete mode 100644 Hyperion.PerfTest/Tests/TestBase.cs delete mode 100644 Hyperion.PerfTest/Tests/TypicalMessageArrayTest.cs delete mode 100644 Hyperion.PerfTest/Tests/TypicalMessageTest.cs delete mode 100644 Hyperion.PerfTest/Tests/TypicalPersonArrayTest.cs delete mode 100644 Hyperion.PerfTest/Tests/TypicalPersonTest.cs delete mode 100644 Hyperion.PerfTest/Types/LargeStruct.cs delete mode 100644 Hyperion.PerfTest/Types/TypicalMessage.cs delete mode 100644 Hyperion.PerfTest/Types/TypicalPerson.cs delete mode 100644 Hyperion.PerformanceTests/Hyperion.PerformanceTests.csproj delete mode 100644 Hyperion.PerformanceTests/Properties/AssemblyInfo.cs delete mode 100644 Hyperion.PerformanceTests/SpeedAndSizeTests.cs create mode 100644 Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj rename Hyperion.FSharpTestTypes/Library1.fs => Hyperion.Tests.FSharpData/Types.fs (82%) delete mode 100644 Hyperion.Tests.Performance/BenchmarkHelper.cs delete mode 100644 Hyperion.Tests.Performance/Deserialization/DeserializeCollectionsBenchmark.cs delete mode 100644 Hyperion.Tests.Performance/Deserialization/DeserializeComplexObjectsBenchmark.cs delete mode 100644 Hyperion.Tests.Performance/Deserialization/DeserializeFSharpTypesBenchmark.cs delete mode 100644 Hyperion.Tests.Performance/Deserialization/DeserializeImmutableCollectionsBenchmark.cs delete mode 100644 Hyperion.Tests.Performance/Deserialization/DeserializePrimitivesBenchmark.cs delete mode 100644 Hyperion.Tests.Performance/Hyperion.Tests.Performance.csproj delete mode 100644 Hyperion.Tests.Performance/PerfTestBase.cs delete mode 100644 Hyperion.Tests.Performance/Properties/AssemblyInfo.cs delete mode 100644 Hyperion.Tests.Performance/Serialization/SerializeCollectionsBenchmark.cs delete mode 100644 Hyperion.Tests.Performance/Serialization/SerializeComplexObjectsBenchmark.cs delete mode 100644 Hyperion.Tests.Performance/Serialization/SerializeFSharpTypesBenchmark.cs delete mode 100644 Hyperion.Tests.Performance/Serialization/SerializeImmutableCollectionsBenchmark.cs delete mode 100644 Hyperion.Tests.Performance/Serialization/SerializePrimitivesBenchmark.cs delete mode 100644 Hyperion.Tests.Performance/Types/Cyclic.cs delete mode 100644 Hyperion.Tests.Performance/Types/LargeStruct.cs delete mode 100644 Hyperion.Tests.Performance/Types/TestMessage.cs delete mode 100644 Hyperion.Tests.Performance/Types/TestPerson.cs delete mode 100644 Hyperion.Tests.Performance/app.config create mode 100644 Hyperion.Tests/AttributeTests.cs delete mode 100644 Hyperion.Tests/Properties/AssemblyInfo.cs create mode 100644 Hyperion/Attributes.cs diff --git a/Hyperion.Benchmarks/Hyperion.Benchmarks.csproj b/Hyperion.Benchmarks/Hyperion.Benchmarks.csproj new file mode 100644 index 00000000..2bedeb73 --- /dev/null +++ b/Hyperion.Benchmarks/Hyperion.Benchmarks.csproj @@ -0,0 +1,17 @@ + + + + Exe + netcoreapp2.0 + + + + + + + + + + + + diff --git a/Hyperion.Benchmarks/Program.cs b/Hyperion.Benchmarks/Program.cs new file mode 100644 index 00000000..41a15b23 --- /dev/null +++ b/Hyperion.Benchmarks/Program.cs @@ -0,0 +1,15 @@ +using System; +using System.Reflection; +using BenchmarkDotNet.Running; + +namespace Hyperion.Benchmarks +{ + class Program + { + static void Main(string[] args) + { + var benchmark = BenchmarkSwitcher.FromAssembly(Assembly.GetExecutingAssembly()); + benchmark.RunAll(); + } + } +} diff --git a/Hyperion.Benchmarks/Prolog.cs b/Hyperion.Benchmarks/Prolog.cs new file mode 100644 index 00000000..224ba5ce --- /dev/null +++ b/Hyperion.Benchmarks/Prolog.cs @@ -0,0 +1,82 @@ +#region copyright +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2016 AsynkronIT +// Copyright (C) 2016-2016 Akka.NET Team +// +// ----------------------------------------------------------------------- +#endregion + +using System.IO; +using System.Runtime.CompilerServices; +using BenchmarkDotNet.Attributes; +using BenchmarkDotNet.Columns; +using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Diagnosers; +using BenchmarkDotNet.Exporters; + +namespace Hyperion.Benchmarks +{ + public class HyperionConfig : ManualConfig + { + public HyperionConfig() + { + Add(StatisticColumn.Mean, StatisticColumn.Min, StatisticColumn.Max, StatisticColumn.OperationsPerSecond); + Add(MarkdownExporter.GitHub); + Add(MemoryDiagnoser.Default); + } + } + + [Config(typeof(HyperionConfig))] + public abstract class HyperionBenchmark + { + #region init + + protected Serializer Serializer; + protected MemoryStream Stream; + + [GlobalSetup] + public void Setup() + { + Stream = new MemoryStream(); + Init(); + } + + [GlobalCleanup] + public void Cleanup() + { + Stream.Dispose(); + Clean(); + } + + protected virtual void Init() + { + Serializer = new Serializer(); + } + + protected virtual void Clean() { } + + #endregion + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + protected void Serialize(T elem) + { + Serializer.Serialize(elem, Stream); + Stream.Position = 0; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + protected void Deserialize() + { + Serializer.Deserialize(Stream); + Stream.Position = 0; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + protected void SerializeAndDeserialize(T elem) + { + Serialize(elem); + Deserialize(); + } + } +} \ No newline at end of file diff --git a/Hyperion.Benchmarks/SerializeClassesBenchmark.cs b/Hyperion.Benchmarks/SerializeClassesBenchmark.cs new file mode 100644 index 00000000..58357588 --- /dev/null +++ b/Hyperion.Benchmarks/SerializeClassesBenchmark.cs @@ -0,0 +1,192 @@ +#region copyright +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2016 AsynkronIT +// Copyright (C) 2016-2016 Akka.NET Team +// +// ----------------------------------------------------------------------- +#endregion + +using System; +using BenchmarkDotNet.Attributes; + +namespace Hyperion.Benchmarks +{ + public class SerializeClassesBenchmark : HyperionBenchmark + { + #region init + private CyclicClassA cyclic; + private VirtualTestClass virtualObject; + private LargeSealedClass sealedObject; + private GenericClass genericObject; + + protected override void Init() + { + Serializer = new Serializer(new SerializerOptions(preserveObjectReferences:true)); + var a = new CyclicClassA(); + var b = new CyclicClassB(); + a.B = b; + b.A = a; + cyclic = a; + + virtualObject = new VirtualTestClass + { + DateProp = DateTime.Now, + GuidProp = Guid.NewGuid(), + IntProp = 812342354, + StringProp = new string('x', 30) + }; + + sealedObject = LargeSealedClass.MakeRandom(); + + genericObject = new GenericClass(123, "hello-world", true, DateTime.Now, Guid.NewGuid()); + } + + #endregion + + [Benchmark] public void Cyclic_References() => SerializeAndDeserialize(cyclic); + [Benchmark] public void Virtual_Classes() => SerializeAndDeserialize(virtualObject); + [Benchmark] public void Large_Sealed_Classes() => SerializeAndDeserialize(sealedObject); + [Benchmark] public void Generic_Classes() => SerializeAndDeserialize(genericObject); + } + + #region test data types + + public class CyclicClassA + { + public CyclicClassB B { get; set; } + } + + public class CyclicClassB + { + public CyclicClassA A { get; set; } + } + + public class VirtualTestClass + { + public virtual string StringProp { get; set; } + + public virtual int IntProp { get; set; } + + public virtual Guid GuidProp { get; set; } + + public virtual DateTime DateProp { get; set; } + } + + public class GenericClass + { + public T1 Item1 { get; } + public T2 Item2 { get; } + public T3 Item3 { get; } + public T4 Item4 { get; } + public T5 Item5 { get; } + + public GenericClass(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5) + { + Item1 = item1; + Item2 = item2; + Item3 = item3; + Item4 = item4; + Item5 = item5; + } + } + + public sealed class LargeSealedClass + { + public LargeSealedClass() { } + public string Address1 { get; set; } + public string Address2 { get; set; } + public string AddressCity { get; set; } + public string AddressState { get; set; } + public string AddressZip { get; set; } + public double CreditScore { get; set; } + public DateTime DOB { get; set; } + public string EMail { get; set; } + public string FirstName { get; set; } + public string HomePhone { get; set; } + public string LastName { get; set; } + public TestEnum TestEnum { get; set; } + public string MiddleName { get; set; } + public string MobilePhone { get; set; } + public bool RegisteredToVote { get; set; } + public decimal Salary { get; set; } + public int YearsOfService { get; set; } + public string SkypeID { get; set; } + public string YahooID { get; set; } + public string GoogleID { get; set; } + public string Notes { get; set; } + public bool? IsSmoker { get; set; } + public bool? IsLoving { get; set; } + public bool? IsLoved { get; set; } + public bool? IsDangerous { get; set; } + public bool? IsEducated { get; set; } + public DateTime? LastSmokingDate { get; set; } + public decimal? DesiredSalary { get; set; } + public double? ProbabilityOfSpaceFlight { get; set; } + public int? CurrentFriendCount { get; set; } + public int? DesiredFriendCount { get; set; } + + + private static int counter; + public static LargeSealedClass MakeRandom() + { + var rnd = counter++; + + var data = new LargeSealedClass + { + FirstName = NaturalTextGenerator.GenerateFirstName(), + MiddleName = NaturalTextGenerator.GenerateFirstName(), + LastName = NaturalTextGenerator.GenerateLastName(), + DOB = DateTime.Now.AddYears(5), + Salary = 55435345, + YearsOfService = 25, + CreditScore = 0.7562, + RegisteredToVote = (DateTime.UtcNow.Ticks & 1) == 0, + TestEnum = TestEnum.HatesAll, + Address1 = NaturalTextGenerator.GenerateAddressLine(), + Address2 = NaturalTextGenerator.GenerateAddressLine(), + AddressCity = NaturalTextGenerator.GenerateCityName(), + AddressState = "CA", + AddressZip = "91606", + HomePhone = (DateTime.UtcNow.Ticks & 1) == 0 ? "(555) 123-4567" : null, + EMail = NaturalTextGenerator.GenerateEMail() + }; + + if (0 != (rnd & (1 << 32))) data.Notes = NaturalTextGenerator.Generate(45); + if (0 != (rnd & (1 << 31))) data.SkypeID = NaturalTextGenerator.GenerateEMail(); + if (0 != (rnd & (1 << 30))) data.YahooID = NaturalTextGenerator.GenerateEMail(); + + if (0 != (rnd & (1 << 29))) data.IsSmoker = 0 != (rnd & (1 << 17)); + if (0 != (rnd & (1 << 28))) data.IsLoving = 0 != (rnd & (1 << 16)); + if (0 != (rnd & (1 << 27))) data.IsLoved = 0 != (rnd & (1 << 15)); + if (0 != (rnd & (1 << 26))) data.IsDangerous = 0 != (rnd & (1 << 14)); + if (0 != (rnd & (1 << 25))) data.IsEducated = 0 != (rnd & (1 << 13)); + + if (0 != (rnd & (1 << 24))) data.LastSmokingDate = DateTime.Now.AddYears(-10); + + + if (0 != (rnd & (1 << 23))) data.DesiredSalary = rnd / 1000m; + if (0 != (rnd & (1 << 22))) data.ProbabilityOfSpaceFlight = rnd / (double)int.MaxValue; + + if (0 != (rnd & (1 << 21))) + { + data.CurrentFriendCount = rnd % 123; + data.DesiredFriendCount = rnd % 121000; + } + + return data; + } + } + + public class NaturalTextGenerator + { + public static string GenerateEMail() => "foo@fooo.com"; + public static string Generate(int i) => "fskldjflksjfl ksj dlfkjsdfl ksdjklf jsdlkj" + DateTime.Now.Ticks; + public static string GenerateAddressLine() => "fkjdskfjskfjs" + DateTime.Now.Ticks; + public static string GenerateFirstName() => "fksjdfkjsdkfjksdfs" + DateTime.Now.Ticks; + public static string GenerateCityName() => "fksdfkjsdkfjsdkfs"; + public static string GenerateLastName() => "kfjdskdfjskj"; + } + + #endregion +} \ No newline at end of file diff --git a/Hyperion.Benchmarks/SerializeCollectionsBenchmark.cs b/Hyperion.Benchmarks/SerializeCollectionsBenchmark.cs new file mode 100644 index 00000000..ff19bd46 --- /dev/null +++ b/Hyperion.Benchmarks/SerializeCollectionsBenchmark.cs @@ -0,0 +1,30 @@ +#region copyright +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2016 AsynkronIT +// Copyright (C) 2016-2016 Akka.NET Team +// +// ----------------------------------------------------------------------- +#endregion + +using System.Collections.Generic; +using BenchmarkDotNet.Attributes; + +namespace Hyperion.Benchmarks +{ + public class SerializeCollectionsBenchmark : HyperionBenchmark + { + [Benchmark] public void Byte_Array() => SerializeAndDeserialize(new byte[] { 123, 134, 11, 122, 1 }); + [Benchmark] public void String_Array() => SerializeAndDeserialize(new[] { "abc", "cbd0", "sdsd4", "4dfg", "sfsdf44g" }); + [Benchmark] public void Dictionary() => SerializeAndDeserialize(new Dictionary + { + ["abc"] = "aaa", + ["dsdf"] = "asdab", + ["fms0"] = "sdftu" + }); + [Benchmark] public void Array_List() => SerializeAndDeserialize(new List { "asdad", "asdabs3", "sfsdf44g", "asdf4r", "sfsdf44g" }); + [Benchmark] public void Linked_List() => SerializeAndDeserialize(new LinkedList(new[] { "asdad", "asdabs3", "dfsdf9", "asdf4r", "sfsdf44g" })); + [Benchmark] public void Hash_Set() => SerializeAndDeserialize(new HashSet(new[] { "asdad", "asdabs3", "dfsdf9", "asdf4r", "sfsdf44g" })); + [Benchmark] public void Sorted_Set() => SerializeAndDeserialize(new SortedSet(new[] { "asdad", "asdabs3", "dfsdf9", "asdf4r", "sfsdf44g" })); + } +} \ No newline at end of file diff --git a/Hyperion.Benchmarks/SerializeFSharpDataTypesBenchmark.cs b/Hyperion.Benchmarks/SerializeFSharpDataTypesBenchmark.cs new file mode 100644 index 00000000..d2797654 --- /dev/null +++ b/Hyperion.Benchmarks/SerializeFSharpDataTypesBenchmark.cs @@ -0,0 +1,54 @@ +#region copyright +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2016 AsynkronIT +// Copyright (C) 2016-2016 Akka.NET Team +// +// ----------------------------------------------------------------------- +#endregion + +using BenchmarkDotNet.Attributes; +#if FSHARP + +using Hyperion.FSharpTestTypes; +using Microsoft.FSharp.Collections; +using Microsoft.FSharp.Core; + +namespace Hyperion.Benchmarks +{ + public class SerializeFSharpDataTypesBenchmark : HyperionBenchmark + { + #region init + + private FSharpSet set; + private FSharpList list; + private TestRecord record; + private DU2 du; + private SDU1 sdu; + + protected override void Init() + { + base.Init(); + + list = ListModule.OfArray(new[] {123, 2342355, 456456467578, 234234, -234281}); + set = SetModule.OfArray(new[] {123, 2342355, 456456467578, 234234, -234281}); + record = new TestRecord( + name: "John Doe", + aref: FSharpOption.Some("ok"), + connections: "test"); + du = DU2.NewC(DU1.NewB("test", 123)); + sdu = SDU1.NewB("hello", 123); + } + + #endregion + + [Benchmark] public void Discriminated_Union() => SerializeAndDeserialize(du); + [Benchmark] public void Struct_Discriminated_Union() => SerializeAndDeserialize(sdu); + [Benchmark] public void Record() => SerializeAndDeserialize(record); + [Benchmark] public void Record_With_Map() => SerializeAndDeserialize(TestMap.createRecordWithMap); + [Benchmark] public void FSharp_List() => SerializeAndDeserialize(list); + [Benchmark] public void FSharp_Set() => SerializeAndDeserialize(set); + } +} + +#endif \ No newline at end of file diff --git a/Hyperion.Benchmarks/SerializeImmutableCollectionsBenchmark.cs b/Hyperion.Benchmarks/SerializeImmutableCollectionsBenchmark.cs new file mode 100644 index 00000000..83e1f3a8 --- /dev/null +++ b/Hyperion.Benchmarks/SerializeImmutableCollectionsBenchmark.cs @@ -0,0 +1,31 @@ +#region copyright +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2016 AsynkronIT +// Copyright (C) 2016-2016 Akka.NET Team +// +// ----------------------------------------------------------------------- +#endregion + +using System.Collections.Generic; +using System.Collections.Immutable; +using BenchmarkDotNet.Attributes; + +namespace Hyperion.Benchmarks +{ + public class SerializeImmutableCollectionsBenchmark : HyperionBenchmark + { + [Benchmark] public void Immutable_Array() => SerializeAndDeserialize(ImmutableArray.CreateRange(new[] { "abc", "cbd0", "sdsd4", "4dfg", "adafd0xd" })); + [Benchmark] public void Immutable_List() => SerializeAndDeserialize(ImmutableList.CreateRange(new[] { "abc", "cbd0", "sdsd4", "4dfg", "adafd0xd" })); + [Benchmark] public void Immutable_Hash_Set() => SerializeAndDeserialize(ImmutableHashSet.CreateRange(new[] { "abc", "cbd0", "sdsd4", "4dfg", "adafd0xd" })); + [Benchmark] public void Immutable_Sorted_Set() => SerializeAndDeserialize(ImmutableSortedSet.CreateRange(new[] { "abc", "cbd0", "sdsd4", "4dfg", "adafd0xd" })); + [Benchmark] public void Immutable_Dictionary() => SerializeAndDeserialize(ImmutableDictionary.CreateRange(new[] + { + new KeyValuePair("key1", "value1"), + new KeyValuePair("key2", "value2"), + new KeyValuePair("key3", "value3"), + new KeyValuePair("key4", "value4"), + new KeyValuePair("key5", "value5"), + })); + } +} \ No newline at end of file diff --git a/Hyperion.Benchmarks/SerializePrimitivesBenchmark.cs b/Hyperion.Benchmarks/SerializePrimitivesBenchmark.cs new file mode 100644 index 00000000..cd0b9370 --- /dev/null +++ b/Hyperion.Benchmarks/SerializePrimitivesBenchmark.cs @@ -0,0 +1,71 @@ +#region copyright +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2016 AsynkronIT +// Copyright (C) 2016-2016 Akka.NET Team +// +// ----------------------------------------------------------------------- +#endregion + +using System; +using BenchmarkDotNet.Attributes; + +namespace Hyperion.Benchmarks +{ + public class SerializePrimitivesBenchmark : HyperionBenchmark + { + #region init + private Guid guid; + private string str; + private DateTime dateTime; + private TimeSpan time; + + protected override void Init() + { + base.Init(); + + guid = Guid.NewGuid(); + str = new string('x', 100); + dateTime = DateTime.UtcNow; + time = DateTime.UtcNow.TimeOfDay; + } + + #endregion + + [Benchmark] public void Boolean() => SerializeAndDeserialize(true); + [Benchmark] public void Byte() => SerializeAndDeserialize((byte)123); + [Benchmark] public void SByte() => SerializeAndDeserialize((sbyte)123); + [Benchmark] public void Int16() => SerializeAndDeserialize((short)1234); + [Benchmark] public void UInt16() => SerializeAndDeserialize((ushort)1234); + [Benchmark] public void Int32() => SerializeAndDeserialize(12345); + [Benchmark] public void UInt32() => SerializeAndDeserialize(12345U); + [Benchmark] public void Int64() => SerializeAndDeserialize(123456L); + [Benchmark] public void UInt64() => SerializeAndDeserialize(123456UL); + [Benchmark] public void Single() => SerializeAndDeserialize(123456.34F); + [Benchmark] public void Double() => SerializeAndDeserialize(123456.34D); + [Benchmark] public void Decimal() => SerializeAndDeserialize(123456.34M); + [Benchmark] public void Guids() => SerializeAndDeserialize(guid); + [Benchmark] public void DateTimes() => SerializeAndDeserialize(dateTime); + [Benchmark] public void TimeSpan() => SerializeAndDeserialize(time); + [Benchmark] public void String() => SerializeAndDeserialize(str); + [Benchmark] public void Type() => SerializeAndDeserialize(typeof(int)); + + [Benchmark] public void Tuple1() => SerializeAndDeserialize(Tuple.Create(1234)); + [Benchmark] public void Tuple2() => SerializeAndDeserialize(Tuple.Create(1234, "hello world")); + [Benchmark] public void Tuple3() => SerializeAndDeserialize(Tuple.Create(1234, "hello world", true)); + [Benchmark] public void Tuple4() => SerializeAndDeserialize(Tuple.Create(1234, "hello world", true, typeof(int))); + [Benchmark] public void Tuple5() => SerializeAndDeserialize(Tuple.Create(1234, "hello world", true, typeof(int), 345666UL)); + [Benchmark] public void Tuple6() => SerializeAndDeserialize(Tuple.Create(1234, "hello world", true, typeof(int), 345666UL, dateTime)); + [Benchmark] public void Tuple7() => SerializeAndDeserialize(Tuple.Create(1234, "hello world", true, typeof(int), 345666UL, dateTime, time)); + [Benchmark] public void Tuple8() => SerializeAndDeserialize(Tuple.Create(1234, "hello world", true, typeof(int), 345666UL, dateTime, time, guid)); + + [Benchmark] public void ValueTuple1() => SerializeAndDeserialize(ValueTuple.Create(1234)); + [Benchmark] public void ValueTuple2() => SerializeAndDeserialize(ValueTuple.Create(1234, "hello world")); + [Benchmark] public void ValueTuple3() => SerializeAndDeserialize(ValueTuple.Create(1234, "hello world", true)); + [Benchmark] public void ValueTuple4() => SerializeAndDeserialize(ValueTuple.Create(1234, "hello world", true, typeof(int))); + [Benchmark] public void ValueTuple5() => SerializeAndDeserialize(ValueTuple.Create(1234, "hello world", true, typeof(int), 345666UL)); + [Benchmark] public void ValueTuple6() => SerializeAndDeserialize(ValueTuple.Create(1234, "hello world", true, typeof(int), 345666UL, dateTime)); + [Benchmark] public void ValueTuple7() => SerializeAndDeserialize(ValueTuple.Create(1234, "hello world", true, typeof(int), 345666UL, dateTime, time)); + [Benchmark] public void ValueTuple8() => SerializeAndDeserialize(ValueTuple.Create(1234, "hello world", true, typeof(int), 345666UL, dateTime, time, guid)); + } +} \ No newline at end of file diff --git a/Hyperion.Benchmarks/SerializeStructsBenchmark.cs b/Hyperion.Benchmarks/SerializeStructsBenchmark.cs new file mode 100644 index 00000000..63fbd47d --- /dev/null +++ b/Hyperion.Benchmarks/SerializeStructsBenchmark.cs @@ -0,0 +1,80 @@ +#region copyright +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2016 AsynkronIT +// Copyright (C) 2016-2016 Akka.NET Team +// +// ----------------------------------------------------------------------- +#endregion + +using System.Runtime.InteropServices; +using BenchmarkDotNet.Attributes; + +namespace Hyperion.Benchmarks +{ + public class SerializeStructsBenchmark : HyperionBenchmark + { + #region init + private StandardStruct standardValue; + private BlittableStruct blittableValue; + private TestEnum testEnum; + + protected override void Init() + { + standardValue = new StandardStruct(1, "John", "Doe", isLoggedIn: false); + blittableValue = new BlittableStruct(59, 92); + testEnum = TestEnum.HatesAll; + } + + #endregion + + [Benchmark] public void Enums() => SerializeAndDeserialize(testEnum); + [Benchmark] public void Standard_Value_Types() => SerializeAndDeserialize(standardValue); + [Benchmark] public void Blittable_Value_Types() => SerializeAndDeserialize(blittableValue); + } + + #region test data types + + public struct StandardStruct + { + public readonly int Id; + public readonly string FirstName; + public readonly string LastName; + public readonly bool IsLoggedIn; + + public StandardStruct(int id, string firstName, string lastName, bool isLoggedIn) + : this() + { + Id = id; + FirstName = firstName; + LastName = lastName; + IsLoggedIn = isLoggedIn; + } + } + + /// + /// Blittable types have field layout matching their memory layout. + /// See: https://docs.microsoft.com/en-us/dotnet/framework/interop/blittable-and-non-blittable-types + /// + [StructLayout(LayoutKind.Sequential)] + public struct BlittableStruct + { + public readonly int X; + public readonly int Y; + + public BlittableStruct(int x, int y) : this() + { + X = x; + Y = y; + } + } + + public enum TestEnum + { + Married, + Divorced, + HatesAll + } + + #endregion +} \ No newline at end of file diff --git a/Hyperion.FSharpTestTypes/Hyperion.FSharpTestTypes.fsproj b/Hyperion.FSharpTestTypes/Hyperion.FSharpTestTypes.fsproj deleted file mode 100644 index 03d03aa1..00000000 --- a/Hyperion.FSharpTestTypes/Hyperion.FSharpTestTypes.fsproj +++ /dev/null @@ -1,24 +0,0 @@ - - - netstandard1.6;net45 - Hyperion.FSharpTestTypes - false - - - - - - - - - - - - - - - - - $(DefineConstants);AKKA - - \ No newline at end of file diff --git a/Hyperion.FSharpTestTypes/Script.fsx b/Hyperion.FSharpTestTypes/Script.fsx deleted file mode 100644 index 401ae0e4..00000000 --- a/Hyperion.FSharpTestTypes/Script.fsx +++ /dev/null @@ -1,8 +0,0 @@ -// Learn more about F# at http://fsharp.org. See the 'F# Tutorial' project -// for more guidance on F# programming. - -#load "Library1.fs" -open Hyperion.FSharpTestTypes - -// Define your library scripting code here - diff --git a/Hyperion.PerfTest/App.config b/Hyperion.PerfTest/App.config deleted file mode 100644 index 24eaab57..00000000 --- a/Hyperion.PerfTest/App.config +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Hyperion.PerfTest/Hyperion.PerfTest.csproj b/Hyperion.PerfTest/Hyperion.PerfTest.csproj deleted file mode 100644 index bd810aae..00000000 --- a/Hyperion.PerfTest/Hyperion.PerfTest.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - net451 - Hyperion.PerfTest - - - - - - - - - - - - - - - - - - - - - - - - - - $(DefineConstants);RELEASE - - diff --git a/Hyperion.PerfTest/ManualSerializer/CustomBinaryFormatter.cs b/Hyperion.PerfTest/ManualSerializer/CustomBinaryFormatter.cs deleted file mode 100644 index e5aaf782..00000000 --- a/Hyperion.PerfTest/ManualSerializer/CustomBinaryFormatter.cs +++ /dev/null @@ -1,121 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System; -using System.Collections.Generic; -using System.IO; -using System.Runtime.InteropServices; -using System.Runtime.Serialization; - -namespace Hyperion.PerfTest.ManualSerializer -{ - public interface ICustomBinarySerializable - { - void WriteDataTo(BinaryWriter writer); - void SetDataFrom(BinaryReader reader); - } - - public class CustomBinaryFormatter : IFormatter - { - private readonly Dictionary _byId = new Dictionary(); - private readonly Dictionary _byType = new Dictionary(); - private readonly byte[] _copyBuffer; - private readonly byte[] _lengthBuffer = new byte[4]; - private readonly BinaryReader _reader; - private readonly MemoryStream _readStream; - private readonly BinaryWriter _writer; - private readonly MemoryStream _writeStream; - - public CustomBinaryFormatter() - { - _copyBuffer = new byte[20000]; - _writeStream = new MemoryStream(10000); - _readStream = new MemoryStream(10000); - _writer = new BinaryWriter(_writeStream); - _reader = new BinaryReader(_readStream); - } - - public object Deserialize(Stream serializationStream) - { - if (serializationStream.Read(_lengthBuffer, 0, 4) != 4) - throw new SerializationException("Could not read length from the stream."); - var length = new IntToBytes(_lengthBuffer[0], _lengthBuffer[1], _lengthBuffer[2], _lengthBuffer[3]); - //TODO make this support partial reads from stream - if (serializationStream.Read(_copyBuffer, 0, length.I32) != length.I32) - throw new SerializationException("Could not read " + length + " bytes from the stream."); - _readStream.Seek(0L, SeekOrigin.Begin); - _readStream.Write(_copyBuffer, 0, length.I32); - _readStream.Seek(0L, SeekOrigin.Begin); - var typeid = _reader.ReadInt32(); - Type t; - if (!_byId.TryGetValue(typeid, out t)) - throw new SerializationException("TypeId " + typeid + " is not a registerred type id"); - var obj = FormatterServices.GetUninitializedObject(t); - var deserialize = (ICustomBinarySerializable) obj; - deserialize.SetDataFrom(_reader); - if (_readStream.Position != length.I32) - throw new SerializationException("object of type " + t + - " did not read its entire buffer during deserialization. This is most likely an inbalance between the writes and the reads of the object."); - return deserialize; - } - - public void Serialize(Stream serializationStream, object graph) - { - int key; - if (!_byType.TryGetValue(graph.GetType(), out key)) - throw new SerializationException(graph.GetType() + " has not been registered with the serializer"); - var c = (ICustomBinarySerializable) graph; //this will always work due to generic constraint on the Register - _writeStream.Seek(0L, SeekOrigin.Begin); - _writer.Write(key); - c.WriteDataTo(_writer); - var length = new IntToBytes((int) _writeStream.Position); - serializationStream.WriteByte(length.B0); - serializationStream.WriteByte(length.B1); - serializationStream.WriteByte(length.B2); - serializationStream.WriteByte(length.B3); - serializationStream.Write(_writeStream.GetBuffer(), 0, (int) _writeStream.Position); - } - - public ISurrogateSelector SurrogateSelector { get; set; } - - public SerializationBinder Binder { get; set; } - - public StreamingContext Context { get; set; } - - public void Register(int typeId) where T : ICustomBinarySerializable - { - _byId.Add(typeId, typeof(T)); - _byType.Add(typeof(T), typeId); - } - } - - [StructLayout(LayoutKind.Explicit)] - public struct IntToBytes - { - public IntToBytes(Int32 value) { B0 = B1 = B2 = B3 = 0; I32 = value; } - public IntToBytes(byte b0, byte b1, byte b2, byte b3) - { - I32 = 0; - B0 = b0; - B1 = b1; - B2 = b2; - B3 = b3; - } - [FieldOffset(0)] - public Int32 I32; - [FieldOffset(0)] - public byte B0; - [FieldOffset(1)] - public byte B1; - [FieldOffset(2)] - public byte B2; - [FieldOffset(3)] - public byte B3; - } -} \ No newline at end of file diff --git a/Hyperion.PerfTest/Properties/AssemblyInfo.cs b/Hyperion.PerfTest/Properties/AssemblyInfo.cs deleted file mode 100644 index 3d9003bc..00000000 --- a/Hyperion.PerfTest/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("35352664-e867-48ec-a0b1-39013ca42fe0")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] diff --git a/Hyperion.PerfTest/Tests/GuidArrayTest.cs b/Hyperion.PerfTest/Tests/GuidArrayTest.cs deleted file mode 100644 index 2a8de602..00000000 --- a/Hyperion.PerfTest/Tests/GuidArrayTest.cs +++ /dev/null @@ -1,27 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System; -using System.Collections.Generic; - -namespace Hyperion.PerfTest.Tests -{ - class GuidArrayTest : TestBase - { - protected override Guid[] GetValue() - { - var l = new List(); - for (int i = 0; i < 100; i++) - { - l.Add(Guid.NewGuid()); - } - return l.ToArray(); - } - } -} diff --git a/Hyperion.PerfTest/Tests/GuidTest.cs b/Hyperion.PerfTest/Tests/GuidTest.cs deleted file mode 100644 index 43a84df5..00000000 --- a/Hyperion.PerfTest/Tests/GuidTest.cs +++ /dev/null @@ -1,21 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System; - -namespace Hyperion.PerfTest.Tests -{ - class GuidTest : TestBase - { - protected override Guid GetValue() - { - return Guid.NewGuid(); - } - } -} diff --git a/Hyperion.PerfTest/Tests/LargeStructTest.cs b/Hyperion.PerfTest/Tests/LargeStructTest.cs deleted file mode 100644 index 6b01bbaf..00000000 --- a/Hyperion.PerfTest/Tests/LargeStructTest.cs +++ /dev/null @@ -1,21 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using Hyperion.PerfTest.Types; - -namespace Hyperion.PerfTest.Tests -{ - internal class LargeStructTest : TestBase - { - protected override LargeStruct GetValue() - { - return LargeStruct.Create(); - } - } -} \ No newline at end of file diff --git a/Hyperion.PerfTest/Tests/TestBase.cs b/Hyperion.PerfTest/Tests/TestBase.cs deleted file mode 100644 index 65d67531..00000000 --- a/Hyperion.PerfTest/Tests/TestBase.cs +++ /dev/null @@ -1,469 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Runtime.Serialization.Formatters.Binary; -using System.Text; -using Newtonsoft.Json; -using NFX.IO; -using NFX.Serialization.Slim; -using ServiceStack.Text; -using ZeroFormatter; - -namespace Hyperion.PerfTest.Tests -{ - internal class TestResult - { - public string TestName { get; set; } - public TimeSpan SerializationTime { get; set; } - public TimeSpan DeserializationTime { get; set; } - public TimeSpan RoundtripTime => SerializationTime + DeserializationTime; - public int PayloadSize { get; set; } - public bool Success { get; set; } - } - - //Commented out serializers fail in different ways, throw or produce no output - - internal abstract class TestBase - { - private readonly List _results = new List(); - protected int Repeat; - protected T Value; - - protected abstract T GetValue(); - - public void Run(int repeat) - { - Repeat = repeat; - Value = GetValue(); - Console.WriteLine(); - var testName = GetType().Name; - - //for (int i = 0; i < 100; i++) - //{ - // SerializeKnownTypesReuseSession(); - // SerializeKnownTypes(); - // SerializeNetSerializer(); - //} - - Console.WriteLine($"# Test {testName}"); - Console.WriteLine(); - Console.WriteLine("## Running cold"); - Console.WriteLine("```"); - TestAll(); - Console.WriteLine("```"); - Console.WriteLine(); - Console.WriteLine("## Running hot"); - _results.Clear(); - Console.WriteLine("```"); - TestAll(); - Console.WriteLine("```"); - - var fastestSerializer = _results.OrderBy(r => r.SerializationTime).First(); - var fastestDeserializer = _results.OrderBy(r => r.DeserializationTime).First(); - var fastestRoundtrip = _results.OrderBy(r => r.SerializationTime + r.DeserializationTime).First(); - var smallestPayload = _results.OrderBy(r => r.PayloadSize).First(); - - Console.WriteLine( - $"* **Fastest Serializer**: {fastestSerializer.TestName} - {(long) fastestSerializer.SerializationTime.TotalMilliseconds} ms"); - Console.WriteLine( - $"* **Fastest Deserializer**: {fastestDeserializer.TestName} - {(long) fastestDeserializer.DeserializationTime.TotalMilliseconds} ms"); - Console.WriteLine( - $"* **Fastest Roundtrip**: {fastestRoundtrip.TestName} - {(long) fastestRoundtrip.RoundtripTime.TotalMilliseconds} ms"); - Console.WriteLine( - $"* **Smallest Payload**: {smallestPayload.TestName} - {smallestPayload.PayloadSize} bytes"); - - SaveTestResult($"{testName}_roundtrip", _results.OrderBy(r => r.RoundtripTime.TotalMilliseconds)); - SaveTestResult($"{testName}_serialize", _results.OrderBy(r => r.SerializationTime.TotalMilliseconds)); - SaveTestResult($"{testName}_deserialize", _results.OrderBy(r => r.DeserializationTime.TotalMilliseconds)); - SaveTestResult($"{testName}_payload", _results.OrderBy(r => r.PayloadSize)); - } - - protected virtual void TestAll() - { - SerializeZeroFormatter(); - SerializeZeroFormatterWithPooling(); - SerializeKnownTypesReuseSession(); - SerializeKnownTypes(); - SerializeDefault(); - SerializeVersionTolerant(); - SerializeVersionPreserveObjects(); - SerializeNFXSlim(); - SerializeNFXSlimPreregister(); - SerializeSSText(); - SerializeNetSerializer(); - SerializeProtoBufNet(); - SerializeJsonNet(); - SerializeBinaryFormatter(); - } - - private void SaveTestResult(string testName, IEnumerable result) - { - var sb = new StringBuilder(); - sb.AppendLine($"## {testName}"); - sb.AppendLine("test | roundtrip | serialize | deserialize | size"); - sb.AppendLine("-----|----------:|----------:|------------:|-----:"); - foreach (var row in result) - { - sb.AppendLine( - $"{row.TestName} | {(long) row.RoundtripTime.TotalMilliseconds} | {(long) row.SerializationTime.TotalMilliseconds} | {(long) row.DeserializationTime.TotalMilliseconds} | {row.PayloadSize}"); - } - var file = testName + ".txt"; - File.WriteAllText(file, sb.ToString()); - } - - //private void SerializeNetJson() - //{ - // var s = new MemoryStream(); - // var res = NetJSON.NetJSON.Serialize(Value); - // var size = Encoding.UTF8.GetBytes(res).Length; - - - // RunTest("NET-JSON", () => - // { - // NetJSON.NetJSON.Serialize(Value); - // }, () => { NetJSON.NetJSON.Deserialize(res); }, size); - //} - - private void SerializeJsonNet() - { - var settings = new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.All - //ReferenceLoopHandling = ReferenceLoopHandling.Serialize, - //PreserveReferencesHandling = PreserveReferencesHandling.All - }; - var data = JsonConvert.SerializeObject(Value, settings); - RunTest("Json.NET", () => { JsonConvert.SerializeObject(Value, settings); }, - () => { JsonConvert.DeserializeObject(data, settings); }, Encoding.UTF8.GetBytes(data).Length); - } - - protected void RunTest(string testName, Action serialize, Action deserialize, int size) - { - try - { - var tmp = Console.ForegroundColor; - Console.ForegroundColor = ConsoleColor.Yellow; - Console.WriteLine($"{testName}"); - Console.ForegroundColor = tmp; - - GC.Collect(2, GCCollectionMode.Forced, true); - - var sw = Stopwatch.StartNew(); - for (var i = 0; i < Repeat; i++) - { - serialize(); - } - sw.Stop(); - - Console.WriteLine($" {"Serialize".PadRight(30, ' ')} {sw.ElapsedMilliseconds} ms"); - - GC.Collect(2, GCCollectionMode.Forced, true); - - var sw2 = Stopwatch.StartNew(); - for (var i = 0; i < Repeat; i++) - { - deserialize(); - } - sw2.Stop(); - - Console.WriteLine($" {"Deserialize".PadRight(30, ' ')} {sw2.ElapsedMilliseconds} ms"); - Console.WriteLine($" {"Size".PadRight(30, ' ')} {size} bytes"); - Console.WriteLine( - $" {"Total".PadRight(30, ' ')} {sw.ElapsedMilliseconds + sw2.ElapsedMilliseconds} ms"); - var testResult = new TestResult - { - TestName = testName, - DeserializationTime = sw2.Elapsed, - SerializationTime = sw.Elapsed, - PayloadSize = size, - Success = true - }; - _results.Add(testResult); - } - catch - { - Console.WriteLine($" FAILURE"); - } - } - - //private void SerializeMessageShark() - //{ - // var bytes = MessageShark.MessageSharkSerializer.Serialize(Value); - // RunTest("MessageShark", () => - // { - // MessageShark.MessageSharkSerializer.Serialize(Value); - // }, () => - // { - // MessageShark.MessageSharkSerializer.Deserialize(bytes); - // }, bytes.Length); - //} - - private void SerializeProtoBufNet() - { - var s = new MemoryStream(); - ProtoBuf.Serializer.Serialize(s, Value); - var bytes = s.ToArray(); - RunTest("Protobuf.NET", () => - { - var stream = new MemoryStream(); - ProtoBuf.Serializer.Serialize(stream, Value); - }, () => - { - s.Position = 0; - ProtoBuf.Serializer.Deserialize(s); - }, bytes.Length); - } - - private void SerializeNFXSlimPreregister() - { - var s = new MemoryStream(); - var serializer = new SlimSerializer(); - serializer.TypeMode = TypeRegistryMode.Batch; - serializer.Serialize(s, Value); //Serialize 1st in batch - - var deserializer = new SlimSerializer(); - deserializer.TypeMode = TypeRegistryMode.Batch; - s.Position = 0; //Deserialize first in batch - deserializer.Deserialize(s); - - s = new MemoryStream(); //serialize subsequent in batch - serializer.Serialize(s, Value); - var bytes = s.ToArray(); - - var stream = new MemoryStream(); - - RunTest("NFX Slim Serializer - KnownTypes", () => - { - stream.Position = 0; - serializer.Serialize(stream, Value); - }, () => - { - s.Position = 0; - deserializer.Deserialize(s); - }, bytes.Length); - } - - private void SerializeSSText() - { - var serializer = new TypeSerializer(); - var text = serializer.SerializeToString(Value); - var bytes = Encoding.UTF8.GetBytes(text); - - RunTest("ServiceStack.Text", () => { serializer.SerializeToString(Value); }, - () => { serializer.DeserializeFromString(text); }, bytes.Length); - } - - private void SerializeNFXSlim() - { - var s = new MemoryStream(); - var serializer = new SlimSerializer(SlimFormat.Instance); - serializer.Serialize(s, Value); - var bytes = s.ToArray(); - - RunTest("NFX Slim Serializer", () => - { - var stream = new MemoryStream(); - serializer.Serialize(stream, Value); - }, () => - { - s.Position = 0; - serializer.Deserialize(s); - }, bytes.Length); - } - - private void SerializeNetSerializer() - { - var s = new MemoryStream(); - var serializer = new NetSerializer.Serializer(new[] {typeof(T)}); - serializer.Serialize(s, Value); - var bytes = s.ToArray(); - - RunTest("Net Serializer", () => - { - var stream = new MemoryStream(); - serializer.Serialize(stream, Value); - }, () => - { - s.Position = 0; - serializer.Deserialize(s); - }, bytes.Length); - } - - //private void SerializeJil() - //{ - // var s = new MemoryStream(); - // var res = JSON.Serialize(Value); - - // var bytes = s.ToArray(); - // RunTest("Jil", () => - // { - // JSON.Serialize(Value); - // }, () => { JSON.Deserialize(res, typeof(T)); }, bytes.Length); - //} - - //private void SerializeFsPickler() - //{ - // var pickler = MBrace.FsPickler.FsPickler.CreateBinarySerializer(); - // var s = new MemoryStream(); - // pickler.Serialize(s, Value); - // var bytes = s.ToArray(); - // RunTest("FsPickler", () => - // { - // var stream = new MemoryStream(); - // pickler.Serialize(stream, Value); - // }, () => - // { - // s.Position = 0; - // pickler.Deserialize(s); - // }, bytes.Length); - //} - - private void SerializeBinaryFormatter() - { - var bf = new BinaryFormatter(); - var s = new MemoryStream(); - - bf.Serialize(s, Value); - var bytes = s.ToArray(); - RunTest("Binary formatter", () => - { - var stream = new MemoryStream(); - bf.Serialize(stream, Value); - }, () => - { - s.Position = 0; - var o = bf.Deserialize(s); - }, bytes.Length); - } - - private void SerializeZeroFormatter() - { - var bytes = ZeroFormatterSerializer.Serialize(Value); - RunTest("ZeroFormatter", () => { ZeroFormatterSerializer.Serialize(Value); }, - () => { ZeroFormatterSerializer.Deserialize(bytes); }, bytes.Length); - } - - private void SerializeZeroFormatterWithPooling() - { - var bytes = ZeroFormatterSerializer.Serialize(Value); - RunTest("ZeroFormatterWithPooling", () => { ZeroFormatterSerializer.Serialize(ref bytes, 0, Value); }, - () => { ZeroFormatterSerializer.Deserialize(bytes); }, bytes.Length); - } - - - private void SerializeKnownTypesReuseSession() - { - var types = typeof(T).Namespace.StartsWith("System") ? null : new[] {typeof(T)}; - var serializer = new Serializer(new SerializerOptions(knownTypes: types)); - var ss = serializer.GetSerializerSession(); - var ds = serializer.GetDeserializerSession(); - var s = new MemoryStream(); - serializer.Serialize(Value, s, ss); - var bytes = s.ToArray(); - - RunTest("Hyperion - KnownTypes + Reuse Sessions", () => - { - var stream = new MemoryStream(); - serializer.Serialize(Value, stream, ss); - }, () => - { - s.Position = 0; - serializer.Deserialize(s, ds); - }, bytes.Length); - } - - private void SerializeKnownTypes() - { - var types = typeof(T).Namespace.StartsWith("System") ? null : new[] {typeof(T)}; - var serializer = new Serializer(new SerializerOptions(knownTypes: types)); - var s = new MemoryStream(); - serializer.Serialize(Value, s); - var bytes = s.ToArray(); - - RunTest("Hyperion - KnownTypes", () => - { - var stream = new MemoryStream(); - serializer.Serialize(Value, stream); - }, () => - { - s.Position = 0; - serializer.Deserialize(s); - }, bytes.Length); - } - - private void SerializeDefault() - { - var serializer = new Serializer(new SerializerOptions(false)); - var s = new MemoryStream(); - serializer.Serialize(Value, s); - var bytes = s.ToArray(); - RunTest("Hyperion - Default", () => - { - var stream = new MemoryStream(); - serializer.Serialize(Value, stream); - }, () => - { - s.Position = 0; - serializer.Deserialize(s); - }, bytes.Length); - } - - private void SerializeVersionPreserveObjects() - { - var serializer = new Serializer(new SerializerOptions(false, true)); - var s = new MemoryStream(); - serializer.Serialize(Value, s); - var bytes = s.ToArray(); - RunTest("Hyperion - Object Identity", () => - { - var stream = new MemoryStream(); - serializer.Serialize(Value, stream); - }, () => - { - s.Position = 0; - serializer.Deserialize(s); - }, bytes.Length); - } - - private void SerializeVersionTolerant() - { - var serializer = new Serializer(new SerializerOptions(true)); - var s = new MemoryStream(); - serializer.Serialize(Value, s); - var bytes = s.ToArray(); - s.Position = 0; - RunTest("Hyperion - Version Tolerant", () => - { - var stream = new MemoryStream(); - - serializer.Serialize(Value, stream); - }, () => - { - s.Position = 0; - serializer.Deserialize(s); - }, bytes.Length); - } - } - - internal abstract class CustomSerializerTestBase : TestBase - { - protected override void TestAll() - { - CustomTest(); - base.TestAll(); - } - - protected abstract void CustomTest(); - } -} \ No newline at end of file diff --git a/Hyperion.PerfTest/Tests/TypicalMessageArrayTest.cs b/Hyperion.PerfTest/Tests/TypicalMessageArrayTest.cs deleted file mode 100644 index e69ffc39..00000000 --- a/Hyperion.PerfTest/Tests/TypicalMessageArrayTest.cs +++ /dev/null @@ -1,37 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System; -using System.Collections.Generic; -using Hyperion.PerfTest.Types; - -namespace Hyperion.PerfTest.Tests -{ - class TypicalMessageArrayTest : TestBase - { - protected override TypicalMessage[] GetValue() - { - var l = new List(); - - for (var i = 0; i < 100; i++) - { - var v = new TypicalMessage() - { - StringProp = "hello", - GuidProp = Guid.NewGuid(), - IntProp = 123, - DateProp = DateTime.UtcNow - }; - l.Add(v); - } - - return l.ToArray(); - } - } -} diff --git a/Hyperion.PerfTest/Tests/TypicalMessageTest.cs b/Hyperion.PerfTest/Tests/TypicalMessageTest.cs deleted file mode 100644 index 64a0dbe7..00000000 --- a/Hyperion.PerfTest/Tests/TypicalMessageTest.cs +++ /dev/null @@ -1,91 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System; -using System.IO; -using Hyperion.PerfTest.ManualSerializer; -using Hyperion.PerfTest.Types; - -namespace Hyperion.PerfTest.Tests -{ - class CustomTypicalMessage : ICustomBinarySerializable - { - public string StringProp { get; set; } - public int IntProp { get; set; } - public Guid GuidProp { get; set; } - public DateTime DateProp { get; set; } - - public void WriteDataTo(BinaryWriter writer) - { - writer.Write(StringProp); - writer.Write(IntProp); - writer.Write(GuidProp.ToByteArray()); - writer.Write(DateProp.Ticks); - writer.Write((byte)DateProp.Kind); - } - - public void SetDataFrom(BinaryReader reader) - { - StringProp = reader.ReadString(); - IntProp = reader.ReadInt32(); - var bytes = reader.ReadBytes(16); - GuidProp= new Guid(bytes); - var ticks = reader.ReadInt64(); - var kind = reader.ReadByte(); - DateProp = new DateTime(ticks,(DateTimeKind)kind); - } - } - class TypicalMessageTest : TestBase - { - protected override TypicalMessage GetValue() - { - return new TypicalMessage() - { - StringProp = "hello", - GuidProp = Guid.NewGuid(), - IntProp = 123, - DateProp = DateTime.UtcNow - }; - } - - protected override void TestAll() - { - SerializeCustom(); - base.TestAll(); - } - - private void SerializeCustom() - { - var s = new CustomBinaryFormatter(); - var message = new CustomTypicalMessage() - { - StringProp = "hello", - GuidProp = Guid.NewGuid(), - IntProp = 123, - DateProp = DateTime.UtcNow, - }; - s.Register(0); - - var stream = new MemoryStream(); - s.Serialize(stream, message); - var bytes = stream.ToArray(); - RunTest("Greg Young Custom Serializer", () => - { - var stream2 = new MemoryStream(); - s.Serialize(stream2, message); - }, - () => - { - stream.Position = 0; - s.Deserialize(stream); - }, bytes.Length); - - } - } -} diff --git a/Hyperion.PerfTest/Tests/TypicalPersonArrayTest.cs b/Hyperion.PerfTest/Tests/TypicalPersonArrayTest.cs deleted file mode 100644 index 78f6b356..00000000 --- a/Hyperion.PerfTest/Tests/TypicalPersonArrayTest.cs +++ /dev/null @@ -1,27 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System.Collections.Generic; -using Hyperion.PerfTest.Types; - -namespace Hyperion.PerfTest.Tests -{ - class TypicalPersonArrayTest : TestBase - { - protected override TypicalPersonData[] GetValue() - { - var l = new List(); - for (int i = 0; i < 100; i++) - { - l.Add(TypicalPersonData.MakeRandom()); - } - return l.ToArray(); - } - } -} diff --git a/Hyperion.PerfTest/Tests/TypicalPersonTest.cs b/Hyperion.PerfTest/Tests/TypicalPersonTest.cs deleted file mode 100644 index f7b9e633..00000000 --- a/Hyperion.PerfTest/Tests/TypicalPersonTest.cs +++ /dev/null @@ -1,21 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using Hyperion.PerfTest.Types; - -namespace Hyperion.PerfTest.Tests -{ - class TypicalPersonTest : TestBase - { - protected override TypicalPersonData GetValue() - { - return TypicalPersonData.MakeRandom(); - } - } -} diff --git a/Hyperion.PerfTest/Types/LargeStruct.cs b/Hyperion.PerfTest/Types/LargeStruct.cs deleted file mode 100644 index 2d375167..00000000 --- a/Hyperion.PerfTest/Types/LargeStruct.cs +++ /dev/null @@ -1,69 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System; -using ProtoBuf; -using ZeroFormatter; - -namespace Hyperion.PerfTest.Types -{ - [Serializable] - [ProtoContract] - [ZeroFormattable] - public struct LargeStruct - { - private static void A(bool b) - { - if (!b) - throw new Exception(); - } - - [Index(0)] - [ProtoMember(1)] - public ulong m_val1; - [Index(1)] - [ProtoMember(2)] - public ulong m_val2; - [Index(2)] - [ProtoMember(3)] - public ulong m_val3; - [Index(3)] - [ProtoMember(4)] - public ulong m_val4; - - private static ulong counter; - - public LargeStruct(ulong m_val1, ulong m_val2, ulong m_val3, ulong m_val4) - { - this.m_val1 = m_val1; - this.m_val2 = m_val2; - this.m_val3 = m_val3; - this.m_val4 = m_val4; - } - - public static LargeStruct Create() - { - return new LargeStruct - { - m_val1 = counter++, - m_val2 = ulong.MaxValue - counter++, - m_val3 = counter++, - m_val4 = ulong.MaxValue - counter++ - }; - } - - public static void Compare(LargeStruct a, LargeStruct b) - { - A(a.m_val1 == b.m_val1); - A(a.m_val2 == b.m_val2); - A(a.m_val3 == b.m_val3); - A(a.m_val4 == b.m_val4); - } - } -} \ No newline at end of file diff --git a/Hyperion.PerfTest/Types/TypicalMessage.cs b/Hyperion.PerfTest/Types/TypicalMessage.cs deleted file mode 100644 index a450c83a..00000000 --- a/Hyperion.PerfTest/Types/TypicalMessage.cs +++ /dev/null @@ -1,37 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System; -using ProtoBuf; -using ZeroFormatter; - -namespace Hyperion.PerfTest.Types -{ - [ProtoContract] - [Serializable] - [ZeroFormattable] - public class TypicalMessage - { - [ProtoMember(1)] - [Index(0)] - public virtual string StringProp { get; set; } - - [ProtoMember(2)] - [Index(1)] - public virtual int IntProp { get; set; } - - [ProtoMember(3)] - [Index(2)] - public virtual Guid GuidProp { get; set; } - - [ProtoMember(4)] - [Index(3)] - public virtual DateTime DateProp { get; set; } - } -} diff --git a/Hyperion.PerfTest/Types/TypicalPerson.cs b/Hyperion.PerfTest/Types/TypicalPerson.cs deleted file mode 100644 index b7c4bd40..00000000 --- a/Hyperion.PerfTest/Types/TypicalPerson.cs +++ /dev/null @@ -1,276 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System; -using System.Runtime.Serialization; -using ProtoBuf; -using ZeroFormatter; - -namespace Hyperion.PerfTest.Types -{ - [DataContract] - public enum MaritalStatus - { - [EnumMember] - Married, - [EnumMember] - Divorced, - [EnumMember] - HatesAll - } - - [ProtoContract] - [DataContract] - [Serializable] - [ZeroFormattable] - public class TypicalPersonData - { - /// - /// Required by some serilizers (i.e. XML) - /// - public TypicalPersonData() { } - - - [ProtoMember(1)] - [DataMember] - [Index(0)] - public virtual string Address1 { get; set; } - - [ProtoMember(2)] - [DataMember] - [Index(1)] - public virtual string Address2 { get; set; } - - [ProtoMember(3)] - [DataMember] - [Index(2)] - public virtual string AddressCity { get; set; } - - [ProtoMember(4)] - [DataMember] - [Index(3)] - public virtual string AddressState { get; set; } - - [ProtoMember(5)] - [DataMember] - [Index(4)] - public virtual string AddressZip { get; set; } - - [ProtoMember(6)] - [DataMember] - [Index(5)] - public virtual double CreditScore { get; set; } - - [ProtoMember(7)] - [DataMember] - [Index(6)] - public virtual DateTime DOB { get; set; } - - [ProtoMember(8)] - [DataMember] - [Index(7)] - public virtual string EMail { get; set; } - - [ProtoMember(9)] - [DataMember] - [Index(8)] - public virtual string FirstName { get; set; } - - [ProtoMember(10)] - [DataMember] - [Index(9)] - public virtual string HomePhone { get; set; } - - [ProtoMember(11)] - [DataMember] - [Index(10)] - public virtual string LastName { get; set; } - - [ProtoMember(12)] - [DataMember] - [Index(11)] - public virtual MaritalStatus MaritalStatus { get; set; } - - [ProtoMember(13)] - [DataMember] - [Index(12)] - public virtual string MiddleName { get; set; } - - [ProtoMember(14)] - [DataMember] - [Index(13)] - public virtual string MobilePhone { get; set; } - - [ProtoMember(15)] - [DataMember] - [Index(14)] - public virtual bool RegisteredToVote { get; set; } - - [ProtoMember(16)] - [DataMember] - [Index(15)] - public virtual decimal Salary { get; set; } - - [ProtoMember(17)] - [DataMember] - [Index(16)] - public virtual int YearsOfService { get; set; } - - - - [ProtoMember(18)] - [DataMember] - [Index(17)] - public virtual string SkypeID { get; set; } - [ProtoMember(19)] - [DataMember] - [Index(18)] - public virtual string YahooID { get; set; } - [ProtoMember(20)] - [DataMember] - [Index(19)] - public virtual string GoogleID { get; set; } - - [ProtoMember(21)] - [DataMember] - [Index(20)] - public virtual string Notes { get; set; } - - [ProtoMember(22)] - [DataMember] - [Index(21)] - public virtual bool? IsSmoker { get; set; } - [ProtoMember(23)] - [DataMember] - [Index(22)] - public virtual bool? IsLoving { get; set; } - [ProtoMember(24)] - [DataMember] - [Index(23)] - public virtual bool? IsLoved { get; set; } - [ProtoMember(25)] - [DataMember] - [Index(24)] - public virtual bool? IsDangerous { get; set; } - [ProtoMember(26)] - [DataMember] - [Index(25)] - public virtual bool? IsEducated { get; set; } - [ProtoMember(27)] - [DataMember] - [Index(26)] - public virtual DateTime? LastSmokingDate { get; set; } - - [ProtoMember(28)] - [DataMember] - [Index(27)] - public virtual decimal? DesiredSalary { get; set; } - [ProtoMember(29)] - [DataMember] - [Index(28)] - public virtual double? ProbabilityOfSpaceFlight { get; set; } - - [ProtoMember(30)] - [DataMember] - [Index(29)] - public virtual int? CurrentFriendCount { get; set; } - [ProtoMember(31)] - [DataMember] - [Index(30)] - public virtual int? DesiredFriendCount { get; set; } - - - private static int counter; - public static TypicalPersonData MakeRandom() - { - var rnd = counter++; - - var data = new TypicalPersonData - { - FirstName = NaturalTextGenerator.GenerateFirstName(), - MiddleName = NaturalTextGenerator.GenerateFirstName(), - LastName = NaturalTextGenerator.GenerateLastName(), - DOB = DateTime.Now.AddYears(5), - Salary = 55435345, - YearsOfService = 25, - CreditScore = 0.7562, - RegisteredToVote = (DateTime.UtcNow.Ticks & 1) == 0, - MaritalStatus = MaritalStatus.HatesAll, - Address1 = NaturalTextGenerator.GenerateAddressLine(), - Address2 = NaturalTextGenerator.GenerateAddressLine(), - AddressCity = NaturalTextGenerator.GenerateCityName(), - AddressState = "CA", - AddressZip = "91606", - HomePhone = (DateTime.UtcNow.Ticks & 1) == 0 ? "(555) 123-4567" : null, - EMail = NaturalTextGenerator.GenerateEMail() - }; - - if (0 != (rnd & (1 << 32))) data.Notes = NaturalTextGenerator.Generate(45); - if (0 != (rnd & (1 << 31))) data.SkypeID = NaturalTextGenerator.GenerateEMail(); - if (0 != (rnd & (1 << 30))) data.YahooID = NaturalTextGenerator.GenerateEMail(); - - if (0 != (rnd & (1 << 29))) data.IsSmoker = 0 != (rnd & (1 << 17)); - if (0 != (rnd & (1 << 28))) data.IsLoving = 0 != (rnd & (1 << 16)); - if (0 != (rnd & (1 << 27))) data.IsLoved = 0 != (rnd & (1 << 15)); - if (0 != (rnd & (1 << 26))) data.IsDangerous = 0 != (rnd & (1 << 14)); - if (0 != (rnd & (1 << 25))) data.IsEducated = 0 != (rnd & (1 << 13)); - - if (0 != (rnd & (1 << 24))) data.LastSmokingDate = DateTime.Now.AddYears(-10); - - - if (0 != (rnd & (1 << 23))) data.DesiredSalary = rnd / 1000m; - if (0 != (rnd & (1 << 22))) data.ProbabilityOfSpaceFlight = rnd / (double)int.MaxValue; - - if (0 != (rnd & (1 << 21))) - { - data.CurrentFriendCount = rnd % 123; - data.DesiredFriendCount = rnd % 121000; - } - - return data; - } - } - - public class NaturalTextGenerator - { - public static string GenerateEMail() - { - return "foo@fooo.com"; - } - - public static string Generate(int i) - { - return "fskldjflksjfl ksj dlfkjsdfl ksdjklf jsdlkj" + DateTime.Now.Ticks; - } - - public static string GenerateAddressLine() - { - return "fkjdskfjskfjs" + DateTime.Now.Ticks; - } - - public static string GenerateFirstName() - { - return "fksjdfkjsdkfjksdfs" + DateTime.Now.Ticks; - } - - public static string GenerateCityName() - { - return "fksdfkjsdkfjsdkfs"; - } - - public static string GenerateLastName() - { - return "kfjdskdfjskj"; - } - } - - public class ExternalRandomGenerator - { - } -} diff --git a/Hyperion.PerformanceTests/Hyperion.PerformanceTests.csproj b/Hyperion.PerformanceTests/Hyperion.PerformanceTests.csproj deleted file mode 100644 index 6f4876cd..00000000 --- a/Hyperion.PerformanceTests/Hyperion.PerformanceTests.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - net452 - Hyperion.PerformanceTests - - - - - - - - - - - - - - - - - - - - - - $(DefineConstants);RELEASE - - diff --git a/Hyperion.PerformanceTests/Properties/AssemblyInfo.cs b/Hyperion.PerformanceTests/Properties/AssemblyInfo.cs deleted file mode 100644 index 848f6c93..00000000 --- a/Hyperion.PerformanceTests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,33 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("19e9324e-c3e9-4751-8b8f-5a456ca98e8c")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] diff --git a/Hyperion.PerformanceTests/SpeedAndSizeTests.cs b/Hyperion.PerformanceTests/SpeedAndSizeTests.cs deleted file mode 100644 index 402ccf37..00000000 --- a/Hyperion.PerformanceTests/SpeedAndSizeTests.cs +++ /dev/null @@ -1,354 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Text; -using MBrace.FsPickler; -using Microsoft.FSharp.Collections; -using Xunit; - -namespace Hyperion.PerformanceTests -{ - public class SpeedAndSizeTests - { - [Serializable] - public class CyclicA - { - public CyclicB B { get; set; } - } - - [Serializable] - public class CyclicB - { - public CyclicA A { get; set; } - } - - [Serializable] - public class Poco - { - public int Age { get; set; } - public string Name { get; set; } - } - - [Fact] - public void TestPocoArray() - { - var arr = new Poco[200]; - for (var i = 0; i < arr.Length; i++) - { - arr[i] = new Poco() - { - Name = "Foo" + i, - Age = i - }; - } - - Test(arr); - } - - [Fact] - public void TestDateTime() - { - Test(DateTime.Now); - } - - [Fact] - public void TestDateTimeArray() - { - var arr = new DateTime[200]; - for (var i = 0; i < arr.Length; i++) - { - arr[i] = DateTime.Now; - } - - Test(arr); - } - - [Fact] - public void TestGuidArray() - { - var arr = new Guid[200]; - for (var i = 0; i < arr.Length; i++) - { - arr[i] = Guid.NewGuid(); - } - - Test(arr); - } - - [Fact] - public void TestIntArray() - { - var arr = new int[1000]; - for (var i = 0; i < arr.Length; i++) - { - arr[i] = i; - } - - Test(arr); - } - - [Fact] - public void TestStringShort() - { - - Test("hello"); - } - - [Fact] - public void TestStringLong() - { - var sb = new StringBuilder(); - sb.Append("Hello"); - for (var i = 0; i < 14; i++) - { - sb.Append(sb); - } - Test(sb.ToString()); - } - - - //TODO: fails as FsPickler uses 2 bytes for length encoding instead of 4 as Hyperion does - //our payload gets bigger - [Fact] - public void TestStringArray() - { - var arr = new string[1000]; - for (var i = 0; i < arr.Length; i++) - { - arr[i] = "hello"; - } - - Test(arr); - } - - - [Fact] - public void TestByteArray() - { - var arr = new byte[1000]; - for (var i = 0; i < arr.Length; i++) - { - arr[i] = (byte)(i%255); - } - - Test(arr); - } - - [Fact] - public void TestType() - { - Test(typeof(int)); - } - - - - ///fails big time, we are writing the entire qualified type name for each entry, fs pickler does not. - [Fact] - public void TestTypeArray() - { - var arr = new Type[100]; - for (var i = 0; i < arr.Length; i++) - { - arr[i] = typeof (int); - } - - Test(arr); - } - - [Fact()] - public void TestGuid() - { - Test(Guid.NewGuid()); - } - - [Fact] - public void TestBoolArray() - { - var arr = new bool[1000]; - for (var i = 0; i < arr.Length; i++) - { - arr[i] = i % 2 == 0; - } - - Test(arr); - } - - - [Fact] - public void TestTuple() - { - Test(Tuple.Create(123,456)); - } - - [Serializable] - public class FakeTupleIntInt - { - public int Item1 { get; set; } - public int Item2 { get; set; } - } - - [Fact] - public void TestTupleLikeArray() - { - var arr = new FakeTupleIntInt[100]; - for (var i = 0; i < arr.Length; i++) - { - arr[i] = new FakeTupleIntInt - { - Item2 = i, - Item1 = 999 - i, - }; - } - - Test(arr); - } - - [Fact(Skip = "Slow test (?)")] //this is slow because we can not codegen setters for readonly fields yet (expressions, we need IL compiler first) - public void TestTupleArray() - { - var arr = new Tuple[100]; - for (var i = 0; i < arr.Length; i++) - { - arr[i] = Tuple.Create(i, 999 - i); - } - - Test(arr); - } - - [Fact] - public void TestList() - { - var list = new List() - { - 123, - 456, - 789, - 111, - 222 - }; - Test(list); - } - - [Fact] - public void TestInt() - { - Test(123456); - } - - [Fact] - public void TestPocoSmall() - { - Test(new Poco() - { - Age = 40, - Name = "Roger" - }); - } - - [Fact] - //fails as our payload is bigger, probably due to qualified typename, we are faster though - public void TestCyclic() - { - var a = new CyclicA(); - var b = new CyclicB(); - a.B = b; - b.A = a; - - Test(a); - } - - [Fact] - public void TestIntDictionary() - { - var dict = new Dictionary() - { - [123] = 123, - [555] = 789, - [666] = 999, - }; - Test(dict); - } - - [Fact] - public void TestFSharpList() - { - var list = - ListModule.OfArray(new[] - { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, - 6, 7, 8, 9, 0 - }); - Test(list); - } - - private static void Test(object value) - { - var wireSerializer = new Serializer(new SerializerOptions(false,true,null, null)); - var pickler = FsPickler.CreateBinarySerializer(); - - double wireTs; - double picklerTs; - long wireSize; - long picklerSize; - const int repeat = 10000; - { - var wireStream = new MemoryStream(); - wireSerializer.Serialize(value, wireStream); - - var sw = Stopwatch.StartNew(); - for (var i = 0; i < repeat; i++) - { - wireStream = new MemoryStream(); - HyperionSerialize(value, wireSerializer, wireStream); - } - sw.Stop(); - wireTs = sw.Elapsed.TotalMilliseconds; - wireSize = wireStream.ToArray().Length; - } - - - //using (MemoryStream picklerStram = new MemoryStream()) - { - var picklerStram = new MemoryStream(); - pickler.Serialize(picklerStram,value); - var sw = Stopwatch.StartNew(); - for (var i = 0; i < repeat; i++) - { - picklerStram = new MemoryStream(); - pickler.Serialize(picklerStram, value); - } - sw.Stop(); - picklerTs = sw.Elapsed.TotalMilliseconds; - picklerSize = picklerStram.ToArray().Length; - } - Console.WriteLine($"Serializing {value.GetType().Name} {repeat:n0} times"); - Console.WriteLine(); - Console.WriteLine($"Hyperion elapsed time {wireTs:n0} MS"); - Console.WriteLine($"FsPickler elapsed time {picklerTs:n0} MS"); - Console.WriteLine($"Hyperion is {picklerTs / wireTs :n2} times faster than FsPickler"); - Console.WriteLine(); - Console.WriteLine($"Hyperion payload size {wireSize} bytes"); - Console.WriteLine($"FsPickler payload size {picklerSize} bytes"); - Console.WriteLine($"Hyperion is {picklerSize / (double)wireSize:n2} times smaller than FsPickler"); - - //assert that we are in a 10% margin of FsPickler - Assert.True(wireTs <= picklerTs * 1.1, "Hyperion was slower than FsPickler"); - Assert.True(wireSize <= picklerSize * 1.1, "Hyperion payload was larger than FsPickler"); - } - - private static void HyperionSerialize(object value, Serializer wireSerializer, MemoryStream wireStream) - { - wireSerializer.Serialize(value, wireStream); - } - } -} diff --git a/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj b/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj new file mode 100644 index 00000000..a50bae24 --- /dev/null +++ b/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj @@ -0,0 +1,11 @@ + + + + netstandard1.6 + + + + + + + diff --git a/Hyperion.FSharpTestTypes/Library1.fs b/Hyperion.Tests.FSharpData/Types.fs similarity index 82% rename from Hyperion.FSharpTestTypes/Library1.fs rename to Hyperion.Tests.FSharpData/Types.fs index 4eceed48..ca956e13 100644 --- a/Hyperion.FSharpTestTypes/Library1.fs +++ b/Hyperion.Tests.FSharpData/Types.fs @@ -1,8 +1,5 @@ -namespace Hyperion.FSharpTestTypes +namespace Hyperion.Tests.FSharpData -#if AKKA -open Akka.Actor -#endif type DU1 = | A of int @@ -15,15 +12,7 @@ and DU2 = type HubType = | Task of unit | Chat of unit - -#if AKKA -type Connection = - { username : string - id : string - hubType : HubType - signalrAref : IActorRef } -#endif - + [] type User = { name : string @@ -54,6 +43,4 @@ module TestQuotations = module TestMap = type RecordWithString = {Name:string} type RecordWithMap = {SomeMap: Map} - let createRecordWithMap = {SomeMap = Map.ofSeq [ (1, "one"); (2, "two") ] } - - + let createRecordWithMap = {SomeMap = Map.ofSeq [ (1, "one"); (2, "two") ] } \ No newline at end of file diff --git a/Hyperion.Tests.Performance/BenchmarkHelper.cs b/Hyperion.Tests.Performance/BenchmarkHelper.cs deleted file mode 100644 index bc5c5771..00000000 --- a/Hyperion.Tests.Performance/BenchmarkHelper.cs +++ /dev/null @@ -1,14 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion -namespace Hyperion.Tests.Performance -{ - public static class BenchmarkHelper - { - } -} diff --git a/Hyperion.Tests.Performance/Deserialization/DeserializeCollectionsBenchmark.cs b/Hyperion.Tests.Performance/Deserialization/DeserializeCollectionsBenchmark.cs deleted file mode 100644 index d5aceda6..00000000 --- a/Hyperion.Tests.Performance/Deserialization/DeserializeCollectionsBenchmark.cs +++ /dev/null @@ -1,173 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System.Collections.Generic; -using NBench; - -namespace Hyperion.Tests.Performance.Deserialization -{ - public class ByteArrayDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(new byte[] { 123, 134, 11, 122, 1 }); - } - - [PerfBenchmark( - Description = "Benchmark byte array deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 4500000)] - public void Deserialize_ByteArray() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public sealed class StringArrayDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(new string[] { "abc", "cbd0", "sdsd4", "4dfg", "sfsdf44g" }); - } - - [PerfBenchmark( - Description = "Benchmark string array deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 650000)] - public void Deserialize_StringArray() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public sealed class DictionaryDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(new Dictionary - { - ["abc"] = "aaa", - ["dsdf"] = "asdab", - ["fms0"] = "sdftu" - }); - } - - [PerfBenchmark( - Description = "Benchmark dictionary deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 130000)] - public void Deserialize_Dictionary() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } - - public sealed class ListDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(new List { "asdad", "asdabs3", "sfsdf44g", "asdf4r", "sfsdf44g" }); - } - - [PerfBenchmark( - Description = "Benchmark list deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 250000)] - public void Deserialize_StringList() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } - - public sealed class LinkedListDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(new LinkedList(new[] { "asdad", "asdabs3", "dfsdf9", "asdf4r", "sfsdf44g" })); - } - - [PerfBenchmark( - Description = "Benchmark linked list deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 150000)] - public void Deserialize_LinkedList() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } - - public sealed class HashSetDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(new HashSet { "asdad", "asdabs3", "dfsdf9", "asdf4r", "sfsdf44g" }); - } - - [PerfBenchmark( - Description = "Benchmark hash set deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 50000)] - public void Deserialize_HashSet() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } - - public sealed class SortedSetDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(new SortedSet { "asdad", "asdabs3", "dfsdf9", "asdf4r", "sfsdf44g" }); - } - - [PerfBenchmark( - Description = "Benchmark sorted set deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 45000)] - public void Deserialize_SortedSet() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } -} \ No newline at end of file diff --git a/Hyperion.Tests.Performance/Deserialization/DeserializeComplexObjectsBenchmark.cs b/Hyperion.Tests.Performance/Deserialization/DeserializeComplexObjectsBenchmark.cs deleted file mode 100644 index 52f3b4b9..00000000 --- a/Hyperion.Tests.Performance/Deserialization/DeserializeComplexObjectsBenchmark.cs +++ /dev/null @@ -1,87 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using Hyperion.Tests.Performance.Types; -using NBench; - -namespace Hyperion.Tests.Performance.Deserialization -{ - public class StructDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(LargeStruct.Create()); - } - - [PerfBenchmark( - Description = "Benchmark struct deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 1000000)] - public void Deserialize_Struct() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class ClassDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(TypicalPersonData.MakeRandom()); - } - - [PerfBenchmark( - Description = "Benchmark class deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 180000)] - public void Deserialize_Class() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class CyclicReferenceDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - - var a = new CyclicA(); - var b = new CyclicB(); - a.B = b; - b.A = a; - - InitStreamWith(a); - } - - [PerfBenchmark( - Description = "Benchmark cyclic reference deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test, - Skip = "FIXME: Stack overflow exception")] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 4000000)] - public void Deserialize_Cyclic() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } -} \ No newline at end of file diff --git a/Hyperion.Tests.Performance/Deserialization/DeserializeFSharpTypesBenchmark.cs b/Hyperion.Tests.Performance/Deserialization/DeserializeFSharpTypesBenchmark.cs deleted file mode 100644 index e38486dc..00000000 --- a/Hyperion.Tests.Performance/Deserialization/DeserializeFSharpTypesBenchmark.cs +++ /dev/null @@ -1,134 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using Hyperion.FSharpTestTypes; -using Microsoft.FSharp.Collections; -using Microsoft.FSharp.Core; -using NBench; - -namespace Hyperion.Tests.Performance.Deserialization -{ - public class DiscriminatedUnionDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(DU2.NewC(DU1.NewB("test", 123))); - } - - [PerfBenchmark( - Description = "Benchmark dyscriminated union deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 500000)] - public void Deserialize_DiscriminatedUnion() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class RecordDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - var record = new User( - name: "John Doe", - aref: FSharpOption.Some("ok"), - connections: "test"); - InitStreamWith(record); - } - - [PerfBenchmark( - Description = "Benchmark record deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 350000)] - public void Deserialize_Record() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class FSharpMapDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(TestMap.createRecordWithMap); - } - - [PerfBenchmark( - Description = "Benchmark F# map deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 120000)] - public void Deserialize_FSharpMap() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class FSharpListDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - var list = ListModule.OfArray(new[] { 123, 2342355, 456456467578, 234234, -234281 }); - InitStreamWith(list); - } - - [PerfBenchmark( - Description = "Benchmark F# list deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test, - Skip = "FIXME: counter is always 0")] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 4000000)] - public void Deserialize_FSharpList() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } - - public class FSharpSetDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - var set = SetModule.OfArray(new[] { 123, 2342355, 456456467578, 234234, -234281 }); - InitStreamWith(set); - } - - [PerfBenchmark( - Description = "Benchmark F# list deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test, - Skip="FIXME: counter is always 0")] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 4000000)] - public void Deserialize_FSharpSet() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } -} diff --git a/Hyperion.Tests.Performance/Deserialization/DeserializeImmutableCollectionsBenchmark.cs b/Hyperion.Tests.Performance/Deserialization/DeserializeImmutableCollectionsBenchmark.cs deleted file mode 100644 index 0e52bdb5..00000000 --- a/Hyperion.Tests.Performance/Deserialization/DeserializeImmutableCollectionsBenchmark.cs +++ /dev/null @@ -1,134 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System.Collections.Generic; -using System.Collections.Immutable; -using NBench; - -namespace Hyperion.Tests.Performance.Deserialization -{ - public class ImmutableArrayDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(ImmutableArray.Create(123, 56568, 3445, 568567, 234236, 5821, 2456, 71231)); - } - - [PerfBenchmark( - Description = "Benchmark immutable array deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 240000)] - public void Deserialize_ImmutableArray() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } - - public class ImmutableListDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(ImmutableList.Create(123, 56568, 3445, 568567, 234236, 5821, 2456, 71231)); - } - - [PerfBenchmark( - Description = "Benchmark immutable list deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 230000)] - public void Deserialize_ImmutableList() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } - - public class ImmutableHashSetDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(ImmutableHashSet.Create(123, 56568, 3445, 568567, 234236, 5821, 2456, 71231)); - } - - [PerfBenchmark( - Description = "Benchmark immutable hash set deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 120000)] - public void Deserialize_ImmutableHashSet() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } - - public class ImmutableSortedSetDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(ImmutableSortedSet.Create(123, 56568, 3445, 568567, 234236, 5821, 2456, 71231)); - } - - [PerfBenchmark( - Description = "Benchmark immutable sorted set deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 180000)] - public void Deserialize_ImmutableSortedSet() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } - - public class ImmutableDictionaryDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(ImmutableDictionary.CreateRange(new Dictionary - { - ["key1"] = 123, - ["key2"] = 1234, - ["key3"] = 12345, - ["key4"] = 123456, - ["key5"] = 1234567, - ["key6"] = 12345678, - ["key7"] = 123456789, - })); - } - - [PerfBenchmark( - Description = "Benchmark immutable dictionary deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 75000)] - public void Deserialize_ImmutableDictionary() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } -} \ No newline at end of file diff --git a/Hyperion.Tests.Performance/Deserialization/DeserializePrimitivesBenchmark.cs b/Hyperion.Tests.Performance/Deserialization/DeserializePrimitivesBenchmark.cs deleted file mode 100644 index 41882153..00000000 --- a/Hyperion.Tests.Performance/Deserialization/DeserializePrimitivesBenchmark.cs +++ /dev/null @@ -1,569 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System; -using NBench; - -namespace Hyperion.Tests.Performance.Deserialization -{ - public class ByteDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith((byte)120); - } - - [PerfBenchmark( - Description = "Benchmark System.Byte deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 9000000)] - public void Deserialize_Byte() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class Int16DeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith((short)12389); - } - - [PerfBenchmark( - Description = "Benchmark System.Int16 deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 7500000)] - public void Deserialize_Int16() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class Int32DeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(1238919); - } - - [PerfBenchmark( - Description = "Benchmark System.Int32 deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 12000000)] - public void Deserialize_Int32() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class Int64DeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(93111238919L); - } - - [PerfBenchmark( - Description = "Benchmark System.Int64 deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 10000000)] - public void Deserialize_Int64() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class SByteDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith((sbyte)-120); - } - - [PerfBenchmark( - Description = "Benchmark System.SByte deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 15000000)] - public void Deserialize_SByte() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class UInt16DeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith((ushort)12389); - } - - [PerfBenchmark( - Description = "Benchmark System.UInt16 deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 11000000)] - public void Deserialize_UInt16() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class UInt32DeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith((uint)11238919); - } - - [PerfBenchmark( - Description = "Benchmark System.UInt32 deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 7000000)] - public void Deserialize_UInt32() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class UInt64DeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith((ulong)793111238919L); - } - - [PerfBenchmark( - Description = "Benchmark System.UInt64 deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 9000000)] - public void Deserialize_UInt64() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class SingleDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith((float)1.21355); - } - - [PerfBenchmark( - Description = "Benchmark System.Single deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 6500000)] - public void Deserialize_Single() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class DoubleDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith((double)1.21355); - } - - [PerfBenchmark( - Description = "Benchmark System.Double deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 6000000)] - public void Deserialize_Double() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class DecimalDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith((decimal)1.21355); - } - - [PerfBenchmark( - Description = "Benchmark System.Decimal deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 6200000)] - public void Deserialize_Decimal() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class BoolDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(true); - } - - [PerfBenchmark( - Description = "Benchmark System.Boolean deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 9000000)] - public void Deserialize_Bool() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class StringDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - var s = new string('x', 100); - InitStreamWith(s); - } - - [PerfBenchmark( - Description = "Benchmark System.String deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 3500000)] - public void Deserialize_String() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class GuidDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(Guid.NewGuid()); - } - - [PerfBenchmark( - Description = "Benchmark System.Guid deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 5500000)] - public void Deserialize_Guid() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class TimeSpanDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(DateTime.Now.TimeOfDay); - } - - [PerfBenchmark( - Description = "Benchmark System.TimeSpan deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 1500000)] - public void Deserialize_TimeSpan() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class DateTimeDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(DateTime.Now); - } - - [PerfBenchmark( - Description = "Benchmark System.DateTime deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 10000000)] - public void Deserialize_DateTime() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class TypeDeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(typeof(int)); - } - - [PerfBenchmark( - Description = "Benchmark System.Type deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 90000)] - public void Deserialize_Type() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount(); - } - } - - public class Tuple1DeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(Tuple.Create(123)); - } - - [PerfBenchmark( - Description = "Benchmark System.Tuple`1 deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 1100000)] - public void Deserialize_Tuple1() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } - - public class Tuple2DeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(Tuple.Create(123, 1234)); - } - - [PerfBenchmark( - Description = "Benchmark System.Tuple`2 deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 400000)] - public void Deserialize_Tuple2() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } - - public class Tuple3DeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(Tuple.Create(123, 234, 345)); - } - - [PerfBenchmark( - Description = "Benchmark System.Tuple`3 deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 350000)] - public void Deserialize_Tuple3() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } - - public class Tuple4DeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(Tuple.Create(123, 2345, 3456, 4501)); - } - - [PerfBenchmark( - Description = "Benchmark System.Tuple`4 deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 260000)] - public void Deserialize_Tuple4() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } - - public class Tuple5DeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(Tuple.Create(123, 2345, 3245, 4561, 746756)); - } - - - [PerfBenchmark( - Description = "Benchmark System.Tuple`5 deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 220000)] - public void Deserialize_Tuple5() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } - - public class Tuple6DeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(Tuple.Create(123, 56568, 3445, 568567, 234236, 5821)); - } - - - [PerfBenchmark( - Description = "Benchmark System.Tuple`6 deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 175000)] - public void Deserialize_Tuple6() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } - - public class Tuple7DeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(Tuple.Create(123, 56568, 3445, 568567, 234236, 5821, 2456)); - } - - - [PerfBenchmark( - Description = "Benchmark System.Tuple`7 deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 260000)] - public void Deserialize_Tuple7() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } - - public class Tuple8DeserializationBenchmark : PerfTestBase - { - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - InitStreamWith(Tuple.Create(123, 56568, 3445, 568567, 234236, 5821, 2456, 71231)); - } - - [PerfBenchmark( - Description = "Benchmark System.Tuple`8 deserialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test, - Skip = "FIXME: counter is always 0")] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 4000000)] - public void Deserialize_Tuple8() - { - Stream.Position = 0; // don't move it up to Setup, I don't know why it needed here to work - DeserializeAndCount>(); - } - } -} \ No newline at end of file diff --git a/Hyperion.Tests.Performance/Hyperion.Tests.Performance.csproj b/Hyperion.Tests.Performance/Hyperion.Tests.Performance.csproj deleted file mode 100644 index 478d2418..00000000 --- a/Hyperion.Tests.Performance/Hyperion.Tests.Performance.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - net452 - Hyperion.Tests.Performance - - - - - - - - - - - - - - - - - - - - - - $(DefineConstants);RELEASE - - diff --git a/Hyperion.Tests.Performance/PerfTestBase.cs b/Hyperion.Tests.Performance/PerfTestBase.cs deleted file mode 100644 index 153e410a..00000000 --- a/Hyperion.Tests.Performance/PerfTestBase.cs +++ /dev/null @@ -1,77 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System.Diagnostics; -using System.IO; -using System.Runtime.CompilerServices; -using NBench; -using NBench.Sdk; - -namespace Hyperion.Tests.Performance -{ - public abstract class PerfTestBase - { - public const string TestCounterName = "CallCounter"; - - /// - /// 100 milliseconds. - /// - public const int StandardRunTime = 100; - - /// - /// 3 iterations. - /// - public const int StandardIterationCount = 3; - - protected MemoryStream Stream; - protected Hyperion.Serializer Serializer; - protected Counter TestCounter; - private readonly SerializerOptions options; - - protected PerfTestBase(SerializerOptions options = null) - { - this.options = options; - new TestRunner(null).SetProcessPriority(concurrent: false); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - protected void SerializeAndCount(T value) - { - Serializer.Serialize(value, Stream); - TestCounter.Increment(); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - protected void DeserializeAndCount() - { - Serializer.Deserialize(Stream); - TestCounter.Increment(); - } - - protected void InitStreamWith(T value) - { - Serializer.Serialize(value, Stream); - Stream.Position = 0; - } - - [PerfSetup] - public virtual void Setup(BenchmarkContext context) - { - Serializer = options == null ? new Serializer() : new Serializer(options); - Stream = new MemoryStream(); - TestCounter = context.GetCounter(TestCounterName); - } - - [PerfCleanup] - public virtual void Cleanup() - { - Stream?.Dispose(); - } - } -} \ No newline at end of file diff --git a/Hyperion.Tests.Performance/Properties/AssemblyInfo.cs b/Hyperion.Tests.Performance/Properties/AssemblyInfo.cs deleted file mode 100644 index de5d1647..00000000 --- a/Hyperion.Tests.Performance/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,30 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System.Reflection; -using System.Runtime.InteropServices; - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("44afcd2c-2220-4b52-817a-bd9c8b600e05")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] diff --git a/Hyperion.Tests.Performance/Serialization/SerializeCollectionsBenchmark.cs b/Hyperion.Tests.Performance/Serialization/SerializeCollectionsBenchmark.cs deleted file mode 100644 index 7e8b994a..00000000 --- a/Hyperion.Tests.Performance/Serialization/SerializeCollectionsBenchmark.cs +++ /dev/null @@ -1,110 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System.Collections.Generic; -using NBench; - -namespace Hyperion.Tests.Performance.Serialization -{ - public class SerializeCollectionsBenchmark : PerfTestBase - { - [PerfBenchmark( - Description = "Benchmark byte array serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 4800000)] - public void Serialize_ByteArray() - { - SerializeAndCount(new byte[] { 123, 134, 11, 122, 1 }); - } - - [PerfBenchmark( - Description = "Benchmark string array serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 300000)] - public void Serialize_StringArray() - { - SerializeAndCount(new string[] { "abc", "cbd0", "sdsd4", "4dfg", "sfsdf44g" }); - } - - [PerfBenchmark( - Description = "Benchmark dictionary serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 360000)] - public void Serialize_Dictionary() - { - var dictionary = new Dictionary - { - ["abc"] = "aaa", - ["dsdf"] = "asdab", - ["fms0"] = "sdftu" - }; - SerializeAndCount(dictionary); - } - - [PerfBenchmark( - Description = "Benchmark list serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 550000)] - public void Serialize_List() - { - SerializeAndCount(new List { "asdad", "asdabs3", "sfsdf44g", "asdf4r", "sfsdf44g" }); - } - - [PerfBenchmark( - Description = "Benchmark linked list serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 500000)] - public void Serialize_LinkedList() - { - var list = new LinkedList(new[] { "asdad", "asdabs3", "dfsdf9", "asdf4r", "sfsdf44g" }); - SerializeAndCount(list); - } - - [PerfBenchmark( - Description = "Benchmark hash set serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 170000)] - public void Serialize_HashSet() - { - var set = new HashSet { "asdad", "asdabs3", "dfsdf9", "asdf4r", "sfsdf44g" }; - SerializeAndCount(set); - } - - [PerfBenchmark( - Description = "Benchmark sorted set serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 110000)] - public void Serialize_SortedSet() - { - var set = new SortedSet { "asdad", "asdabs3", "dfsdf9", "asdf4r", "sfsdf44g" }; - SerializeAndCount(set); - } - } -} \ No newline at end of file diff --git a/Hyperion.Tests.Performance/Serialization/SerializeComplexObjectsBenchmark.cs b/Hyperion.Tests.Performance/Serialization/SerializeComplexObjectsBenchmark.cs deleted file mode 100644 index 8c00f202..00000000 --- a/Hyperion.Tests.Performance/Serialization/SerializeComplexObjectsBenchmark.cs +++ /dev/null @@ -1,72 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using Hyperion.Tests.Performance.Types; -using NBench; -namespace Hyperion.Tests.Performance.Serialization -{ - public class SerializeComplexObjectsBenchmark : PerfTestBase - { - private LargeStruct _testStruct; - private TypicalPersonData _testObject; - private CyclicA _cyclic; - - public override void Setup(BenchmarkContext context) - { - base.Setup(context); - _testStruct = LargeStruct.Create(); - _testObject = TypicalPersonData.MakeRandom(); - - var a = new CyclicA(); - var b = new CyclicB(); - a.B = b; - b.A = a; - - _cyclic = a; - } - - [PerfBenchmark( - Description = "Benchmark struct serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 1300000)] - public void Serialize_Struct() - { - SerializeAndCount(_testStruct); - } - - [PerfBenchmark( - Description = "Benchmark big object serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 160000)] - public void Serialize_LargeObject() - { - SerializeAndCount(_testObject); - } - - //TODO: PerfBenchmark.Skip doesn't work - [PerfBenchmark( - Description = "Benchmark cyclic reference serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test, - Skip = "FIXME: stack overflow")] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 230000)] - public void Serialize_CyclicReferences() - { - SerializeAndCount(_cyclic); - } - } -} \ No newline at end of file diff --git a/Hyperion.Tests.Performance/Serialization/SerializeFSharpTypesBenchmark.cs b/Hyperion.Tests.Performance/Serialization/SerializeFSharpTypesBenchmark.cs deleted file mode 100644 index 43136cd8..00000000 --- a/Hyperion.Tests.Performance/Serialization/SerializeFSharpTypesBenchmark.cs +++ /dev/null @@ -1,86 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using Hyperion.FSharpTestTypes; -using Microsoft.FSharp.Collections; -using Microsoft.FSharp.Core; -using NBench; - -namespace Hyperion.Tests.Performance.Serialization -{ - public class SerializeFSharpTypesBenchmark : PerfTestBase - { - [PerfBenchmark( - Description = "Benchmark discriminated union serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 900000)] - public void Serialize_DiscriminatedUnion() - { - SerializeAndCount(DU2.NewC(DU1.NewB("test", 123))); - } - - [PerfBenchmark( - Description = "Benchmark F# record serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 600000)] - public void Serialize_Record() - { - var record = new User( - name: "John Doe", - aref: FSharpOption.Some("ok"), - connections: "test"); - SerializeAndCount(record); - } - - [PerfBenchmark( - Description = "Benchmark F# record with map serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 250)] //FIXME: F# Maps are pretty expensive - public void Serialize_RecordWithMap() - { - var record = TestMap.createRecordWithMap; - SerializeAndCount(record); - } - - [PerfBenchmark( - Description = "Benchmark F# list serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 700000)] - public void Serialize_FSharpList() - { - var list = ListModule.OfArray(new[] { 123, 2342355, 456456467578, 234234, -234281 }); - SerializeAndCount(list); - } - - [PerfBenchmark( - Description = "Benchmark F# set serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 300000)] - public void Serialize_FSharpSet() - { - var set = SetModule.OfArray(new[] { 123, 2342355, 456456467578, 234234, -234281 }); - SerializeAndCount(set); - } - } -} diff --git a/Hyperion.Tests.Performance/Serialization/SerializeImmutableCollectionsBenchmark.cs b/Hyperion.Tests.Performance/Serialization/SerializeImmutableCollectionsBenchmark.cs deleted file mode 100644 index 2eaa8ffa..00000000 --- a/Hyperion.Tests.Performance/Serialization/SerializeImmutableCollectionsBenchmark.cs +++ /dev/null @@ -1,90 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System.Collections.Generic; -using System.Collections.Immutable; -using NBench; - -namespace Hyperion.Tests.Performance.Serialization -{ - public class SerializeImmutableCollectionsBenchmark : PerfTestBase - { - [PerfBenchmark( - Description = "Benchmark immutable string array serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 420000)] - public void Serialize_ImmutableArray() - { - var collection = ImmutableArray.CreateRange(new[] { "abc", "cbd0", "sdsd4", "4dfg", "adafd0xd" }); - SerializeAndCount(collection); - } - - [PerfBenchmark( - Description = "Benchmark immutable list serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 200000)] - public void Serialize_ImmutableList() - { - var collection = ImmutableList.CreateRange(new[] { "abc", "cbd0", "sdsd4", "4dfg", "adafd0xd" }); - SerializeAndCount(collection); - } - - [PerfBenchmark( - Description = "Benchmark immutable hash set serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 100000)] - public void Serialize_ImmutableHashSet() - { - var collection = ImmutableHashSet.CreateRange(new[] { "abc", "cbd0", "sdsd4", "4dfg", "adafd0xd" }); - SerializeAndCount(collection); - } - - [PerfBenchmark( - Description = "Benchmark immutable sorted set serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 100000)] - public void Serialize_ImmutableSortedSet() - { - var collection = ImmutableHashSet.CreateRange(new[] { "abc", "cbd0", "sdsd4", "4dfg", "adafd0xd" }); - SerializeAndCount(collection); - } - - [PerfBenchmark( - Description = "Benchmark immutable dictionary serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 90000)] - public void Serialize_ImmutableDictionary() - { - var collection = ImmutableDictionary.CreateRange(new[] - { - new KeyValuePair("key1", "value1"), - new KeyValuePair("key2", "value2"), - new KeyValuePair("key3", "value3"), - new KeyValuePair("key4", "value4"), - new KeyValuePair("key5", "value5"), - }); - SerializeAndCount(collection); - } - } -} diff --git a/Hyperion.Tests.Performance/Serialization/SerializePrimitivesBenchmark.cs b/Hyperion.Tests.Performance/Serialization/SerializePrimitivesBenchmark.cs deleted file mode 100644 index 8dade7ce..00000000 --- a/Hyperion.Tests.Performance/Serialization/SerializePrimitivesBenchmark.cs +++ /dev/null @@ -1,318 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System; -using NBench; - -namespace Hyperion.Tests.Performance.Serialization -{ - public class SerializePrimitivesBenchmark : PerfTestBase - { - [PerfBenchmark( - Description = "Benchmark System.Byte serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 5300000)] - public void Serialize_Byte() - { - SerializeAndCount((byte)123); - } - - [PerfBenchmark( - Description = "Benchmark System.Int16 serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 4500000)] - public void Serialize_Int16() - { - SerializeAndCount((short)123); - } - - [PerfBenchmark( - Description = "Benchmark System.Int32 serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 4500000)] - public void Serialize_Int32() - { - SerializeAndCount((int)123); - } - - [PerfBenchmark( - Description = "Benchmark System.Int64 serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 4200000)] - public void Serialize_Int64() - { - SerializeAndCount((long)123); - } - - [PerfBenchmark( - Description = "Benchmark System.SByte serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 5500000)] - public void Serialize_SByte() - { - SerializeAndCount((sbyte)123); - } - - [PerfBenchmark( - Description = "Benchmark System.UInt16 serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 4500000)] - public void Serialize_UInt16() - { - SerializeAndCount((ushort)123); - } - - [PerfBenchmark( - Description = "Benchmark System.UInt32 serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 4500000)] - public void Serialize_UInt32() - { - SerializeAndCount((uint)123); - } - - [PerfBenchmark( - Description = "Benchmark System.UInt64 serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 4200000)] - public void Serialize_UInt64() - { - SerializeAndCount((ulong)123); - } - - [PerfBenchmark( - Description = "Benchmark System.Boolean serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 5500000)] - public void Serialize_Boolean() - { - SerializeAndCount(true); - } - - [PerfBenchmark( - Description = "Benchmark System.Single serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 4500000)] - public void Serialize_Single() - { - SerializeAndCount((float)123.56); - } - - [PerfBenchmark( - Description = "Benchmark System.Double serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 4000000)] - public void Serialize_Double() - { - SerializeAndCount((double)123.56); - } - - [PerfBenchmark( - Description = "Benchmark System.Decimal serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 2500000)] - public void Serialize_Decimal() - { - SerializeAndCount((decimal)123.56); - } - - [PerfBenchmark( - Description = "Benchmark System.String serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 1000000)] - public void Serialize_String() - { - var x = new string('x', 100); - SerializeAndCount(x); - } - - [PerfBenchmark( - Description = "Benchmark System.Guid serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 2000000)] - public void Serialize_Guid() - { - SerializeAndCount(Guid.NewGuid()); - } - - [PerfBenchmark( - Description = "Benchmark System.DateTime serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 3800000)] - public void Serialize_DateTime() - { - SerializeAndCount(DateTime.UtcNow); - } - - [PerfBenchmark( - Description = "Benchmark System.TimeSpan serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 1800000)] //FIXME: why is this so slower than DateTime? - public void Serialize_TimeSpan() - { - SerializeAndCount(DateTime.UtcNow.TimeOfDay); - } - - [PerfBenchmark( - Description = "Benchmark System.Tuple`1 serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 2000000)] - public void Serialize_Tuple1() - { - SerializeAndCount(Tuple.Create(123)); - } - - [PerfBenchmark( - Description = "Benchmark System.Tuple`2 serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 1500000)] - public void Serialize_Tuple2() - { - SerializeAndCount(Tuple.Create(123, true)); - } - - [PerfBenchmark( - Description = "Benchmark System.Tuple`3 serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 1100000)] - public void Serialize_Tuple3() - { - SerializeAndCount(Tuple.Create(123, true, "x")); - } - - [PerfBenchmark( - Description = "Benchmark System.Tuple`4 serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 1000000)] - public void Serialize_Tuple4() - { - SerializeAndCount(Tuple.Create(123, true, "x", 123.3f)); - } - - [PerfBenchmark( - Description = "Benchmark System.Tuple`5 serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 750000)] - public void Serialize_Tuple5() - { - SerializeAndCount(Tuple.Create(123, true, "x", 123.3f, "asdasdac")); - } - - [PerfBenchmark( - Description = "Benchmark System.Tuple`6 serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 750000)] - public void Serialize_Tuple6() - { - SerializeAndCount(Tuple.Create(123, true, "x", 123.3f, "asdasdac", false)); - } - - [PerfBenchmark( - Description = "Benchmark System.Tuple`7 serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 750000)] - public void Serialize_Tuple7() - { - SerializeAndCount(Tuple.Create(123, true, "x", 123.3f, "asdasdac", false, (byte)0xf)); - } - - [PerfBenchmark( - Description = "Benchmark System.Tuple`8 serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 600000)] - public void Serialize_Tuple8() - { - SerializeAndCount(Tuple.Create(123, true, "x", 123.3f, "asdasdac", false, (byte)0xf, 1234)); - } - - [PerfBenchmark( - Description = "Benchmark System.Type serialization", - NumberOfIterations = StandardIterationCount, - RunMode = RunMode.Throughput, - RunTimeMilliseconds = StandardRunTime, - TestMode = TestMode.Test)] - [CounterThroughputAssertion(TestCounterName, MustBe.GreaterThan, 550000)] - public void Serialize_Type() - { - SerializeAndCount(typeof(int)); - } - } -} diff --git a/Hyperion.Tests.Performance/Types/Cyclic.cs b/Hyperion.Tests.Performance/Types/Cyclic.cs deleted file mode 100644 index f6b3516e..00000000 --- a/Hyperion.Tests.Performance/Types/Cyclic.cs +++ /dev/null @@ -1,25 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System; - -namespace Hyperion.Tests.Performance.Types -{ - [Serializable] - public class CyclicA - { - public CyclicB B { get; set; } - } - - [Serializable] - public class CyclicB - { - public CyclicA A { get; set; } - } -} \ No newline at end of file diff --git a/Hyperion.Tests.Performance/Types/LargeStruct.cs b/Hyperion.Tests.Performance/Types/LargeStruct.cs deleted file mode 100644 index 884f91ef..00000000 --- a/Hyperion.Tests.Performance/Types/LargeStruct.cs +++ /dev/null @@ -1,56 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System; - -namespace Hyperion.Tests.Performance.Types -{ - public struct LargeStruct - { - private static void A(bool b) - { - if (!b) - throw new Exception(); - } - - public ulong m_val1; - public ulong m_val2; - public ulong m_val3; - public ulong m_val4; - - private static ulong counter; - - public LargeStruct(ulong m_val1, ulong m_val2, ulong m_val3, ulong m_val4) - { - this.m_val1 = m_val1; - this.m_val2 = m_val2; - this.m_val3 = m_val3; - this.m_val4 = m_val4; - } - - public static LargeStruct Create() - { - return new LargeStruct - { - m_val1 = counter++, - m_val2 = ulong.MaxValue - counter++, - m_val3 = counter++, - m_val4 = ulong.MaxValue - counter++ - }; - } - - public static void Compare(LargeStruct a, LargeStruct b) - { - A(a.m_val1 == b.m_val1); - A(a.m_val2 == b.m_val2); - A(a.m_val3 == b.m_val3); - A(a.m_val4 == b.m_val4); - } - } -} \ No newline at end of file diff --git a/Hyperion.Tests.Performance/Types/TestMessage.cs b/Hyperion.Tests.Performance/Types/TestMessage.cs deleted file mode 100644 index 5b959aaf..00000000 --- a/Hyperion.Tests.Performance/Types/TestMessage.cs +++ /dev/null @@ -1,24 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System; - -namespace Hyperion.Tests.Performance.Types -{ - public class TestMessage - { - public virtual string StringProp { get; set; } - - public virtual int IntProp { get; set; } - - public virtual Guid GuidProp { get; set; } - - public virtual DateTime DateProp { get; set; } - } -} \ No newline at end of file diff --git a/Hyperion.Tests.Performance/Types/TestPerson.cs b/Hyperion.Tests.Performance/Types/TestPerson.cs deleted file mode 100644 index dc515af4..00000000 --- a/Hyperion.Tests.Performance/Types/TestPerson.cs +++ /dev/null @@ -1,143 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System; - -namespace Hyperion.Tests.Performance.Types -{ - public enum MaritalStatus - { - Married, - Divorced, - HatesAll - } - - public class TypicalPersonData - { - /// - /// Required by some serilizers (i.e. XML) - /// - public TypicalPersonData() { } - public virtual string Address1 { get; set; } - public virtual string Address2 { get; set; } - public virtual string AddressCity { get; set; } - public virtual string AddressState { get; set; } - public virtual string AddressZip { get; set; } - public virtual double CreditScore { get; set; } - public virtual DateTime DOB { get; set; } - public virtual string EMail { get; set; } - public virtual string FirstName { get; set; } - public virtual string HomePhone { get; set; } - public virtual string LastName { get; set; } - public virtual MaritalStatus MaritalStatus { get; set; } - public virtual string MiddleName { get; set; } - public virtual string MobilePhone { get; set; } - public virtual bool RegisteredToVote { get; set; } - public virtual decimal Salary { get; set; } - public virtual int YearsOfService { get; set; } - public virtual string SkypeID { get; set; } - public virtual string YahooID { get; set; } - public virtual string GoogleID { get; set; } - public virtual string Notes { get; set; } - public virtual bool? IsSmoker { get; set; } - public virtual bool? IsLoving { get; set; } - public virtual bool? IsLoved { get; set; } - public virtual bool? IsDangerous { get; set; } - public virtual bool? IsEducated { get; set; } - public virtual DateTime? LastSmokingDate { get; set; } - public virtual decimal? DesiredSalary { get; set; } - public virtual double? ProbabilityOfSpaceFlight { get; set; } - public virtual int? CurrentFriendCount { get; set; } - public virtual int? DesiredFriendCount { get; set; } - - - private static int counter; - public static TypicalPersonData MakeRandom() - { - var rnd = counter++; - - var data = new TypicalPersonData - { - FirstName = NaturalTextGenerator.GenerateFirstName(), - MiddleName = NaturalTextGenerator.GenerateFirstName(), - LastName = NaturalTextGenerator.GenerateLastName(), - DOB = DateTime.Now.AddYears(5), - Salary = 55435345, - YearsOfService = 25, - CreditScore = 0.7562, - RegisteredToVote = (DateTime.UtcNow.Ticks & 1) == 0, - MaritalStatus = MaritalStatus.HatesAll, - Address1 = NaturalTextGenerator.GenerateAddressLine(), - Address2 = NaturalTextGenerator.GenerateAddressLine(), - AddressCity = NaturalTextGenerator.GenerateCityName(), - AddressState = "CA", - AddressZip = "91606", - HomePhone = (DateTime.UtcNow.Ticks & 1) == 0 ? "(555) 123-4567" : null, - EMail = NaturalTextGenerator.GenerateEMail() - }; - - if (0 != (rnd & (1 << 32))) data.Notes = NaturalTextGenerator.Generate(45); - if (0 != (rnd & (1 << 31))) data.SkypeID = NaturalTextGenerator.GenerateEMail(); - if (0 != (rnd & (1 << 30))) data.YahooID = NaturalTextGenerator.GenerateEMail(); - - if (0 != (rnd & (1 << 29))) data.IsSmoker = 0 != (rnd & (1 << 17)); - if (0 != (rnd & (1 << 28))) data.IsLoving = 0 != (rnd & (1 << 16)); - if (0 != (rnd & (1 << 27))) data.IsLoved = 0 != (rnd & (1 << 15)); - if (0 != (rnd & (1 << 26))) data.IsDangerous = 0 != (rnd & (1 << 14)); - if (0 != (rnd & (1 << 25))) data.IsEducated = 0 != (rnd & (1 << 13)); - - if (0 != (rnd & (1 << 24))) data.LastSmokingDate = DateTime.Now.AddYears(-10); - - - if (0 != (rnd & (1 << 23))) data.DesiredSalary = rnd / 1000m; - if (0 != (rnd & (1 << 22))) data.ProbabilityOfSpaceFlight = rnd / (double)int.MaxValue; - - if (0 != (rnd & (1 << 21))) - { - data.CurrentFriendCount = rnd % 123; - data.DesiredFriendCount = rnd % 121000; - } - - return data; - } - } - - public class NaturalTextGenerator - { - public static string GenerateEMail() - { - return "foo@fooo.com"; - } - - public static string Generate(int i) - { - return "fskldjflksjfl ksj dlfkjsdfl ksdjklf jsdlkj" + DateTime.Now.Ticks; - } - - public static string GenerateAddressLine() - { - return "fkjdskfjskfjs" + DateTime.Now.Ticks; - } - - public static string GenerateFirstName() - { - return "fksjdfkjsdkfjksdfs" + DateTime.Now.Ticks; - } - - public static string GenerateCityName() - { - return "fksdfkjsdkfjsdkfs"; - } - - public static string GenerateLastName() - { - return "kfjdskdfjskj"; - } - } -} \ No newline at end of file diff --git a/Hyperion.Tests.Performance/app.config b/Hyperion.Tests.Performance/app.config deleted file mode 100644 index 63ab907e..00000000 --- a/Hyperion.Tests.Performance/app.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/Hyperion.Tests/AttributeTests.cs b/Hyperion.Tests/AttributeTests.cs new file mode 100644 index 00000000..146bc3f9 --- /dev/null +++ b/Hyperion.Tests/AttributeTests.cs @@ -0,0 +1,58 @@ +#region copyright +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2016 AsynkronIT +// Copyright (C) 2016-2016 Akka.NET Team +// +// ----------------------------------------------------------------------- +#endregion + +using System; +using Xunit; + +namespace Hyperion.Tests +{ + public class AttributeTests : TestBase + { + #region test classes + + private abstract class Animal + { + public readonly string Name; + + [Ignore] + public readonly string Secret; + + protected Animal(string name, string secret) + { + Name = name; + Secret = secret; + } + } + + private class Dog : Animal + { + public readonly bool Barks; + + public Dog(string name, string secret, bool barks) : base(name, secret) + { + Barks = barks; + } + } + + #endregion + + [Fact] + public void ShouldNotSerializeFieldsMarkedAsIgnore() + { + var expected = new Dog("Max", "p4ssw0rd", barks: true); + Serialize(expected); + Reset(); + var actual = Deserialize(); + + Assert.Equal(expected.Name, actual.Name); + Assert.Equal(expected.Barks, actual.Barks); + Assert.Null(actual.Secret); + } + } +} \ No newline at end of file diff --git a/Hyperion.Tests/Bugs.cs b/Hyperion.Tests/Bugs.cs index e5ae4441..12e7551c 100644 --- a/Hyperion.Tests/Bugs.cs +++ b/Hyperion.Tests/Bugs.cs @@ -8,14 +8,46 @@ #endregion using System; +using System.Collections.Generic; +using System.Collections.Immutable; using System.IO; using Xunit; namespace Hyperion.Tests { - + public class Bugs { + #region issue 58 + + public enum TrustLevel { Unknown, Suspicious, Partial, Fully } + public interface IContainer + { + T Value { get; } + TrustLevel TrustLevel { get; } + } + public class Container : IContainer + { + public T Value { get; } + public TrustLevel TrustLevel { get; } + + public Container(T value, TrustLevel trustLevel) + { + Value = value; + TrustLevel = trustLevel; + } + } + public class ProvisioningResultMessage + { + private T Result { get; } + + public ProvisioningResultMessage(T result) + { + Result = result; + } + } + + #endregion public class ByteMessage { @@ -46,7 +78,7 @@ public bool Equals(ByteMessage other) public void CanSerializeMessageWithByte() { var stream = new MemoryStream(); - var msg = new ByteMessage(DateTime.UtcNow,1,2); + var msg = new ByteMessage(DateTime.UtcNow, 1, 2); var serializer = new Serializer(new SerializerOptions(versionTolerance: true, preserveObjectReferences: true)); serializer.Serialize(msg, stream); stream.Position = 0; @@ -65,6 +97,35 @@ public void CanSerialieCustomType_bug() var actual = serializer.Deserialize(stream); } + [Fact] + public void CanSerializeImmutableGenericInterfaces() + { + var serializer = new Serializer(new SerializerOptions(versionTolerance: true, preserveObjectReferences: true)); + var names = new List> + { + new Container("Mr", TrustLevel.Partial), + new Container("Bob", TrustLevel.Partial), + new Container("Smith", TrustLevel.Suspicious), + new Container("Mrs", TrustLevel.Suspicious), + new Container("Jane", TrustLevel.Suspicious), + new Container("Smith", TrustLevel.Suspicious), + new Container("Master", TrustLevel.Fully), + new Container("Fred", TrustLevel.Fully), + new Container("Smith", TrustLevel.Fully), + new Container("Miss", TrustLevel.Partial), + new Container("Sandra", TrustLevel.Partial), + new Container("Smith", TrustLevel.Suspicious) + }; + var message = new ProvisioningResultMessage>>(names.ToImmutableArray()); + + using (var stream = new MemoryStream()) + { + serializer.Serialize(message, stream); + stream.Position = 0; + var actual = serializer.Deserialize(stream); + } + } + public class SnapshotSelectionCriteria { public static SnapshotSelectionCriteria Latest { get; set; } = new SnapshotSelectionCriteria() diff --git a/Hyperion.Tests/CollectionTests.cs b/Hyperion.Tests/CollectionTests.cs index 0743a5dc..12389be2 100644 --- a/Hyperion.Tests/CollectionTests.cs +++ b/Hyperion.Tests/CollectionTests.cs @@ -51,8 +51,7 @@ public void CanSerializeByteArray() var actual = Deserialize(); Assert.Equal(expected, actual); } - - + [Fact] public void CanSerializeDictionary() { @@ -68,6 +67,21 @@ public void CanSerializeDictionary() Assert.Equal(expected.ToList(), actual.ToList()); } + [Fact] + public void CanSerializeIDictionaryInterface() + { + var expected = new Dictionary + { + ["abc"] = "def", + ["ghi"] = "jkl," + }; + + Serialize(expected); + Reset(); + var actual = Deserialize>(); + Assert.Equal(expected.ToList(), actual.ToList()); + } + [Fact] public void CanSerializeDictionaryKeysAndValuesByteChar() { diff --git a/Hyperion.Tests/CustomObjectTests.cs b/Hyperion.Tests/CustomObjectTests.cs index 46ce0b57..f509b51d 100644 --- a/Hyperion.Tests/CustomObjectTests.cs +++ b/Hyperion.Tests/CustomObjectTests.cs @@ -8,17 +8,31 @@ #endregion using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; using Xunit; namespace Hyperion.Tests { - + public class CustomObjectTests : TestBase { private class PrivateType { public int IntProp { get; set; } } + + private class Bucket + { + public Bucket(IImmutableDictionary values) + { + Values = values; + } + + public IImmutableDictionary Values { get; } + } + [Fact] public void CanSerializePrivateType() { @@ -170,7 +184,7 @@ public void CanEmptyObject() [Fact] public void CanSerializeObjectsKnownTypes() { - CustomInit(new Serializer(new SerializerOptions(knownTypes:new[] {typeof(Something)}))); + CustomInit(new Serializer(new SerializerOptions(knownTypes: new[] { typeof(Something) }))); var expected1 = new Something { StringProp = "First" @@ -191,5 +205,20 @@ public void CanSerializeObjectsKnownTypes() Assert.Equal(expected2, Deserialize()); Assert.Equal(expected3, Deserialize()); } + + [Fact] + public void CanSerializeObjectWithInterfaceReferencedCollections() + { + var expected = new Bucket(new Dictionary + { + { "a", 1 }, + { "b", 2 }, + { "c", 3 } + }.ToImmutableDictionary()); + + Serialize(expected); + Reset(); + Assert.Equal(expected.Values.ToArray(), Deserialize().Values.ToArray()); + } } } \ No newline at end of file diff --git a/Hyperion.Tests/ExpressionTests.cs b/Hyperion.Tests/ExpressionTests.cs index c977f8f2..58db7693 100644 --- a/Hyperion.Tests/ExpressionTests.cs +++ b/Hyperion.Tests/ExpressionTests.cs @@ -13,7 +13,6 @@ using System.Linq; using System.Linq.Expressions; using System.Reflection; -using System.Runtime.Serialization; using Xunit; namespace Hyperion.Tests diff --git a/Hyperion.Tests/FSharpTests.cs b/Hyperion.Tests/FSharpTests.cs index 634b1b80..46c0e4b7 100644 --- a/Hyperion.Tests/FSharpTests.cs +++ b/Hyperion.Tests/FSharpTests.cs @@ -7,10 +7,11 @@ // ----------------------------------------------------------------------- #endregion -#if AKKA +#if FSHARP + using Akka.Actor; -#endif -using Hyperion.FSharpTestTypes; +using System.Threading; +using Hyperion.Tests.FSharpData; using Microsoft.FSharp.Collections; using Microsoft.FSharp.Control; using Microsoft.FSharp.Core; @@ -53,6 +54,16 @@ public void CanSerializeSimpleDU() Assert.Equal(expected,actual); } + [Fact] + public void CanSerializeStructBasedDU() + { + var expected = SDU1.NewB("hello", 1); + Serialize(expected); + Reset(); + var actual = Deserialize(); + Assert.Equal(expected, actual); + } + [Fact] public void CanSerializeNestedDU() { @@ -83,22 +94,20 @@ public void CanSerializeOption() Assert.Equal(expected, actual); } -#if AKKA public class FooActor : UntypedActor { protected override void OnReceive(object message) { } } -#endif [Fact] - public void CanSerializeUser() + public void CanSerializeRecord() { - var expected = new User("foo", new FSharpOption(null), "hello"); + var expected = new TestRecord("foo", new FSharpOption(null), "hello"); Serialize(expected); Reset(); - var actual = Deserialize(); + var actual = Deserialize(); // Assert.Equal(expected, actual); Assert.Equal(expected.aref, actual.aref); Assert.Equal(expected.name, actual.name); @@ -106,16 +115,38 @@ public void CanSerializeUser() } + [Fact] + public void CanSerializeStructRecord() + { + var expected = new TestStructRecord("foo", new FSharpOption(null), "hello"); + Serialize(expected); + Reset(); + var actual = Deserialize(); + // Assert.Equal(expected, actual); + Assert.Equal(expected.aref, actual.aref); + Assert.Equal(expected.name, actual.name); + Assert.Equal(expected.connections, actual.connections); + + } + //FIXME: make F# quotations and Async serializable - //[Fact] + [Fact(Skip = "FIXME: problem with System.Core version=4.0")] public void CanSerializeQuotation() { var expected = TestQuotations.Quotation; Serialize(expected); Reset(); var actual = Deserialize>>>(); - // Assert.Equal(expected, actual); - Assert.Equal(expected, actual); + + var expectedFn = QuotationEvaluator.Compile(expected); + var actualFn = QuotationEvaluator.Compile(actual); + + var a = FSharpAsync.RunSynchronously(expectedFn.Invoke(5), FSharpOption.None, FSharpOption.None); + var b = FSharpAsync.RunSynchronously(actualFn.Invoke(5), FSharpOption.None, FSharpOption.None); + + Assert.Equal(a, b); } } } + +#endif \ No newline at end of file diff --git a/Hyperion.Tests/Hyperion.Tests.csproj b/Hyperion.Tests/Hyperion.Tests.csproj index 78bf6fb9..f0d5dfc6 100644 --- a/Hyperion.Tests/Hyperion.Tests.csproj +++ b/Hyperion.Tests/Hyperion.Tests.csproj @@ -1,35 +1,20 @@ + - Hyperion.Tests - net452;netcoreapp1.0 + net461;netcoreapp1.1 - - - - - - - - - + + + + + - - - + + + - - $(DefineConstants);SERIALIZATION;NET45;AKKA - - - - $(DefineConstants) - - - - $(DefineConstants);RELEASE - - \ No newline at end of file + diff --git a/Hyperion.Tests/ImmutableCollectionsTests.cs b/Hyperion.Tests/ImmutableCollectionsTests.cs index a8911cc2..4b1fbd79 100644 --- a/Hyperion.Tests/ImmutableCollectionsTests.cs +++ b/Hyperion.Tests/ImmutableCollectionsTests.cs @@ -7,7 +7,6 @@ // ----------------------------------------------------------------------- #endregion -using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; diff --git a/Hyperion.Tests/Properties/AssemblyInfo.cs b/Hyperion.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 94bd87f0..00000000 --- a/Hyperion.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,24 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("096c7e76-2170-4e5f-9da5-cd9ccaf0e5df")] diff --git a/Hyperion.Tests/UnsupportedTypeSerializerTests.cs b/Hyperion.Tests/UnsupportedTypeSerializerTests.cs index ce1ae80f..b9a1317e 100644 --- a/Hyperion.Tests/UnsupportedTypeSerializerTests.cs +++ b/Hyperion.Tests/UnsupportedTypeSerializerTests.cs @@ -9,7 +9,6 @@ using System; using System.IO; -using System.Threading; using System.Threading.Tasks; using Hyperion.ValueSerializers; using Xunit; diff --git a/Hyperion.sln b/Hyperion.sln index 42de7b47..31d67710 100644 --- a/Hyperion.sln +++ b/Hyperion.sln @@ -1,17 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26228.4 +VisualStudioVersion = 15.0.27004.2005 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyperion", "Hyperion\Hyperion.csproj", "{7AF8D2B6-9F1F-4A1C-8673-48E533108385}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyperion.Tests", "Hyperion.Tests\Hyperion.Tests.csproj", "{096C7E76-2170-4E5F-9DA5-CD9CCAF0E5DF}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyperion.PerfTest", "Hyperion.PerfTest\Hyperion.PerfTest.csproj", "{35352664-E867-48EC-A0B1-39013CA42FE0}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Hyperion.FSharpTestTypes", "Hyperion.FSharpTestTypes\Hyperion.FSharpTestTypes.fsproj", "{2D321671-6320-4DD2-B174-2773192D2A5A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyperion.PerformanceTests", "Hyperion.PerformanceTests\Hyperion.PerformanceTests.csproj", "{19E9324E-C3E9-4751-8B8F-5A456CA98E8C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperion", "Hyperion\Hyperion.csproj", "{7AF8D2B6-9F1F-4A1C-8673-48E533108385}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{2F3D4EC4-3A41-48C2-9DEA-0510B0FF89B4}" ProjectSection(SolutionItems) = preProject @@ -23,7 +15,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{2F3D4EC4 RELEASE_NOTES.md = RELEASE_NOTES.md EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyperion.Tests.Performance", "Hyperion.Tests.Performance\Hyperion.Tests.Performance.csproj", "{44AFCD2C-2220-4B52-817A-BD9C8B600E05}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Hyperion.Tests.FSharpData", "Hyperion.Tests.FSharpData\Hyperion.Tests.FSharpData.fsproj", "{1E406A85-C7F5-4F62-9D72-88C67FF2D743}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperion.Benchmarks", "Hyperion.Benchmarks\Hyperion.Benchmarks.csproj", "{CAE2DB69-0BE7-4B11-96DB-D5B61D35607F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyperion.Tests", "Hyperion.Tests\Hyperion.Tests.csproj", "{EA096BA2-3B4C-4878-B9AD-5A88D164EBF0}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -35,28 +31,23 @@ Global {7AF8D2B6-9F1F-4A1C-8673-48E533108385}.Debug|Any CPU.Build.0 = Debug|Any CPU {7AF8D2B6-9F1F-4A1C-8673-48E533108385}.Release|Any CPU.ActiveCfg = Release|Any CPU {7AF8D2B6-9F1F-4A1C-8673-48E533108385}.Release|Any CPU.Build.0 = Release|Any CPU - {096C7E76-2170-4E5F-9DA5-CD9CCAF0E5DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {096C7E76-2170-4E5F-9DA5-CD9CCAF0E5DF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {096C7E76-2170-4E5F-9DA5-CD9CCAF0E5DF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {096C7E76-2170-4E5F-9DA5-CD9CCAF0E5DF}.Release|Any CPU.Build.0 = Release|Any CPU - {35352664-E867-48EC-A0B1-39013CA42FE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {35352664-E867-48EC-A0B1-39013CA42FE0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {35352664-E867-48EC-A0B1-39013CA42FE0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {35352664-E867-48EC-A0B1-39013CA42FE0}.Release|Any CPU.Build.0 = Release|Any CPU - {2D321671-6320-4DD2-B174-2773192D2A5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2D321671-6320-4DD2-B174-2773192D2A5A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2D321671-6320-4DD2-B174-2773192D2A5A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2D321671-6320-4DD2-B174-2773192D2A5A}.Release|Any CPU.Build.0 = Release|Any CPU - {19E9324E-C3E9-4751-8B8F-5A456CA98E8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {19E9324E-C3E9-4751-8B8F-5A456CA98E8C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {19E9324E-C3E9-4751-8B8F-5A456CA98E8C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {19E9324E-C3E9-4751-8B8F-5A456CA98E8C}.Release|Any CPU.Build.0 = Release|Any CPU - {44AFCD2C-2220-4B52-817A-BD9C8B600E05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {44AFCD2C-2220-4B52-817A-BD9C8B600E05}.Debug|Any CPU.Build.0 = Debug|Any CPU - {44AFCD2C-2220-4B52-817A-BD9C8B600E05}.Release|Any CPU.ActiveCfg = Release|Any CPU - {44AFCD2C-2220-4B52-817A-BD9C8B600E05}.Release|Any CPU.Build.0 = Release|Any CPU + {1E406A85-C7F5-4F62-9D72-88C67FF2D743}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1E406A85-C7F5-4F62-9D72-88C67FF2D743}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1E406A85-C7F5-4F62-9D72-88C67FF2D743}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1E406A85-C7F5-4F62-9D72-88C67FF2D743}.Release|Any CPU.Build.0 = Release|Any CPU + {CAE2DB69-0BE7-4B11-96DB-D5B61D35607F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CAE2DB69-0BE7-4B11-96DB-D5B61D35607F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CAE2DB69-0BE7-4B11-96DB-D5B61D35607F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CAE2DB69-0BE7-4B11-96DB-D5B61D35607F}.Release|Any CPU.Build.0 = Release|Any CPU + {EA096BA2-3B4C-4878-B9AD-5A88D164EBF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EA096BA2-3B4C-4878-B9AD-5A88D164EBF0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EA096BA2-3B4C-4878-B9AD-5A88D164EBF0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EA096BA2-3B4C-4878-B9AD-5A88D164EBF0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B1C59E88-286D-4AD0-B5FC-94C8F95BF0FA} + EndGlobalSection EndGlobal diff --git a/Hyperion/Attributes.cs b/Hyperion/Attributes.cs new file mode 100644 index 00000000..cedbbb73 --- /dev/null +++ b/Hyperion/Attributes.cs @@ -0,0 +1,22 @@ +#region copyright +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2016 AsynkronIT +// Copyright (C) 2016-2016 Akka.NET Team +// +// ----------------------------------------------------------------------- +#endregion + +using System; + +namespace Hyperion +{ + /// + /// Just like `NonSerializedAttribute` Ignore attribute can be used to mark fields, + /// which should not be attached as part of the payload. + /// + [AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)] + public sealed class IgnoreAttribute : Attribute + { + } +} \ No newline at end of file diff --git a/Hyperion/ByteArrayKey.cs b/Hyperion/ByteArrayKey.cs index 6a1d467c..e54d69f1 100644 --- a/Hyperion/ByteArrayKey.cs +++ b/Hyperion/ByteArrayKey.cs @@ -11,7 +11,7 @@ namespace Hyperion { - public struct ByteArrayKey + internal struct ByteArrayKey { public readonly byte[] Bytes; private readonly int _hashCode; diff --git a/Hyperion/ByteArrayKeyComparer.cs b/Hyperion/ByteArrayKeyComparer.cs index a05a8b9a..9a921ad2 100644 --- a/Hyperion/ByteArrayKeyComparer.cs +++ b/Hyperion/ByteArrayKeyComparer.cs @@ -15,7 +15,7 @@ namespace Hyperion /// By default ByteArrayKey overrides "public bool Equals(object obj)" to do comparisons. /// But this causes boxing/allocations, so by having a custom comparer we can prevent that. /// - public class ByteArrayKeyComparer : IEqualityComparer + internal struct ByteArrayKeyComparer : IEqualityComparer { public static readonly ByteArrayKeyComparer Instance = new ByteArrayKeyComparer(); diff --git a/Hyperion/Compilation/Compiler.cs b/Hyperion/Compilation/Compiler.cs index 0602843c..1cd0a015 100644 --- a/Hyperion/Compilation/Compiler.cs +++ b/Hyperion/Compilation/Compiler.cs @@ -9,13 +9,13 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Linq.Expressions; using System.Reflection; +using System.Runtime.CompilerServices; namespace Hyperion.Compilation { - public class Compiler : ICompiler + internal sealed class Compiler : ICompiler { private readonly List _content = new List(); private readonly List _expressions = new List(); @@ -55,13 +55,16 @@ public int Variable(string name,Type type) public int GetVariable(string name) { - var existing = _expressions.OfType().First(v => v.Name == name && v.Type == typeof(T)); - if (existing == null) + var t = typeof(T); + for (int i = 0; i < _expressions.Count; i++) { - throw new Exception("Variable not found."); + if (_expressions[i] is ParameterExpression parameter && parameter.Name == name && parameter.Type == t) + { + return i; + } } - return _expressions.IndexOf(existing); + throw new Exception("Variable not found."); } public int Constant(object value) @@ -87,14 +90,14 @@ public int CastOrUnbox(int value, Type type) public void EmitCall(MethodInfo method, int target, params int[] arguments) { var targetExp = _expressions[target]; - var argumentsExp = arguments.Select(n => _expressions[n]).ToArray(); + var argumentsExp = ArgsToExpr(arguments); var call = Expression.Call(targetExp, method, argumentsExp); _content.Add(call); } public void EmitStaticCall(MethodInfo method, params int[] arguments) { - var argumentsExp = arguments.Select(n => _expressions[n]).ToArray(); + var argumentsExp = ArgsToExpr(arguments); var call = Expression.Call(null, method, argumentsExp); _content.Add(call); } @@ -102,7 +105,7 @@ public void EmitStaticCall(MethodInfo method, params int[] arguments) public int Call(MethodInfo method, int target, params int[] arguments) { var targetExp = _expressions[target]; - var argumentsExp = arguments.Select(n => _expressions[n]).ToArray(); + var argumentsExp = ArgsToExpr(arguments); var call = Expression.Call(targetExp, method, argumentsExp); _expressions.Add(call); return _expressions.Count - 1; @@ -110,7 +113,7 @@ public int Call(MethodInfo method, int target, params int[] arguments) public int StaticCall(MethodInfo method, params int[] arguments) { - var argumentsExp = arguments.Select(n => _expressions[n]).ToArray(); + var argumentsExp = ArgsToExpr(arguments); var call = Expression.Call(null, method, argumentsExp); _expressions.Add(call); return _expressions.Count - 1; @@ -145,7 +148,7 @@ public int WriteField(FieldInfo field, int typedTarget, int target, int value) public Expression ToBlock() { - if (!_content.Any()) + if (_content.Count == 0) { _content.Add(Expression.Empty()); } @@ -191,5 +194,18 @@ public int Convert(int value, Type type) _expressions.Add(conv); return _expressions.Count - 1; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private Expression[] ArgsToExpr(int[] arguments) + { + var result = new Expression[arguments.Length]; + var i = 0; + foreach (var n in arguments) + { + result[i] = _expressions[n]; + i++; + } + return result; + } } } \ No newline at end of file diff --git a/Hyperion/Compilation/ExpressionEx.cs b/Hyperion/Compilation/ExpressionEx.cs index 67759082..4d04c8c0 100644 --- a/Hyperion/Compilation/ExpressionEx.cs +++ b/Hyperion/Compilation/ExpressionEx.cs @@ -14,7 +14,7 @@ namespace Hyperion.Compilation { - public static class ExpressionEx + internal static class ExpressionEx { public static ConstantExpression ToConstant(this object self) { diff --git a/Hyperion/Compilation/IlBuilder.cs b/Hyperion/Compilation/IlBuilder.cs index 6f0e11b2..59e65239 100644 --- a/Hyperion/Compilation/IlBuilder.cs +++ b/Hyperion/Compilation/IlBuilder.cs @@ -16,7 +16,7 @@ namespace Hyperion.Compilation { #if NET45 - public class IlBuilder + internal class IlBuilder { private readonly List _expressions = new List(); protected List Parameters { get; } = new List(); @@ -86,10 +86,10 @@ public int GetVariable(string name) public int Constant(object value) { - if (value is bool) + if (value is bool b) { //doing this is faster than storing this as state - _expressions.Add(new IlBool((bool) value)); + _expressions.Add(new IlBool(b)); return _expressions.Count - 1; } diff --git a/Hyperion/Compilation/IlCompiler.cs b/Hyperion/Compilation/IlCompiler.cs index 99043fc5..32aee18c 100644 --- a/Hyperion/Compilation/IlCompiler.cs +++ b/Hyperion/Compilation/IlCompiler.cs @@ -15,7 +15,7 @@ namespace Hyperion.Compilation { #if NET45 - public class IlCompiler : IlBuilder, ICompiler + internal sealed class IlCompiler : IlBuilder, ICompiler { public TDel Compile() { diff --git a/Hyperion/Compilation/IlCompilerContext.cs b/Hyperion/Compilation/IlCompilerContext.cs index e6088135..5ea7c7c8 100644 --- a/Hyperion/Compilation/IlCompilerContext.cs +++ b/Hyperion/Compilation/IlCompilerContext.cs @@ -15,7 +15,7 @@ namespace Hyperion.Compilation { #if NET45 - public class IlCompilerContext + internal sealed class IlCompilerContext { private int _stackDepth; @@ -44,7 +44,7 @@ public int StackDepth public Type SelfType { get; } } - public class IlEmitter + internal sealed class IlEmitter { private readonly ILGenerator _il; private readonly StringBuilder _sb = new StringBuilder(); diff --git a/Hyperion/Compilation/IlExpression.cs b/Hyperion/Compilation/IlExpression.cs index d6dfa393..b864286d 100644 --- a/Hyperion/Compilation/IlExpression.cs +++ b/Hyperion/Compilation/IlExpression.cs @@ -15,13 +15,13 @@ namespace Hyperion.Compilation { #if NET45 - public abstract class IlExpression + internal abstract class IlExpression { public abstract void Emit(IlCompilerContext ctx); public abstract Type Type(); } - public class IlBool : IlExpression + internal sealed class IlBool : IlExpression { private readonly bool _value; @@ -39,7 +39,7 @@ public override void Emit(IlCompilerContext ctx) public override Type Type() => typeof(bool); } - public class IlRuntimeConstant : IlExpression + internal sealed class IlRuntimeConstant : IlExpression { private readonly object _object; public int Index { get; } @@ -61,7 +61,7 @@ public override void Emit(IlCompilerContext ctx) public override Type Type() => _object.GetType(); } - public class IlReadField : IlExpression + internal sealed class IlReadField : IlExpression { private readonly FieldInfo _field; private readonly IlExpression _target; @@ -82,7 +82,7 @@ public override void Emit(IlCompilerContext ctx) public override Type Type() => _field.FieldType; } - public class IlWriteVariable : IlExpression + internal sealed class IlWriteVariable : IlExpression { private readonly IlVariable _variable; private readonly IlExpression _value; @@ -106,7 +106,7 @@ public override Type Type() } } - public class IlWriteField : IlExpression + internal sealed class IlWriteField : IlExpression { private readonly FieldInfo _field; private readonly IlExpression _target; @@ -133,7 +133,7 @@ public override Type Type() } } - public class IlNew : IlExpression + internal sealed class IlNew : IlExpression { private readonly Type _type; @@ -153,7 +153,7 @@ public override void Emit(IlCompilerContext ctx) public override Type Type() => _type; } - public class IlParameter : IlExpression + internal sealed class IlParameter : IlExpression { public string Name { get; } public int ParameterIndex { get; } @@ -175,7 +175,7 @@ public override void Emit(IlCompilerContext ctx) public override Type Type() => _type; } - public class IlVariable : IlExpression + internal sealed class IlVariable : IlExpression { public int VariableIndex { get; } public string Name { get; } @@ -197,7 +197,7 @@ public override void Emit(IlCompilerContext ctx) public override Type Type() => VarType; } - public class IlCastClass : IlExpression + internal sealed class IlCastClass : IlExpression { private readonly Type _type; private readonly IlExpression _expression; @@ -219,7 +219,7 @@ public override void Emit(IlCompilerContext ctx) public override Type Type() => _type; } - public class IlBox : IlExpression + internal sealed class IlBox : IlExpression { private readonly Type _type; private readonly IlExpression _expression; @@ -239,7 +239,7 @@ public override void Emit(IlCompilerContext ctx) public override Type Type() => typeof(object); } - public class IlUnbox : IlExpression + internal sealed class IlUnbox : IlExpression { private readonly Type _type; private readonly IlExpression _expression; @@ -259,7 +259,7 @@ public override void Emit(IlCompilerContext ctx) public override Type Type() => _type; } - public class IlCall : IlExpression + internal sealed class IlCall : IlExpression { private readonly IlExpression _target; private readonly MethodInfo _method; @@ -295,7 +295,7 @@ public override void Emit(IlCompilerContext ctx) public override Type Type() => _method.ReturnType; } - public class IlCallStatic : IlExpression + internal sealed class IlCallStatic : IlExpression { private readonly MethodInfo _method; private readonly IlExpression[] _args; diff --git a/Hyperion/DefaultCodeGenerator.cs b/Hyperion/DefaultCodeGenerator.cs index 1aab89d8..0b5227a8 100644 --- a/Hyperion/DefaultCodeGenerator.cs +++ b/Hyperion/DefaultCodeGenerator.cs @@ -19,7 +19,7 @@ namespace Hyperion { - public class DefaultCodeGenerator : ICodeGenerator + internal class DefaultCodeGenerator : ICodeGenerator { public const string PreallocatedByteBuffer = "PreallocatedByteBuffer"; @@ -144,7 +144,8 @@ private ObjectWriter GetFieldsWriter([NotNull] Serializer serializer, [NotNull] } var fieldsArray = fields.ToArray(); - var serializers = fieldsArray.Select(field => serializer.GetSerializerByType(field.FieldType)).ToArray(); + var serializers = fieldsArray.Select(field => + serializer.GetSerializerByType(field.FieldType)).ToArray(); preallocatedBufferSize = serializers.Length != 0 ? serializers.Max(s => s.PreallocatedByteBufferSize) : 0; diff --git a/Hyperion/DeserializeSession.cs b/Hyperion/DeserializeSession.cs index 33f782f1..ed7bcadc 100644 --- a/Hyperion/DeserializeSession.cs +++ b/Hyperion/DeserializeSession.cs @@ -18,8 +18,7 @@ public class TypeVersionInfo { } - public class - DeserializerSession + public class DeserializerSession { public const int MinBufferSize = 9; private byte[] _buffer; diff --git a/Hyperion/Extensions/ReflectionEx.cs b/Hyperion/Extensions/ReflectionEx.cs index 5a6c1a85..4d445d75 100644 --- a/Hyperion/Extensions/ReflectionEx.cs +++ b/Hyperion/Extensions/ReflectionEx.cs @@ -18,12 +18,12 @@ namespace Hyperion.Extensions { - public static class BindingFlagsEx + internal static class BindingFlagsEx { public const BindingFlags All = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public; } - public static class ReflectionEx + internal static class ReflectionEx { public static readonly Assembly CoreAssembly = typeof(int).GetTypeInfo().Assembly; @@ -43,6 +43,7 @@ public static FieldInfo[] GetFieldInfosForType(this Type type) #if SERIALIZATION .Where(f => !f.IsDefined(typeof(NonSerializedAttribute))) #endif + .Where(f => !f.IsDefined(typeof(IgnoreAttribute))) .Where(f => !f.IsStatic) .Where(f => f.FieldType != typeof(IntPtr)) .Where(f => f.FieldType != typeof(UIntPtr)) diff --git a/Hyperion/Extensions/StreamEx.cs b/Hyperion/Extensions/StreamEx.cs index 4a2574c9..01c7cd09 100644 --- a/Hyperion/Extensions/StreamEx.cs +++ b/Hyperion/Extensions/StreamEx.cs @@ -13,7 +13,7 @@ namespace Hyperion.Extensions { - public static class StreamEx + internal static class StreamEx { public static uint ReadVarint32(this Stream stream) diff --git a/Hyperion/Extensions/TypeEx.cs b/Hyperion/Extensions/TypeEx.cs index cfb05d3a..7767e761 100644 --- a/Hyperion/Extensions/TypeEx.cs +++ b/Hyperion/Extensions/TypeEx.cs @@ -19,7 +19,7 @@ namespace Hyperion.Extensions { - public static class TypeEx + internal static class TypeEx { //Why not inline typeof you ask? //Because it actually generates calls to get the type. diff --git a/Hyperion/Properties/AssemblyInfo.cs b/Hyperion/Properties/AssemblyInfo.cs index 5885b023..c4cbd14f 100644 --- a/Hyperion/Properties/AssemblyInfo.cs +++ b/Hyperion/Properties/AssemblyInfo.cs @@ -8,6 +8,7 @@ #endregion using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; @@ -24,6 +25,7 @@ // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("7af8d2b6-9f1f-4a1c-8673-48e533108385")] +[assembly: InternalsVisibleTo("Hyperion.Tests")] #if UNSAFE [assembly: AllowPartiallyTrustedCallers] diff --git a/Hyperion/Serializer.cs b/Hyperion/Serializer.cs index ef8e7b8f..7bae7895 100644 --- a/Hyperion/Serializer.cs +++ b/Hyperion/Serializer.cs @@ -115,10 +115,8 @@ private void AddValueSerializer(ValueSerializer instance) [MethodImpl(MethodImplOptions.AggressiveInlining)] private ValueSerializer GetCustomDeserializer([NotNull] Type type) { - ValueSerializer serializer; - //do we already have a deserializer for this type? - if (_deserializers.TryGetValue(type, out serializer)) + if (_deserializers.TryGetValue(type, out var serializer)) return serializer; //is there a deserializer factory that can handle this type? @@ -202,10 +200,8 @@ public object Deserialize([NotNull] Stream stream, DeserializerSession session) public ValueSerializer GetSerializerByType([NotNull] Type type) { - ValueSerializer serializer; - //do we already have a serializer for this type? - if (_serializers.TryGetValue(type, out serializer)) + if (_serializers.TryGetValue(type, out var serializer)) return serializer; //is there a serializer factory that can handle this type? @@ -219,8 +215,7 @@ public ValueSerializer GetSerializerByType([NotNull] Type type) //none of the above, lets create a POCO object serializer serializer = new ObjectSerializer(type); - ushort index; - if (Options.KnownTypesDict.TryGetValue(type, out index)) + if (Options.KnownTypesDict.TryGetValue(type, out var index)) { var wrapper = new KnownTypeObjectSerializer((ObjectSerializer) serializer, index); if (!_serializers.TryAdd(type, wrapper)) diff --git a/Hyperion/SerializerFactories/ArraySerializerFactory.cs b/Hyperion/SerializerFactories/ArraySerializerFactory.cs index 1e3a3ac6..a4ac76a3 100644 --- a/Hyperion/SerializerFactories/ArraySerializerFactory.cs +++ b/Hyperion/SerializerFactories/ArraySerializerFactory.cs @@ -9,16 +9,13 @@ using System; using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Diagnostics; using System.IO; -using System.Runtime.ExceptionServices; using Hyperion.Extensions; using Hyperion.ValueSerializers; namespace Hyperion.SerializerFactories { - public class ArraySerializerFactory : ValueSerializerFactory + internal sealed class ArraySerializerFactory : ValueSerializerFactory { public override bool CanSerialize(Serializer serializer, Type type) => type.IsOneDimensionalArray(); diff --git a/Hyperion/SerializerFactories/ConsistentArraySerializerFactory.cs b/Hyperion/SerializerFactories/ConsistentArraySerializerFactory.cs index 8410c609..5528ceed 100644 --- a/Hyperion/SerializerFactories/ConsistentArraySerializerFactory.cs +++ b/Hyperion/SerializerFactories/ConsistentArraySerializerFactory.cs @@ -14,7 +14,7 @@ namespace Hyperion.SerializerFactories { - public class ConsistentArraySerializerFactory : ValueSerializerFactory + internal sealed class ConsistentArraySerializerFactory : ValueSerializerFactory { public override bool CanSerialize(Serializer serializer, Type type) { diff --git a/Hyperion/SerializerFactories/ConstructorInfoSerializerFactory.cs b/Hyperion/SerializerFactories/ConstructorInfoSerializerFactory.cs index 54dc4440..877bc950 100644 --- a/Hyperion/SerializerFactories/ConstructorInfoSerializerFactory.cs +++ b/Hyperion/SerializerFactories/ConstructorInfoSerializerFactory.cs @@ -16,7 +16,7 @@ namespace Hyperion.SerializerFactories { - public class ConstructorInfoSerializerFactory : ValueSerializerFactory + internal sealed class ConstructorInfoSerializerFactory : ValueSerializerFactory { public override bool CanSerialize(Serializer serializer, Type type) { diff --git a/Hyperion/SerializerFactories/DefaultDictionarySerializerFactory.cs b/Hyperion/SerializerFactories/DefaultDictionarySerializerFactory.cs index e85ec11a..b7d26ece 100644 --- a/Hyperion/SerializerFactories/DefaultDictionarySerializerFactory.cs +++ b/Hyperion/SerializerFactories/DefaultDictionarySerializerFactory.cs @@ -16,7 +16,7 @@ namespace Hyperion.SerializerFactories { - public class DefaultDictionarySerializerFactory : ValueSerializerFactory + internal sealed class DefaultDictionarySerializerFactory : ValueSerializerFactory { public override bool CanSerialize(Serializer serializer, Type type) => IsInterface(type); diff --git a/Hyperion/SerializerFactories/DelegateSerializerFactory.cs b/Hyperion/SerializerFactories/DelegateSerializerFactory.cs index 56d50705..850233df 100644 --- a/Hyperion/SerializerFactories/DelegateSerializerFactory.cs +++ b/Hyperion/SerializerFactories/DelegateSerializerFactory.cs @@ -15,7 +15,7 @@ namespace Hyperion.SerializerFactories { - public class DelegateSerializerFactory : ValueSerializerFactory + internal sealed class DelegateSerializerFactory : ValueSerializerFactory { public override bool CanSerialize(Serializer serializer, Type type) { diff --git a/Hyperion/SerializerFactories/DictionarySerializerFactory.cs b/Hyperion/SerializerFactories/DictionarySerializerFactory.cs index f064c1d9..62bf47e0 100644 --- a/Hyperion/SerializerFactories/DictionarySerializerFactory.cs +++ b/Hyperion/SerializerFactories/DictionarySerializerFactory.cs @@ -18,7 +18,7 @@ namespace Hyperion.SerializerFactories { - public class DictionarySerializerFactory : ValueSerializerFactory + internal sealed class DictionarySerializerFactory : ValueSerializerFactory { public override bool CanSerialize(Serializer serializer, Type type) => IsInterface(type); diff --git a/Hyperion/SerializerFactories/EnumerableSerializerFactory.cs b/Hyperion/SerializerFactories/EnumerableSerializerFactory.cs index e9a1cef3..2fc6a7e5 100644 --- a/Hyperion/SerializerFactories/EnumerableSerializerFactory.cs +++ b/Hyperion/SerializerFactories/EnumerableSerializerFactory.cs @@ -19,7 +19,7 @@ namespace Hyperion.SerializerFactories { - public class EnumerableSerializerFactory : ValueSerializerFactory + internal sealed class EnumerableSerializerFactory : ValueSerializerFactory { public override bool CanSerialize(Serializer serializer, Type type) { diff --git a/Hyperion/SerializerFactories/ExceptionSerializerFactory.cs b/Hyperion/SerializerFactories/ExceptionSerializerFactory.cs index 9b22769b..724f4a63 100644 --- a/Hyperion/SerializerFactories/ExceptionSerializerFactory.cs +++ b/Hyperion/SerializerFactories/ExceptionSerializerFactory.cs @@ -15,7 +15,7 @@ namespace Hyperion.SerializerFactories { - public class ExceptionSerializerFactory : ValueSerializerFactory + internal sealed class ExceptionSerializerFactory : ValueSerializerFactory { private static readonly TypeInfo ExceptionTypeInfo = typeof(Exception).GetTypeInfo(); private readonly FieldInfo _className; diff --git a/Hyperion/SerializerFactories/ExpandoObjectSerializerFactory.cs b/Hyperion/SerializerFactories/ExpandoObjectSerializerFactory.cs index e6b60156..b04775a0 100644 --- a/Hyperion/SerializerFactories/ExpandoObjectSerializerFactory.cs +++ b/Hyperion/SerializerFactories/ExpandoObjectSerializerFactory.cs @@ -16,7 +16,7 @@ namespace Hyperion.SerializerFactories { - public class ExpandoObjectSerializerFactory : ValueSerializerFactory + internal sealed class ExpandoObjectSerializerFactory : ValueSerializerFactory { public override bool CanSerialize(Serializer serializer, Type type) => type == typeof(System.Dynamic.ExpandoObject); diff --git a/Hyperion/SerializerFactories/FSharpListSerializerFactory.cs b/Hyperion/SerializerFactories/FSharpListSerializerFactory.cs index dc54a3b1..abcfd41f 100644 --- a/Hyperion/SerializerFactories/FSharpListSerializerFactory.cs +++ b/Hyperion/SerializerFactories/FSharpListSerializerFactory.cs @@ -17,7 +17,7 @@ namespace Hyperion.SerializerFactories { - public class FSharpListSerializerFactory : ValueSerializerFactory + internal sealed class FSharpListSerializerFactory : ValueSerializerFactory { public override bool CanSerialize(Serializer serializer, Type type) => type.FullName.StartsWith("Microsoft.FSharp.Collections.FSharpList`1"); diff --git a/Hyperion/SerializerFactories/FSharpMapSerializerFactory.cs b/Hyperion/SerializerFactories/FSharpMapSerializerFactory.cs index 468705aa..55db6c2d 100644 --- a/Hyperion/SerializerFactories/FSharpMapSerializerFactory.cs +++ b/Hyperion/SerializerFactories/FSharpMapSerializerFactory.cs @@ -17,7 +17,7 @@ namespace Hyperion.SerializerFactories { - public class FSharpMapSerializerFactory : ValueSerializerFactory + internal sealed class FSharpMapSerializerFactory : ValueSerializerFactory { public override bool CanSerialize(Serializer serializer, Type type) => type.FullName.StartsWith("Microsoft.FSharp.Collections.FSharpMap`2"); diff --git a/Hyperion/SerializerFactories/FieldInfoSerializerFactory.cs b/Hyperion/SerializerFactories/FieldInfoSerializerFactory.cs index 76a7f971..84685233 100644 --- a/Hyperion/SerializerFactories/FieldInfoSerializerFactory.cs +++ b/Hyperion/SerializerFactories/FieldInfoSerializerFactory.cs @@ -15,7 +15,7 @@ namespace Hyperion.SerializerFactories { - public class FieldInfoSerializerFactory : ValueSerializerFactory + internal sealed class FieldInfoSerializerFactory : ValueSerializerFactory { public override bool CanSerialize(Serializer serializer, Type type) { diff --git a/Hyperion/SerializerFactories/FromSurrogateSerializerFactory.cs b/Hyperion/SerializerFactories/FromSurrogateSerializerFactory.cs index a8bd318c..2409fc5b 100644 --- a/Hyperion/SerializerFactories/FromSurrogateSerializerFactory.cs +++ b/Hyperion/SerializerFactories/FromSurrogateSerializerFactory.cs @@ -15,7 +15,7 @@ namespace Hyperion.SerializerFactories { - public class FromSurrogateSerializerFactory : ValueSerializerFactory + internal sealed class FromSurrogateSerializerFactory : ValueSerializerFactory { public override bool CanSerialize(Serializer serializer, Type type) => false; diff --git a/Hyperion/SerializerFactories/ISerializableSerializerFactory.cs b/Hyperion/SerializerFactories/ISerializableSerializerFactory.cs index a38cfd27..11911e7b 100644 --- a/Hyperion/SerializerFactories/ISerializableSerializerFactory.cs +++ b/Hyperion/SerializerFactories/ISerializableSerializerFactory.cs @@ -17,7 +17,7 @@ namespace Hyperion.SerializerFactories { // ReSharper disable once InconsistentNaming - public class ISerializableSerializerFactory : ValueSerializerFactory + internal sealed class ISerializableSerializerFactory : ValueSerializerFactory { public override bool CanSerialize(Serializer serializer, Type type) { diff --git a/Hyperion/SerializerFactories/ImmutableCollectionsSerializerFactory.cs b/Hyperion/SerializerFactories/ImmutableCollectionsSerializerFactory.cs index a7c5a835..e6eab05e 100644 --- a/Hyperion/SerializerFactories/ImmutableCollectionsSerializerFactory.cs +++ b/Hyperion/SerializerFactories/ImmutableCollectionsSerializerFactory.cs @@ -18,7 +18,7 @@ namespace Hyperion.SerializerFactories { - public class ImmutableCollectionsSerializerFactory : ValueSerializerFactory + internal sealed class ImmutableCollectionsSerializerFactory : ValueSerializerFactory { private const string ImmutableCollectionsNamespace = "System.Collections.Immutable"; private const string ImmutableCollectionsAssembly = "System.Collections.Immutable"; diff --git a/Hyperion/SerializerFactories/MethodInfoSerializerFactory.cs b/Hyperion/SerializerFactories/MethodInfoSerializerFactory.cs index 2b95574a..44b63e41 100644 --- a/Hyperion/SerializerFactories/MethodInfoSerializerFactory.cs +++ b/Hyperion/SerializerFactories/MethodInfoSerializerFactory.cs @@ -16,7 +16,7 @@ namespace Hyperion.SerializerFactories { - public class MethodInfoSerializerFactory : ValueSerializerFactory + internal sealed class MethodInfoSerializerFactory : ValueSerializerFactory { public override bool CanSerialize(Serializer serializer, Type type) { diff --git a/Hyperion/SerializerFactories/PropertyInfoSerializerFactory.cs b/Hyperion/SerializerFactories/PropertyInfoSerializerFactory.cs index a978bdc7..c9359518 100644 --- a/Hyperion/SerializerFactories/PropertyInfoSerializerFactory.cs +++ b/Hyperion/SerializerFactories/PropertyInfoSerializerFactory.cs @@ -15,7 +15,7 @@ namespace Hyperion.SerializerFactories { - public class PropertyInfoSerializerFactory : ValueSerializerFactory + internal sealed class PropertyInfoSerializerFactory : ValueSerializerFactory { public override bool CanSerialize(Serializer serializer, Type type) { diff --git a/Hyperion/SerializerFactories/ToSurrogateSerializerFactory.cs b/Hyperion/SerializerFactories/ToSurrogateSerializerFactory.cs index 61de7e14..b6fab697 100644 --- a/Hyperion/SerializerFactories/ToSurrogateSerializerFactory.cs +++ b/Hyperion/SerializerFactories/ToSurrogateSerializerFactory.cs @@ -14,7 +14,7 @@ namespace Hyperion.SerializerFactories { - public class ToSurrogateSerializerFactory : ValueSerializerFactory + internal sealed class ToSurrogateSerializerFactory : ValueSerializerFactory { public override bool CanSerialize(Serializer serializer, Type type) { diff --git a/Hyperion/ValueSerializers/BoolSerializer.cs b/Hyperion/ValueSerializers/BoolSerializer.cs index 635eab4a..b56b443f 100644 --- a/Hyperion/ValueSerializers/BoolSerializer.cs +++ b/Hyperion/ValueSerializers/BoolSerializer.cs @@ -11,7 +11,7 @@ namespace Hyperion.ValueSerializers { - public class BoolSerializer : SessionIgnorantValueSerializer + internal sealed class BoolSerializer : SessionIgnorantValueSerializer { public const byte Manifest = 6; public static readonly BoolSerializer Instance = new BoolSerializer(); diff --git a/Hyperion/ValueSerializers/ByteArraySerializer.cs b/Hyperion/ValueSerializers/ByteArraySerializer.cs index b027a22e..aea98a86 100644 --- a/Hyperion/ValueSerializers/ByteArraySerializer.cs +++ b/Hyperion/ValueSerializers/ByteArraySerializer.cs @@ -13,7 +13,7 @@ namespace Hyperion.ValueSerializers { - public class ByteArraySerializer : ValueSerializer + internal sealed class ByteArraySerializer : ValueSerializer { public const byte Manifest = 9; public static readonly ByteArraySerializer Instance = new ByteArraySerializer(); diff --git a/Hyperion/ValueSerializers/ByteSerializer.cs b/Hyperion/ValueSerializers/ByteSerializer.cs index c0d86d9d..da422a76 100644 --- a/Hyperion/ValueSerializers/ByteSerializer.cs +++ b/Hyperion/ValueSerializers/ByteSerializer.cs @@ -11,7 +11,7 @@ namespace Hyperion.ValueSerializers { - public class ByteSerializer : SessionIgnorantValueSerializer + internal sealed class ByteSerializer : SessionIgnorantValueSerializer { public const byte Manifest = 4; public static readonly ByteSerializer Instance = new ByteSerializer(); diff --git a/Hyperion/ValueSerializers/CharSerializer.cs b/Hyperion/ValueSerializers/CharSerializer.cs index 389453c4..84cf3c0f 100644 --- a/Hyperion/ValueSerializers/CharSerializer.cs +++ b/Hyperion/ValueSerializers/CharSerializer.cs @@ -12,7 +12,7 @@ namespace Hyperion.ValueSerializers { - public class CharSerializer : SessionAwareByteArrayRequiringValueSerializer + internal sealed class CharSerializer : SessionAwareByteArrayRequiringValueSerializer { public const byte Manifest = 15; public const int Size = sizeof(char); diff --git a/Hyperion/ValueSerializers/ConsistentArraySerializer.cs b/Hyperion/ValueSerializers/ConsistentArraySerializer.cs index 9aa59deb..ec07500b 100644 --- a/Hyperion/ValueSerializers/ConsistentArraySerializer.cs +++ b/Hyperion/ValueSerializers/ConsistentArraySerializer.cs @@ -13,7 +13,7 @@ namespace Hyperion.ValueSerializers { - public class ConsistentArraySerializer : ValueSerializer + internal sealed class ConsistentArraySerializer : ValueSerializer { public const byte Manifest = 252; public static readonly ConsistentArraySerializer Instance = new ConsistentArraySerializer(); diff --git a/Hyperion/ValueSerializers/DateTimeSerializer.cs b/Hyperion/ValueSerializers/DateTimeSerializer.cs index 3d7167be..a608a431 100644 --- a/Hyperion/ValueSerializers/DateTimeSerializer.cs +++ b/Hyperion/ValueSerializers/DateTimeSerializer.cs @@ -12,7 +12,7 @@ namespace Hyperion.ValueSerializers { - public class DateTimeSerializer : SessionAwareByteArrayRequiringValueSerializer + internal sealed class DateTimeSerializer : SessionAwareByteArrayRequiringValueSerializer { public const byte Manifest = 5; public const int Size = sizeof(long) + sizeof(byte); diff --git a/Hyperion/ValueSerializers/DecimalSerializer.cs b/Hyperion/ValueSerializers/DecimalSerializer.cs index da44b8f9..1bfef0f5 100644 --- a/Hyperion/ValueSerializers/DecimalSerializer.cs +++ b/Hyperion/ValueSerializers/DecimalSerializer.cs @@ -12,7 +12,7 @@ namespace Hyperion.ValueSerializers { - public class DecimalSerializer : ValueSerializer + internal sealed class DecimalSerializer : ValueSerializer { public const byte Manifest = 14; public static readonly DecimalSerializer Instance = new DecimalSerializer(); diff --git a/Hyperion/ValueSerializers/DoubleSerializer.cs b/Hyperion/ValueSerializers/DoubleSerializer.cs index 5d4c3097..d1f2f437 100644 --- a/Hyperion/ValueSerializers/DoubleSerializer.cs +++ b/Hyperion/ValueSerializers/DoubleSerializer.cs @@ -12,7 +12,7 @@ namespace Hyperion.ValueSerializers { - public class DoubleSerializer : SessionAwareByteArrayRequiringValueSerializer + internal sealed class DoubleSerializer : SessionAwareByteArrayRequiringValueSerializer { public const byte Manifest = 13; public const int Size = sizeof(double); diff --git a/Hyperion/ValueSerializers/FloatSerializer.cs b/Hyperion/ValueSerializers/FloatSerializer.cs index be889a6e..8988aaab 100644 --- a/Hyperion/ValueSerializers/FloatSerializer.cs +++ b/Hyperion/ValueSerializers/FloatSerializer.cs @@ -12,7 +12,7 @@ namespace Hyperion.ValueSerializers { - public class FloatSerializer : SessionAwareByteArrayRequiringValueSerializer + internal sealed class FloatSerializer : SessionAwareByteArrayRequiringValueSerializer { public const byte Manifest = 12; public const int Size = sizeof(float); diff --git a/Hyperion/ValueSerializers/FromSurrogateSerializer.cs b/Hyperion/ValueSerializers/FromSurrogateSerializer.cs index e9c8ac35..8111cbda 100644 --- a/Hyperion/ValueSerializers/FromSurrogateSerializer.cs +++ b/Hyperion/ValueSerializers/FromSurrogateSerializer.cs @@ -12,7 +12,7 @@ namespace Hyperion.ValueSerializers { - public class FromSurrogateSerializer : ValueSerializer + internal sealed class FromSurrogateSerializer : ValueSerializer { private readonly ValueSerializer _surrogateSerializer; private readonly Func _translator; diff --git a/Hyperion/ValueSerializers/GuidSerializer.cs b/Hyperion/ValueSerializers/GuidSerializer.cs index 312ecb69..eaaac0f8 100644 --- a/Hyperion/ValueSerializers/GuidSerializer.cs +++ b/Hyperion/ValueSerializers/GuidSerializer.cs @@ -13,7 +13,7 @@ namespace Hyperion.ValueSerializers { - public class GuidSerializer : SessionIgnorantValueSerializer + internal sealed class GuidSerializer : SessionIgnorantValueSerializer { public const byte Manifest = 11; public static readonly GuidSerializer Instance = new GuidSerializer(); diff --git a/Hyperion/ValueSerializers/Int16Serializer.cs b/Hyperion/ValueSerializers/Int16Serializer.cs index f71a252a..3a38333b 100644 --- a/Hyperion/ValueSerializers/Int16Serializer.cs +++ b/Hyperion/ValueSerializers/Int16Serializer.cs @@ -12,7 +12,7 @@ namespace Hyperion.ValueSerializers { - public class Int16Serializer : SessionAwareByteArrayRequiringValueSerializer + internal sealed class Int16Serializer : SessionAwareByteArrayRequiringValueSerializer { public const byte Manifest = 3; public const int Size = sizeof(short); diff --git a/Hyperion/ValueSerializers/Int32Serializer.cs b/Hyperion/ValueSerializers/Int32Serializer.cs index ee406947..f7358e43 100644 --- a/Hyperion/ValueSerializers/Int32Serializer.cs +++ b/Hyperion/ValueSerializers/Int32Serializer.cs @@ -12,7 +12,7 @@ namespace Hyperion.ValueSerializers { - public class Int32Serializer : SessionAwareByteArrayRequiringValueSerializer + internal sealed class Int32Serializer : SessionAwareByteArrayRequiringValueSerializer { public const byte Manifest = 8; public const int Size = sizeof(int); diff --git a/Hyperion/ValueSerializers/Int64Serializer.cs b/Hyperion/ValueSerializers/Int64Serializer.cs index e4c8665a..d14ef9ab 100644 --- a/Hyperion/ValueSerializers/Int64Serializer.cs +++ b/Hyperion/ValueSerializers/Int64Serializer.cs @@ -12,7 +12,7 @@ namespace Hyperion.ValueSerializers { - public class Int64Serializer : SessionAwareByteArrayRequiringValueSerializer + internal sealed class Int64Serializer : SessionAwareByteArrayRequiringValueSerializer { public const byte Manifest = 2; public const int Size = sizeof(long); diff --git a/Hyperion/ValueSerializers/NullSerializer.cs b/Hyperion/ValueSerializers/NullSerializer.cs index 2a831e44..fb55f6a2 100644 --- a/Hyperion/ValueSerializers/NullSerializer.cs +++ b/Hyperion/ValueSerializers/NullSerializer.cs @@ -12,7 +12,7 @@ namespace Hyperion.ValueSerializers { - public class NullSerializer : ValueSerializer + internal sealed class NullSerializer : ValueSerializer { public const byte Manifest = 0; public static readonly NullSerializer Instance = new NullSerializer(); diff --git a/Hyperion/ValueSerializers/SByteSerializer.cs b/Hyperion/ValueSerializers/SByteSerializer.cs index e5db4bc9..54f48644 100644 --- a/Hyperion/ValueSerializers/SByteSerializer.cs +++ b/Hyperion/ValueSerializers/SByteSerializer.cs @@ -11,7 +11,7 @@ namespace Hyperion.ValueSerializers { - public class SByteSerializer : SessionIgnorantValueSerializer + internal sealed class SByteSerializer : SessionIgnorantValueSerializer { public const byte Manifest = 20; public static readonly SByteSerializer Instance = new SByteSerializer(); diff --git a/Hyperion/ValueSerializers/StringSerializer.cs b/Hyperion/ValueSerializers/StringSerializer.cs index 5c49ab81..596ab304 100644 --- a/Hyperion/ValueSerializers/StringSerializer.cs +++ b/Hyperion/ValueSerializers/StringSerializer.cs @@ -13,7 +13,7 @@ namespace Hyperion.ValueSerializers { - public class StringSerializer : ValueSerializer + internal sealed class StringSerializer : ValueSerializer { public const byte Manifest = 7; public static readonly StringSerializer Instance = new StringSerializer(); diff --git a/Hyperion/ValueSerializers/SystemObjectSerializer.cs b/Hyperion/ValueSerializers/SystemObjectSerializer.cs index 5a33658e..1bcd3839 100644 --- a/Hyperion/ValueSerializers/SystemObjectSerializer.cs +++ b/Hyperion/ValueSerializers/SystemObjectSerializer.cs @@ -12,7 +12,7 @@ namespace Hyperion.ValueSerializers { - public class SystemObjectSerializer : ValueSerializer + internal sealed class SystemObjectSerializer : ValueSerializer { public const byte Manifest = 1; public static SystemObjectSerializer Instance = new SystemObjectSerializer(); diff --git a/Hyperion/ValueSerializers/ToSurrogateSerializer.cs b/Hyperion/ValueSerializers/ToSurrogateSerializer.cs index 8f2ac9bf..aa619cd2 100644 --- a/Hyperion/ValueSerializers/ToSurrogateSerializer.cs +++ b/Hyperion/ValueSerializers/ToSurrogateSerializer.cs @@ -13,7 +13,7 @@ namespace Hyperion.ValueSerializers { - public class ToSurrogateSerializer : ValueSerializer + internal sealed class ToSurrogateSerializer : ValueSerializer { private readonly Func _translator; diff --git a/Hyperion/ValueSerializers/TypeSerializer.cs b/Hyperion/ValueSerializers/TypeSerializer.cs index 7eb37269..db4a3059 100644 --- a/Hyperion/ValueSerializers/TypeSerializer.cs +++ b/Hyperion/ValueSerializers/TypeSerializer.cs @@ -13,7 +13,7 @@ namespace Hyperion.ValueSerializers { - public class TypeSerializer : ValueSerializer + internal sealed class TypeSerializer : ValueSerializer { public const byte Manifest = 16; public static readonly TypeSerializer Instance = new TypeSerializer(); diff --git a/Hyperion/ValueSerializers/UInt16Serializer.cs b/Hyperion/ValueSerializers/UInt16Serializer.cs index 96c7a629..397fcbc8 100644 --- a/Hyperion/ValueSerializers/UInt16Serializer.cs +++ b/Hyperion/ValueSerializers/UInt16Serializer.cs @@ -12,7 +12,7 @@ namespace Hyperion.ValueSerializers { - public class UInt16Serializer : SessionAwareByteArrayRequiringValueSerializer + internal sealed class UInt16Serializer : SessionAwareByteArrayRequiringValueSerializer { public const byte Manifest = 17; public const int Size = sizeof(ushort); diff --git a/Hyperion/ValueSerializers/UInt32Serializer.cs b/Hyperion/ValueSerializers/UInt32Serializer.cs index 1a6c8b59..197564d0 100644 --- a/Hyperion/ValueSerializers/UInt32Serializer.cs +++ b/Hyperion/ValueSerializers/UInt32Serializer.cs @@ -12,7 +12,7 @@ namespace Hyperion.ValueSerializers { - public class UInt32Serializer : SessionAwareByteArrayRequiringValueSerializer + internal sealed class UInt32Serializer : SessionAwareByteArrayRequiringValueSerializer { public const byte Manifest = 18; public const int Size = sizeof(uint); diff --git a/Hyperion/ValueSerializers/UInt64Serializer.cs b/Hyperion/ValueSerializers/UInt64Serializer.cs index e7f50998..662d8666 100644 --- a/Hyperion/ValueSerializers/UInt64Serializer.cs +++ b/Hyperion/ValueSerializers/UInt64Serializer.cs @@ -12,7 +12,7 @@ namespace Hyperion.ValueSerializers { - public class UInt64Serializer : SessionAwareByteArrayRequiringValueSerializer + internal sealed class UInt64Serializer : SessionAwareByteArrayRequiringValueSerializer { public const byte Manifest = 19; public const int Size = sizeof(ulong); diff --git a/Hyperion/ValueSerializers/UnsupportedTypeSerializer.cs b/Hyperion/ValueSerializers/UnsupportedTypeSerializer.cs index 809a34f4..0036716f 100644 --- a/Hyperion/ValueSerializers/UnsupportedTypeSerializer.cs +++ b/Hyperion/ValueSerializers/UnsupportedTypeSerializer.cs @@ -23,7 +23,8 @@ public class UnsupportedTypeException:Exception public UnsupportedTypeException(Type t, string msg):base(msg) { } } - public class UnsupportedTypeSerializer:ValueSerializer + + internal sealed class UnsupportedTypeSerializer :ValueSerializer { private readonly string _errorMessage; private readonly Type _invalidType; diff --git a/build.fsx b/build.fsx index f006098e..61e2df4e 100644 --- a/build.fsx +++ b/build.fsx @@ -54,7 +54,7 @@ Target "Build" (fun _ -> let additionalArgs = if versionSuffix.Length > 0 then [sprintf "/p:VersionSuffix=%s" versionSuffix] else [] if (isWindows) then - let projects = !! "./**/*.csproj" + let projects = !! "./**/*.csproj" ++ "./**/*.fsproj" let runSingleProject project = DotNetCli.Build @@ -78,7 +78,7 @@ Target "Build" (fun _ -> (fun p -> { p with Project = "./Hyperion.Tests/Hyperion.Tests.csproj" - Framework = "netcoreapp1.0" + Framework = "netcoreapp1.1" Configuration = configuration AdditionalArgs = additionalArgs }) ) @@ -100,7 +100,7 @@ Target "RunTests" (fun _ -> (fun p -> { p with Project = "./Hyperion.Tests/Hyperion.Tests.csproj" - Framework = "netcoreapp1.0" + Framework = "netcoreapp1.1" Configuration = configuration }) ) @@ -126,28 +126,11 @@ Target "CopyOutput" (fun _ -> ) //-------------------------------------------------------------------------------- -// NBench targets +// Benchmarks //-------------------------------------------------------------------------------- -Target "NBench" (fun _ -> - if (isWindows) then - let nbenchTestPath = findToolInSubPath "NBench.Runner.exe" "tools/NBench.Runner/lib/net45" - let assembly = __SOURCE_DIRECTORY__ @@ "Hyperion.Tests.Performance/bin/Release/net45/Hyperion.Tests.Performance.dll" - - let spec = getBuildParam "spec" - - let args = new StringBuilder() - |> append assembly - |> append (sprintf "output-directory=\"%s\"" outputPerfTests) - |> append (sprintf "concurrent=\"%b\"" true) - |> append (sprintf "trace=\"%b\"" true) - |> toText - - let result = ExecProcess(fun info -> - info.FileName <- nbenchTestPath - info.WorkingDirectory <- (Path.GetDirectoryName (FullName nbenchTestPath)) - info.Arguments <- args) (System.TimeSpan.FromMinutes 15.0) (* Reasonably long-running task. *) - if result <> 0 then failwithf "NBench.Runner failed. %s %s" nbenchTestPath args +Target "Benchmarks" (fun _ -> + () //TODO: complete BenchmarkDotNet setup ) //-------------------------------------------------------------------------------- @@ -205,6 +188,7 @@ Target "Help" <| fun _ -> " * Build Builds" " * Nuget Create and optionally publish nugets packages" " * RunTests Runs tests" + " * Benchmarks Run BenchmarkDotNet performance tests" " * All Builds, run tests, creates and optionally publish nuget packages" "" " Other Targets" @@ -254,7 +238,10 @@ Target "Nuget" DoNothing // tests dependencies "Clean" ==> "RestorePackages" ==> "Build" ==> "RunTests" -"Clean" ==> "RestorePackages" ==> "Build" ==> "NBench" +"Clean" ==> "RestorePackages" ==> "Build" + +// benchmark dependencies +"BuildRelease" ==> "Benchmarks" // nuget dependencies "Clean" ==> "RestorePackages" ==> "Build" ==> "CreateNuget" @@ -264,6 +251,7 @@ Target "Nuget" DoNothing // all "BuildRelease" ==> "All" "RunTests" ==> "All" +"Benchmarks" ==> "All" "Nuget" ==> "All" RunTargetOrDefault "Help" \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index f1e5ff69..41178df5 100644 --- a/build.ps1 +++ b/build.ps1 @@ -29,12 +29,12 @@ Param( [string[]]$ScriptArgs ) -$FakeVersion = "4.50.0" +$FakeVersion = "4.63.0" $NBenchVersion = "0.3.4" -$DotNetChannel = "preview"; -$DotNetVersion = "1.0.4"; -$DotNetInstallerUri = "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/dotnet-install.ps1"; -$NugetVersion = "3.5.0"; +$DotNetChannel = "LTS"; +$DotNetVersion = "2.0.0"; +$DotNetInstallerUri = "https://raw.githubusercontent.com/dotnet/cli/v$DotNetVersion/scripts/obtain/dotnet-install.ps1"; +$NugetVersion = "4.3.0"; $NugetUrl = "https://dist.nuget.org/win-x86-commandline/v$NugetVersion/nuget.exe" # Make sure tools folder exists diff --git a/build.sh b/build.sh index 2d84218e..97f08cc0 100755 --- a/build.sh +++ b/build.sh @@ -8,10 +8,10 @@ SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) TOOLS_DIR=$SCRIPT_DIR/tools NUGET_EXE=$TOOLS_DIR/nuget.exe NUGET_URL=https://dist.nuget.org/win-x86-commandline/v3.5.0/nuget.exe -FAKE_VERSION=4.50.0 +FAKE_VERSION=4.63.0 FAKE_EXE=$TOOLS_DIR/FAKE/tools/FAKE.exe -DOTNET_VERSION=1.0.0 -DOTNET_INSTALLER_URL=https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/dotnet-install.sh +DOTNET_VERSION=2.0.0 +DOTNET_INSTALLER_URL=https://raw.githubusercontent.com/dotnet/cli/v$DOTNET_VERSION/scripts/obtain/dotnet-install.sh # Define default arguments. TARGET="Default" diff --git a/common.props b/common.props index 973e3486..dbd501d2 100644 --- a/common.props +++ b/common.props @@ -12,5 +12,6 @@ 2.3.0-beta4-* + 15.3.0 \ No newline at end of file From 3d00e7f2402d936a3fc4464d781a9b49f7bd6438 Mon Sep 17 00:00:00 2001 From: Aaron Stannard Date: Wed, 17 Jan 2018 09:33:34 -0600 Subject: [PATCH 2/2] restructured project to use pb-lib format --- Hyperion.PerfTest/Program.cs | 57 ---- Hyperion.PerfTest/Tests/DateTimeOffsetTest.cs | 21 -- Hyperion.sln | 8 +- build.fsx | 290 +++++++++--------- build.ps1 | 26 +- build.sh | 11 +- docs/api/index.md | 1 + docs/articles/index.md | 3 + docs/articles/toc.yml | 2 + docs/docfx.json | 67 ++++ docs/images/icon.png | Bin 0 -> 841 bytes docs/index.md | 1 + docs/toc.yml | 6 + .../Hyperion.Benchmarks.csproj | 1 + .../Hyperion.Benchmarks}/Program.cs | 0 .../Hyperion.Benchmarks}/Prolog.cs | 0 .../SerializeClassesBenchmark.cs | 0 .../SerializeCollectionsBenchmark.cs | 0 .../SerializeFSharpDataTypesBenchmark.cs | 0 .../SerializeImmutableCollectionsBenchmark.cs | 0 .../SerializePrimitivesBenchmark.cs | 0 .../SerializeStructsBenchmark.cs | 0 .../Hyperion.Tests.FSharpData.fsproj | 0 .../Hyperion.Tests.FSharpData}/Types.fs | 0 .../Hyperion.Tests}/AttributeTests.cs | 0 .../Hyperion.Tests}/Bugs.cs | 0 .../Hyperion.Tests}/CollectionTests.cs | 0 .../Hyperion.Tests}/CustomObjectTests.cs | 0 .../Hyperion.Tests}/CyclicTests.cs | 0 .../Hyperion.Tests}/DelegateTests.cs | 0 .../Hyperion.Tests}/EncapsulationTests.cs | 0 .../Hyperion.Tests}/ExpressionTests.cs | 0 .../Hyperion.Tests}/FSharpTests.cs | 0 .../Hyperion.Tests}/Hyperion.Tests.csproj | 12 +- .../Hyperion.Tests}/ISerializableTests.cs | 0 .../Hyperion.Tests}/IlCompilerTests.cs | 0 .../ImmutableCollectionsTests.cs | 0 .../Hyperion.Tests}/InterfaceTests.cs | 0 .../Hyperion.Tests}/PrimitivesTests.cs | 0 .../Hyperion.Tests}/Something.cs | 0 .../Hyperion.Tests}/SurrogateTests.cs | 0 .../Hyperion.Tests}/TestBase.cs | 0 .../UnsupportedTypeSerializerTests.cs | 0 .../Hyperion}/.vscode/launch.json | 0 {Hyperion => src/Hyperion}/.vscode/tasks.json | 0 {Hyperion => src/Hyperion}/Attributes.cs | 0 {Hyperion => src/Hyperion}/ByteArrayKey.cs | 0 .../Hyperion}/ByteArrayKeyComparer.cs | 0 .../Hyperion}/Compilation/Compiler.cs | 0 .../Hyperion}/Compilation/ExpressionEx.cs | 0 .../Hyperion}/Compilation/ICompiler.cs | 0 .../Hyperion}/Compilation/IlBuilder.cs | 0 .../Hyperion}/Compilation/IlCompiler.cs | 0 .../Compilation/IlCompilerContext.cs | 0 .../Hyperion}/Compilation/IlExpression.cs | 0 .../Hyperion}/DefaultCodeGenerator.cs | 0 {Hyperion => src/Hyperion}/Delegates.cs | 0 .../Hyperion}/DeserializeSession.cs | 0 .../Hyperion}/Extensions/ReflectionEx.cs | 0 .../Hyperion}/Extensions/StreamEx.cs | 0 .../Hyperion}/Extensions/StringEx.cs | 0 .../Hyperion}/Extensions/TypeEx.cs | 0 {Hyperion => src/Hyperion}/Hyperion.csproj | 0 {Hyperion => src/Hyperion}/ICodeGenerator.cs | 0 .../Hyperion}/Internal/Annotations.cs | 0 .../Hyperion}/NoAllocBitConverter.cs | 0 .../Hyperion}/Properties/AssemblyInfo.cs | 0 {Hyperion => src/Hyperion}/Serializer.cs | 0 .../ArraySerializerFactory.cs | 0 .../ConsistentArraySerializerFactory.cs | 0 .../ConstructorInfoSerializerFactory.cs | 0 .../DefaultDictionarySerializerFactory.cs | 0 .../DelegateSerializerFactory.cs | 0 .../DictionarySerializerFactory.cs | 0 .../EnumerableSerializerFactory.cs | 0 .../ExceptionSerializerFactory.cs | 0 .../ExpandoObjectSerializerFactory.cs | 0 .../FSharpListSerializerFactory.cs | 0 .../FSharpMapSerializerFactory.cs | 0 .../FieldInfoSerializerFactory.cs | 0 .../FromSurrogateSerializerFactory.cs | 0 .../ISerializableSerializerFactory.cs | 0 .../ImmutableCollectionsSerializerFactory.cs | 0 .../MethodInfoSerializerFactory.cs | 0 .../PropertyInfoSerializerFactory.cs | 0 .../ToSurrogateSerializerFactory.cs | 0 .../ValueSerializerFactory.cs | 0 .../Hyperion}/SerializerOptions.cs | 0 .../Hyperion}/SerializerSession.cs | 0 {Hyperion => src/Hyperion}/Surrogate.cs | 0 .../ValueSerializers/BoolSerializer.cs | 0 .../ValueSerializers/ByteArraySerializer.cs | 0 .../ValueSerializers/ByteSerializer.cs | 0 .../ValueSerializers/CharSerializer.cs | 0 .../ConsistentArraySerializer.cs | 0 .../DateTimeOffsetSerializer.cs | 0 .../ValueSerializers/DateTimeSerializer.cs | 0 .../ValueSerializers/DecimalSerializer.cs | 0 .../ValueSerializers/DoubleSerializer.cs | 0 .../ValueSerializers/FloatSerializer.cs | 0 .../FromSurrogateSerializer.cs | 0 .../ValueSerializers/GuidSerializer.cs | 0 .../ValueSerializers/Int16Serializer.cs | 0 .../ValueSerializers/Int32Serializer.cs | 0 .../ValueSerializers/Int64Serializer.cs | 0 .../KnownTypeObjectSerializer.cs | 0 .../ValueSerializers/NullSerializer.cs | 0 .../ObjectReferenceSerializer.cs | 0 .../ValueSerializers/ObjectSerializer.cs | 0 .../ValueSerializers/SByteSerializer.cs | 0 ...nAwareByteArrayRequiringValueSerializer.cs | 0 ...eByteArrayRequiringValueSerializer.cs.orig | 0 .../SessionIgnorantValueSerializer.cs | 0 .../ValueSerializers/StringSerializer.cs | 0 .../SystemObjectSerializer.cs | 0 .../ValueSerializers/ToSurrogateSerializer.cs | 0 .../ValueSerializers/TypeSerializer.cs | 0 .../ValueSerializers/UInt16Serializer.cs | 0 .../ValueSerializers/UInt32Serializer.cs | 0 .../ValueSerializers/UInt64Serializer.cs | 0 .../UnsupportedTypeSerializer.cs | 0 .../ValueSerializers/ValueSerializer.cs | 0 common.props => src/common.props | 5 +- 123 files changed, 275 insertions(+), 236 deletions(-) delete mode 100644 Hyperion.PerfTest/Program.cs delete mode 100644 Hyperion.PerfTest/Tests/DateTimeOffsetTest.cs create mode 100644 docs/api/index.md create mode 100644 docs/articles/index.md create mode 100644 docs/articles/toc.yml create mode 100644 docs/docfx.json create mode 100644 docs/images/icon.png create mode 100644 docs/index.md create mode 100644 docs/toc.yml rename {Hyperion.Benchmarks => src/Hyperion.Benchmarks}/Hyperion.Benchmarks.csproj (83%) rename {Hyperion.Benchmarks => src/Hyperion.Benchmarks}/Program.cs (100%) rename {Hyperion.Benchmarks => src/Hyperion.Benchmarks}/Prolog.cs (100%) rename {Hyperion.Benchmarks => src/Hyperion.Benchmarks}/SerializeClassesBenchmark.cs (100%) rename {Hyperion.Benchmarks => src/Hyperion.Benchmarks}/SerializeCollectionsBenchmark.cs (100%) rename {Hyperion.Benchmarks => src/Hyperion.Benchmarks}/SerializeFSharpDataTypesBenchmark.cs (100%) rename {Hyperion.Benchmarks => src/Hyperion.Benchmarks}/SerializeImmutableCollectionsBenchmark.cs (100%) rename {Hyperion.Benchmarks => src/Hyperion.Benchmarks}/SerializePrimitivesBenchmark.cs (100%) rename {Hyperion.Benchmarks => src/Hyperion.Benchmarks}/SerializeStructsBenchmark.cs (100%) rename {Hyperion.Tests.FSharpData => src/Hyperion.Tests.FSharpData}/Hyperion.Tests.FSharpData.fsproj (100%) rename {Hyperion.Tests.FSharpData => src/Hyperion.Tests.FSharpData}/Types.fs (100%) rename {Hyperion.Tests => src/Hyperion.Tests}/AttributeTests.cs (100%) rename {Hyperion.Tests => src/Hyperion.Tests}/Bugs.cs (100%) rename {Hyperion.Tests => src/Hyperion.Tests}/CollectionTests.cs (100%) rename {Hyperion.Tests => src/Hyperion.Tests}/CustomObjectTests.cs (100%) rename {Hyperion.Tests => src/Hyperion.Tests}/CyclicTests.cs (100%) rename {Hyperion.Tests => src/Hyperion.Tests}/DelegateTests.cs (100%) rename {Hyperion.Tests => src/Hyperion.Tests}/EncapsulationTests.cs (100%) rename {Hyperion.Tests => src/Hyperion.Tests}/ExpressionTests.cs (100%) rename {Hyperion.Tests => src/Hyperion.Tests}/FSharpTests.cs (100%) rename {Hyperion.Tests => src/Hyperion.Tests}/Hyperion.Tests.csproj (59%) rename {Hyperion.Tests => src/Hyperion.Tests}/ISerializableTests.cs (100%) rename {Hyperion.Tests => src/Hyperion.Tests}/IlCompilerTests.cs (100%) rename {Hyperion.Tests => src/Hyperion.Tests}/ImmutableCollectionsTests.cs (100%) rename {Hyperion.Tests => src/Hyperion.Tests}/InterfaceTests.cs (100%) rename {Hyperion.Tests => src/Hyperion.Tests}/PrimitivesTests.cs (100%) rename {Hyperion.Tests => src/Hyperion.Tests}/Something.cs (100%) rename {Hyperion.Tests => src/Hyperion.Tests}/SurrogateTests.cs (100%) rename {Hyperion.Tests => src/Hyperion.Tests}/TestBase.cs (100%) rename {Hyperion.Tests => src/Hyperion.Tests}/UnsupportedTypeSerializerTests.cs (100%) rename {Hyperion => src/Hyperion}/.vscode/launch.json (100%) rename {Hyperion => src/Hyperion}/.vscode/tasks.json (100%) rename {Hyperion => src/Hyperion}/Attributes.cs (100%) rename {Hyperion => src/Hyperion}/ByteArrayKey.cs (100%) rename {Hyperion => src/Hyperion}/ByteArrayKeyComparer.cs (100%) rename {Hyperion => src/Hyperion}/Compilation/Compiler.cs (100%) rename {Hyperion => src/Hyperion}/Compilation/ExpressionEx.cs (100%) rename {Hyperion => src/Hyperion}/Compilation/ICompiler.cs (100%) rename {Hyperion => src/Hyperion}/Compilation/IlBuilder.cs (100%) rename {Hyperion => src/Hyperion}/Compilation/IlCompiler.cs (100%) rename {Hyperion => src/Hyperion}/Compilation/IlCompilerContext.cs (100%) rename {Hyperion => src/Hyperion}/Compilation/IlExpression.cs (100%) rename {Hyperion => src/Hyperion}/DefaultCodeGenerator.cs (100%) rename {Hyperion => src/Hyperion}/Delegates.cs (100%) rename {Hyperion => src/Hyperion}/DeserializeSession.cs (100%) rename {Hyperion => src/Hyperion}/Extensions/ReflectionEx.cs (100%) rename {Hyperion => src/Hyperion}/Extensions/StreamEx.cs (100%) rename {Hyperion => src/Hyperion}/Extensions/StringEx.cs (100%) rename {Hyperion => src/Hyperion}/Extensions/TypeEx.cs (100%) rename {Hyperion => src/Hyperion}/Hyperion.csproj (100%) rename {Hyperion => src/Hyperion}/ICodeGenerator.cs (100%) rename {Hyperion => src/Hyperion}/Internal/Annotations.cs (100%) rename {Hyperion => src/Hyperion}/NoAllocBitConverter.cs (100%) rename {Hyperion => src/Hyperion}/Properties/AssemblyInfo.cs (100%) rename {Hyperion => src/Hyperion}/Serializer.cs (100%) rename {Hyperion => src/Hyperion}/SerializerFactories/ArraySerializerFactory.cs (100%) rename {Hyperion => src/Hyperion}/SerializerFactories/ConsistentArraySerializerFactory.cs (100%) rename {Hyperion => src/Hyperion}/SerializerFactories/ConstructorInfoSerializerFactory.cs (100%) rename {Hyperion => src/Hyperion}/SerializerFactories/DefaultDictionarySerializerFactory.cs (100%) rename {Hyperion => src/Hyperion}/SerializerFactories/DelegateSerializerFactory.cs (100%) rename {Hyperion => src/Hyperion}/SerializerFactories/DictionarySerializerFactory.cs (100%) rename {Hyperion => src/Hyperion}/SerializerFactories/EnumerableSerializerFactory.cs (100%) rename {Hyperion => src/Hyperion}/SerializerFactories/ExceptionSerializerFactory.cs (100%) rename {Hyperion => src/Hyperion}/SerializerFactories/ExpandoObjectSerializerFactory.cs (100%) rename {Hyperion => src/Hyperion}/SerializerFactories/FSharpListSerializerFactory.cs (100%) rename {Hyperion => src/Hyperion}/SerializerFactories/FSharpMapSerializerFactory.cs (100%) rename {Hyperion => src/Hyperion}/SerializerFactories/FieldInfoSerializerFactory.cs (100%) rename {Hyperion => src/Hyperion}/SerializerFactories/FromSurrogateSerializerFactory.cs (100%) rename {Hyperion => src/Hyperion}/SerializerFactories/ISerializableSerializerFactory.cs (100%) rename {Hyperion => src/Hyperion}/SerializerFactories/ImmutableCollectionsSerializerFactory.cs (100%) rename {Hyperion => src/Hyperion}/SerializerFactories/MethodInfoSerializerFactory.cs (100%) rename {Hyperion => src/Hyperion}/SerializerFactories/PropertyInfoSerializerFactory.cs (100%) rename {Hyperion => src/Hyperion}/SerializerFactories/ToSurrogateSerializerFactory.cs (100%) rename {Hyperion => src/Hyperion}/SerializerFactories/ValueSerializerFactory.cs (100%) rename {Hyperion => src/Hyperion}/SerializerOptions.cs (100%) rename {Hyperion => src/Hyperion}/SerializerSession.cs (100%) rename {Hyperion => src/Hyperion}/Surrogate.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/BoolSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/ByteArraySerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/ByteSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/CharSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/ConsistentArraySerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/DateTimeOffsetSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/DateTimeSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/DecimalSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/DoubleSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/FloatSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/FromSurrogateSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/GuidSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/Int16Serializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/Int32Serializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/Int64Serializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/KnownTypeObjectSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/NullSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/ObjectReferenceSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/ObjectSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/SByteSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/SessionAwareByteArrayRequiringValueSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/SessionAwareByteArrayRequiringValueSerializer.cs.orig (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/SessionIgnorantValueSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/StringSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/SystemObjectSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/ToSurrogateSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/TypeSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/UInt16Serializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/UInt32Serializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/UInt64Serializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/UnsupportedTypeSerializer.cs (100%) rename {Hyperion => src/Hyperion}/ValueSerializers/ValueSerializer.cs (100%) rename common.props => src/common.props (76%) diff --git a/Hyperion.PerfTest/Program.cs b/Hyperion.PerfTest/Program.cs deleted file mode 100644 index fc00791f..00000000 --- a/Hyperion.PerfTest/Program.cs +++ /dev/null @@ -1,57 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System; -using System.Threading; -using Hyperion.PerfTest.Tests; - -namespace Hyperion.PerfTest -{ - internal class Program - { - private static void Main(string[] args) - { - var t = new Thread(Run); - t.Priority = ThreadPriority.Highest; - t.IsBackground = true; - - t.Start(); - Console.ReadLine(); - } - - private static void Run() - { - var largeStructTest = new LargeStructTest(); - largeStructTest.Run(1000000); - - var guidArrayTest = new GuidArrayTest(); - guidArrayTest.Run(30000); - - var guidTest = new GuidTest(); - guidTest.Run(1000000); - - var dateTimeOffsetTest = new DateTimeOffsetTest(); - dateTimeOffsetTest.Run(1000000); - - var typicalPersonArrayTest = new TypicalPersonArrayTest(); - typicalPersonArrayTest.Run(1000); - - var typicalPersonTest = new TypicalPersonTest(); - typicalPersonTest.Run(100000); - - var typicalMessageArrayTest = new TypicalMessageArrayTest(); - typicalMessageArrayTest.Run(10000); - - var typicalMessageTest = new TypicalMessageTest(); - typicalMessageTest.Run(1000000); - - Console.ReadLine(); - } - } -} \ No newline at end of file diff --git a/Hyperion.PerfTest/Tests/DateTimeOffsetTest.cs b/Hyperion.PerfTest/Tests/DateTimeOffsetTest.cs deleted file mode 100644 index a1530099..00000000 --- a/Hyperion.PerfTest/Tests/DateTimeOffsetTest.cs +++ /dev/null @@ -1,21 +0,0 @@ -#region copyright -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 AsynkronIT -// Copyright (C) 2016-2016 Akka.NET Team -// -// ----------------------------------------------------------------------- -#endregion - -using System; - -namespace Hyperion.PerfTest.Tests -{ - class DateTimeOffsetTest : TestBase - { - protected override DateTimeOffset GetValue() - { - return DateTimeOffset.Now; - } - } -} diff --git a/Hyperion.sln b/Hyperion.sln index 31d67710..9cfc24f0 100644 --- a/Hyperion.sln +++ b/Hyperion.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27004.2005 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperion", "Hyperion\Hyperion.csproj", "{7AF8D2B6-9F1F-4A1C-8673-48E533108385}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperion", "src\Hyperion\Hyperion.csproj", "{7AF8D2B6-9F1F-4A1C-8673-48E533108385}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{2F3D4EC4-3A41-48C2-9DEA-0510B0FF89B4}" ProjectSection(SolutionItems) = preProject @@ -15,11 +15,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{2F3D4EC4 RELEASE_NOTES.md = RELEASE_NOTES.md EndProjectSection EndProject -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Hyperion.Tests.FSharpData", "Hyperion.Tests.FSharpData\Hyperion.Tests.FSharpData.fsproj", "{1E406A85-C7F5-4F62-9D72-88C67FF2D743}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Hyperion.Tests.FSharpData", "src\Hyperion.Tests.FSharpData\Hyperion.Tests.FSharpData.fsproj", "{1E406A85-C7F5-4F62-9D72-88C67FF2D743}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperion.Benchmarks", "Hyperion.Benchmarks\Hyperion.Benchmarks.csproj", "{CAE2DB69-0BE7-4B11-96DB-D5B61D35607F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperion.Benchmarks", "src\Hyperion.Benchmarks\Hyperion.Benchmarks.csproj", "{CAE2DB69-0BE7-4B11-96DB-D5B61D35607F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyperion.Tests", "Hyperion.Tests\Hyperion.Tests.csproj", "{EA096BA2-3B4C-4878-B9AD-5A88D164EBF0}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyperion.Tests", "src\Hyperion.Tests\Hyperion.Tests.csproj", "{EA096BA2-3B4C-4878-B9AD-5A88D164EBF0}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/build.fsx b/build.fsx index 61e2df4e..3a3c1bc2 100644 --- a/build.fsx +++ b/build.fsx @@ -7,149 +7,178 @@ open System.Text open Fake open Fake.DotNetCli +open Fake.DocFxHelper +open Fake.FileHelper -// Variables +// Information about the project for Nuget and Assembly info files let configuration = "Release" -// Directories -let output = __SOURCE_DIRECTORY__ @@ "build" -let outputTests = output @@ "TestResults" -let outputPerfTests = output @@ "perf" -let outputBinaries = output @@ "binaries" -let outputNuGet = output @@ "nuget" -let outputBinariesNet45 = outputBinaries @@ "net45" -let outputBinariesNetStandard = outputBinaries @@ "netstandard1.6" - +// Read release notes and version +let solutionFile = FindFirstMatchingFile "*.sln" __SOURCE_DIRECTORY__ // dynamically look up the solution let buildNumber = environVarOrDefault "BUILD_NUMBER" "0" +let preReleaseVersionSuffix = (if (not (buildNumber = "0")) then (buildNumber) else "") + "-beta" let versionSuffix = match (getBuildParam "nugetprerelease") with - | "dev" -> (if (not (buildNumber = "0")) then (buildNumber) else "") + "-beta" + | "dev" -> preReleaseVersionSuffix | _ -> "" +let releaseNotes = + File.ReadLines "./RELEASE_NOTES.md" + |> ReleaseNotesHelper.parseReleaseNotes + +// Directories +let toolsDir = __SOURCE_DIRECTORY__ @@ "tools" +let output = __SOURCE_DIRECTORY__ @@ "bin" +let outputTests = __SOURCE_DIRECTORY__ @@ "TestResults" +let outputPerfTests = __SOURCE_DIRECTORY__ @@ "PerfResults" +let outputNuGet = output @@ "nuget" + +// Copied from original NugetCreate target +let nugetDir = output @@ "nuget" +let workingDir = output @@ "build" +let nugetExe = FullName @"./tools/nuget.exe" + Target "Clean" (fun _ -> CleanDir output CleanDir outputTests CleanDir outputPerfTests - CleanDir outputBinaries CleanDir outputNuGet - CleanDir outputBinariesNet45 - CleanDir outputBinariesNetStandard - + CleanDir "docs/_site" CleanDirs !! "./**/bin" CleanDirs !! "./**/obj" ) -Target "RestorePackages" (fun _ -> - let additionalArgs = if versionSuffix.Length > 0 then [sprintf "/p:VersionSuffix=%s" versionSuffix] else [] +Target "AssemblyInfo" (fun _ -> + XmlPokeInnerText "./src/common.props" "//Project/PropertyGroup/VersionPrefix" releaseNotes.AssemblyVersion + XmlPokeInnerText "./src/common.props" "//Project/PropertyGroup/PackageReleaseNotes" (releaseNotes.Notes |> String.concat "\n") +) +Target "RestorePackages" (fun _ -> DotNetCli.Restore (fun p -> { p with - Project = "./Hyperion.sln" - NoCache = false - AdditionalArgs = additionalArgs }) + Project = solutionFile + NoCache = false}) ) -Target "Build" (fun _ -> - let additionalArgs = if versionSuffix.Length > 0 then [sprintf "/p:VersionSuffix=%s" versionSuffix] else [] - - if (isWindows) then - let projects = !! "./**/*.csproj" ++ "./**/*.fsproj" - - let runSingleProject project = - DotNetCli.Build - (fun p -> - { p with - Project = project - Configuration = configuration - AdditionalArgs = additionalArgs }) - - projects |> Seq.iter (runSingleProject) - else +Target "Build" (fun _ -> + let additionalArgs = if versionSuffix.Length > 0 then [sprintf "/p:VersionSuffix=%s" versionSuffix;"--no-incremental"] else ["--no-incremental"] + + let runSingleProject project = DotNetCli.Build (fun p -> { p with - Project = "./Hyperion/Hyperion.csproj" - Framework = "netstandard1.6" + Project = project Configuration = configuration - AdditionalArgs = additionalArgs }) + AdditionalArgs = additionalArgs}) // "Rebuild" - DotNetCli.Build - (fun p -> - { p with - Project = "./Hyperion.Tests/Hyperion.Tests.csproj" - Framework = "netcoreapp1.1" - Configuration = configuration - AdditionalArgs = additionalArgs }) + let assemblies = !! "./src/**/*.*sproj" + + assemblies |> Seq.iter (runSingleProject) ) -Target "RunTests" (fun _ -> - if (isWindows) then - let projects = !! "./**/Hyperion.Tests.csproj" +//-------------------------------------------------------------------------------- +// Tests targets +//-------------------------------------------------------------------------------- +module internal ResultHandling = + let (|OK|Failure|) = function + | 0 -> OK + | x -> Failure x - let runSingleProject project = - DotNetCli.Test - (fun p -> - { p with - Project = project - Configuration = configuration }) + let buildErrorMessage = function + | OK -> None + | Failure errorCode -> + Some (sprintf "xUnit2 reported an error (Error Code %d)" errorCode) - projects |> Seq.iter (runSingleProject) - else - DotNetCli.Test - (fun p -> - { p with - Project = "./Hyperion.Tests/Hyperion.Tests.csproj" - Framework = "netcoreapp1.1" - Configuration = configuration }) -) + let failBuildWithMessage = function + | DontFailBuild -> traceError + | _ -> (fun m -> raise(FailedTestsException m)) -Target "CopyOutput" (fun _ -> - // .NET 4.5 - if (isWindows) then - DotNetCli.Publish - (fun p -> - { p with - Project = "./Hyperion/Hyperion.csproj" - Framework = "net45" - Output = outputBinariesNet45 - Configuration = configuration }) + let failBuildIfXUnitReportedError errorLevel = + buildErrorMessage + >> Option.iter (failBuildWithMessage errorLevel) - // .NET Core - DotNetCli.Publish - (fun p -> - { p with - Project = "./Hyperion/Hyperion.csproj" - Framework = "netstandard1.6" - Output = outputBinariesNetStandard - Configuration = configuration }) +Target "RunTests" (fun _ -> + let projects = + match (isWindows) with + | true -> !! "./src/**/*.Tests.csproj" + | _ -> !! "./src/**/*.Tests.csproj" // if you need to filter specs for Linux vs. Windows, do it here + + let runSingleProject project = + let result = ExecProcess(fun info -> + info.FileName <- "dotnet" + info.WorkingDirectory <- (Directory.GetParent project).FullName + info.Arguments <- (sprintf "xunit -c Release -nobuild -parallel none -teamcity -xml %s_xunit.xml" (outputTests @@ fileNameWithoutExt project))) (TimeSpan.FromMinutes 30.) + + ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.DontFailBuild result + + projects |> Seq.iter (log) + projects |> Seq.iter (runSingleProject) ) -//-------------------------------------------------------------------------------- -// Benchmarks -//-------------------------------------------------------------------------------- +Target "NBench" <| fun _ -> + let nbenchTestPath = findToolInSubPath "NBench.Runner.exe" (toolsDir @@ "NBench.Runner*") + printfn "Using NBench.Runner: %s" nbenchTestPath + + let nbenchTestAssemblies = !! "./src/**/*Tests.Performance.csproj" + + let runNBench assembly = + let includes = getBuildParam "include" + let excludes = getBuildParam "exclude" + let teamcityStr = (getBuildParam "teamcity") + let enableTeamCity = + match teamcityStr with + | null -> false + | "" -> false + | _ -> bool.Parse teamcityStr + + let args = StringBuilder() + |> append assembly + |> append (sprintf "output-directory=\"%s\"" outputPerfTests) + |> append (sprintf "concurrent=\"%b\"" true) + |> append (sprintf "trace=\"%b\"" true) + |> append (sprintf "teamcity=\"%b\"" enableTeamCity) + |> appendIfNotNullOrEmpty includes "include=" + |> appendIfNotNullOrEmpty excludes "include=" + |> toText + + let result = ExecProcess(fun info -> + info.FileName <- nbenchTestPath + info.WorkingDirectory <- (Path.GetDirectoryName (FullName nbenchTestPath)) + info.Arguments <- args) (System.TimeSpan.FromMinutes 45.0) (* Reasonably long-running task. *) + if result <> 0 then failwithf "NBench.Runner failed. %s %s" nbenchTestPath args + + nbenchTestAssemblies |> Seq.iter runNBench -Target "Benchmarks" (fun _ -> - () //TODO: complete BenchmarkDotNet setup -) //-------------------------------------------------------------------------------- // Nuget targets //-------------------------------------------------------------------------------- -Target "CreateNuget" (fun _ -> - DotNetCli.Pack - (fun p -> - { p with - Project = "./Hyperion/Hyperion.csproj" - Configuration = configuration - AdditionalArgs = ["--include-symbols"] - VersionSuffix = versionSuffix - OutputPath = outputNuGet }) +let overrideVersionSuffix (project:string) = + match project with + | _ -> versionSuffix // add additional matches to publish different versions for different projects in solution +Target "CreateNuget" (fun _ -> + let projects = !! "src/**/*.csproj" + -- "src/**/*Tests.csproj" // Don't publish unit tests + -- "src/**/*Tests*.csproj" + -- "src/**/*.Demo.csproj" // Don't publish demo apps + + let runSingleProject project = + DotNetCli.Pack + (fun p -> + { p with + Project = project + Configuration = configuration + AdditionalArgs = ["--include-symbols"] + VersionSuffix = overrideVersionSuffix project + OutputPath = outputNuGet }) + + projects |> Seq.iter (runSingleProject) ) Target "PublishNuget" (fun _ -> - let projects = !! "./build/nuget/*.nupkg" -- "./build/nuget/*.symbols.nupkg" + let projects = !! "./bin/nuget/*.nupkg" -- "./bin/nuget/*.symbols.nupkg" let apiKey = getBuildParamOrDefault "nugetkey" "" let source = getBuildParamOrDefault "nugetpublishurl" "" let symbolSource = getBuildParamOrDefault "symbolspublishurl" "" @@ -175,6 +204,22 @@ Target "PublishNuget" (fun _ -> projects |> Seq.iter (runSingleProject) ) +//-------------------------------------------------------------------------------- +// Documentation +//-------------------------------------------------------------------------------- +Target "DocFx" (fun _ -> + DotNetCli.Restore (fun p -> { p with Project = solutionFile }) + DotNetCli.Build (fun p -> { p with Project = solutionFile; Configuration = configuration }) + + let docsPath = "./docs" + + DocFx (fun p -> + { p with + Timeout = TimeSpan.FromMinutes 30.0; + WorkingDirectory = docsPath; + DocFxJson = docsPath @@ "docfx.json" }) +) + //-------------------------------------------------------------------------------- // Help //-------------------------------------------------------------------------------- @@ -182,49 +227,19 @@ Target "PublishNuget" (fun _ -> Target "Help" <| fun _ -> List.iter printfn [ "usage:" - "/build [target]" + "./build.ps1 [target]" "" " Targets for building:" " * Build Builds" " * Nuget Create and optionally publish nugets packages" " * RunTests Runs tests" - " * Benchmarks Run BenchmarkDotNet performance tests" " * All Builds, run tests, creates and optionally publish nuget packages" + " * DocFx Creates a DocFx-based website for this solution" "" " Other Targets" " * Help Display this help" ""] -Target "HelpNuget" <| fun _ -> - List.iter printfn [ - "usage: " - "build Nuget [nugetkey= [nugetpublishurl=]] " - " [symbolspublishurl=] " - "" - "In order to publish a nuget package, keys must be specified." - "If a key is not specified the nuget packages will only be created on disk" - "After a build you can find them in build/nuget" - "" - "For pushing nuget packages to nuget.org and symbols to symbolsource.org" - "you need to specify nugetkey=" - " build Nuget nugetKey=" - "" - "For pushing the ordinary nuget packages to another place than nuget.org specify the url" - " nugetkey= nugetpublishurl= " - "" - "For pushing symbols packages specify:" - " symbolskey= symbolspublishurl= " - "" - "Examples:" - " build Nuget Build nuget packages to the build/nuget folder" - "" - " build Nuget versionsuffix=beta1 Build nuget packages with the custom version suffix" - "" - " build Nuget nugetkey=123 Build and publish to nuget.org and symbolsource.org" - "" - " build Nuget nugetprerelease=dev nugetkey=123 nugetpublishurl=http://abcsymbolspublishurl=http://xyz" - ""] - //-------------------------------------------------------------------------------- // Target dependencies //-------------------------------------------------------------------------------- @@ -234,24 +249,21 @@ Target "All" DoNothing Target "Nuget" DoNothing // build dependencies -"Clean" ==> "RestorePackages" ==> "Build" ==> "CopyOutput" ==> "BuildRelease" +"Clean" ==> "RestorePackages" ==> "AssemblyInfo" ==> "Build" ==> "BuildRelease" // tests dependencies -"Clean" ==> "RestorePackages" ==> "Build" ==> "RunTests" -"Clean" ==> "RestorePackages" ==> "Build" - -// benchmark dependencies -"BuildRelease" ==> "Benchmarks" // nuget dependencies "Clean" ==> "RestorePackages" ==> "Build" ==> "CreateNuget" -"CreateNuget" ==> "PublishNuget" -"PublishNuget" ==> "Nuget" +"CreateNuget" ==> "PublishNuget" ==> "Nuget" + +// docs +"BuildRelease" ==> "Docfx" // all "BuildRelease" ==> "All" "RunTests" ==> "All" -"Benchmarks" ==> "All" +//"NBench" ==> "All" "Nuget" ==> "All" RunTargetOrDefault "Help" \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index 41178df5..f2180fc3 100644 --- a/build.ps1 +++ b/build.ps1 @@ -29,13 +29,15 @@ Param( [string[]]$ScriptArgs ) -$FakeVersion = "4.63.0" -$NBenchVersion = "0.3.4" +$FakeVersion = "4.61.2" +$NBenchVersion = "1.0.1" $DotNetChannel = "LTS"; $DotNetVersion = "2.0.0"; $DotNetInstallerUri = "https://raw.githubusercontent.com/dotnet/cli/v$DotNetVersion/scripts/obtain/dotnet-install.ps1"; -$NugetVersion = "4.3.0"; +$NugetVersion = "4.1.0"; $NugetUrl = "https://dist.nuget.org/win-x86-commandline/v$NugetVersion/nuget.exe" +$ProtobufVersion = "3.2.0" +$DocfxVersion = "2.21.1" # Make sure tools folder exists $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent @@ -70,6 +72,8 @@ Function Remove-PathVariable([string]$VariableToRemove) $FoundDotNetCliVersion = $null; if (Get-Command dotnet -ErrorAction SilentlyContinue) { $FoundDotNetCliVersion = dotnet --version; + $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 + $env:DOTNET_CLI_TELEMETRY_OPTOUT=1 } if($FoundDotNetCliVersion -ne $DotNetVersion) { @@ -78,7 +82,7 @@ if($FoundDotNetCliVersion -ne $DotNetVersion) { mkdir -Force $InstallPath | Out-Null; } (New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1"); - & $InstallPath\dotnet-install.ps1 -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath; + & $InstallPath\dotnet-install.ps1 -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath -Architecture x64; Remove-PathVariable "$InstallPath" $env:PATH = "$InstallPath;$env:PATH" @@ -125,6 +129,20 @@ if (!(Test-Path $NBenchDllPath)) { } } +########################################################################### +# Docfx +########################################################################### + +# Make sure Docfx has been installed. +$DocfxExePath = Join-Path $ToolPath "docfx.console/tools/docfx.exe" +if (!(Test-Path $DocfxExePath)) { + Write-Host "Installing Docfx..." + Invoke-Expression "&`"$NugetPath`" install docfx.console -ExcludeVersion -Version $DocfxVersion -OutputDirectory `"$ToolPath`"" | Out-Null; + if ($LASTEXITCODE -ne 0) { + Throw "An error occured while restoring docfx.console from NuGet." + } +} + ########################################################################### # RUN BUILD SCRIPT ########################################################################### diff --git a/build.sh b/build.sh index 97f08cc0..90e7d528 100755 --- a/build.sh +++ b/build.sh @@ -7,10 +7,10 @@ SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) TOOLS_DIR=$SCRIPT_DIR/tools NUGET_EXE=$TOOLS_DIR/nuget.exe -NUGET_URL=https://dist.nuget.org/win-x86-commandline/v3.5.0/nuget.exe -FAKE_VERSION=4.63.0 +NUGET_URL=https://dist.nuget.org/win-x86-commandline/v4.1.0/nuget.exe +FAKE_VERSION=4.61.2 FAKE_EXE=$TOOLS_DIR/FAKE/tools/FAKE.exe -DOTNET_VERSION=2.0.0 +DOTNET_VERSION=2.0.3 DOTNET_INSTALLER_URL=https://raw.githubusercontent.com/dotnet/cli/v$DOTNET_VERSION/scripts/obtain/dotnet-install.sh # Define default arguments. @@ -86,6 +86,11 @@ if [ ! -f "$FAKE_EXE" ]; then exit 1 fi +########################################################################### +# WORKAROUND FOR MONO +########################################################################### +export FrameworkPathOverride=/usr/lib/mono/4.5/ + ########################################################################### # RUN BUILD SCRIPT ########################################################################### diff --git a/docs/api/index.md b/docs/api/index.md new file mode 100644 index 00000000..9e0155be --- /dev/null +++ b/docs/api/index.md @@ -0,0 +1 @@ +# API Docs \ No newline at end of file diff --git a/docs/articles/index.md b/docs/articles/index.md new file mode 100644 index 00000000..9d45024d --- /dev/null +++ b/docs/articles/index.md @@ -0,0 +1,3 @@ +# Introduction + +Article text goes here. \ No newline at end of file diff --git a/docs/articles/toc.yml b/docs/articles/toc.yml new file mode 100644 index 00000000..4262931e --- /dev/null +++ b/docs/articles/toc.yml @@ -0,0 +1,2 @@ +- name: Introduction + href: index.md \ No newline at end of file diff --git a/docs/docfx.json b/docs/docfx.json new file mode 100644 index 00000000..ae92cc07 --- /dev/null +++ b/docs/docfx.json @@ -0,0 +1,67 @@ +{ + "metadata": [ + { + "src": [ + { + "files": [ "**/*.csproj" ], + "exclude": [ + "**/obj/**", + "**/bin/**", + "_site/**", + "**/*Tests*.csproj", + "**/*Tests.*.csproj" + ], + "src": "../src" + } + ], + "dest": "api" + } + ], + "build": { + "content": [ + { + "files": [ + "api/**.yml", + "api/index.md" + ] + }, + { + "files": [ + "articles/**.md", + "articles/**/toc.yml", + "toc.yml", + "*.md" + ], + "exclude": [ + "obj/**", + "_site/**" + ] + }, + ], + "resource": [ + { + "files": [ + "images/**" + ], + "exclude": [ + "obj/**", + "_site/**" + ] + } + ], + "dest": "_site", + "globalMetadata": { + "_appTitle": "gdax_stsdfsdf", + "_disableContribution": "true", + "_appLogoPath": "/images/icon.png", + }, + "globalMetadataFiles": [], + "fileMetadataFiles": [], + "template": [ + "default", + "template" + ], + "postProcessors": [], + "noLangKeyword": false + } +} \ No newline at end of file diff --git a/docs/images/icon.png b/docs/images/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..86698cd6d92eabd00b206f56d4ffbfa59be23a15 GIT binary patch literal 841 zcmeAS@N?(olHy`uVBq!ia0vp^Q6S901|%(3I5Gh##^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!pk#?_L`iUdT1k0gQ7S`0VrE{6US4X6f{C7i zo}syM-uz?+2Bw{!E{-7;ac{5NW`{UR9Q`O@&}AkS*rKqawL^u4m9yj61Mk#C(Wa)K zY?*KVF#Y1>;fVT?C&0Z?pjmLSMwgh|h7B9GZr&_7@vF`09-p@2-IG@roM*N-`aJ)% z*kiTbd|#?;vl)Arxi5ZsF{8?4mK<%FH`vbjNn~0`H#%?F_^`&<=fJ(T&tEqzf7tVF zt6Q?P!S@HLSNjfzcleg=x46&NAAG*<@X=SLc}q6`Ts7Z!?my;rs#3QbB1Y>BqevxWR9=1&bDQ>F<*);m<9co+`hyQ%-Z><4bDGE zJABi#!{&OqV{rl#NtG}bpBkK>0H~5x6Wd8C$xvBI04f%&0JO}G`a1~bUs93w>MX3Co z8QKEf7w&fZy|t)ms!_cEAgFL3>m#9hhq`CFGHc?Vi(L`7< Exe netcoreapp2.0 + false diff --git a/Hyperion.Benchmarks/Program.cs b/src/Hyperion.Benchmarks/Program.cs similarity index 100% rename from Hyperion.Benchmarks/Program.cs rename to src/Hyperion.Benchmarks/Program.cs diff --git a/Hyperion.Benchmarks/Prolog.cs b/src/Hyperion.Benchmarks/Prolog.cs similarity index 100% rename from Hyperion.Benchmarks/Prolog.cs rename to src/Hyperion.Benchmarks/Prolog.cs diff --git a/Hyperion.Benchmarks/SerializeClassesBenchmark.cs b/src/Hyperion.Benchmarks/SerializeClassesBenchmark.cs similarity index 100% rename from Hyperion.Benchmarks/SerializeClassesBenchmark.cs rename to src/Hyperion.Benchmarks/SerializeClassesBenchmark.cs diff --git a/Hyperion.Benchmarks/SerializeCollectionsBenchmark.cs b/src/Hyperion.Benchmarks/SerializeCollectionsBenchmark.cs similarity index 100% rename from Hyperion.Benchmarks/SerializeCollectionsBenchmark.cs rename to src/Hyperion.Benchmarks/SerializeCollectionsBenchmark.cs diff --git a/Hyperion.Benchmarks/SerializeFSharpDataTypesBenchmark.cs b/src/Hyperion.Benchmarks/SerializeFSharpDataTypesBenchmark.cs similarity index 100% rename from Hyperion.Benchmarks/SerializeFSharpDataTypesBenchmark.cs rename to src/Hyperion.Benchmarks/SerializeFSharpDataTypesBenchmark.cs diff --git a/Hyperion.Benchmarks/SerializeImmutableCollectionsBenchmark.cs b/src/Hyperion.Benchmarks/SerializeImmutableCollectionsBenchmark.cs similarity index 100% rename from Hyperion.Benchmarks/SerializeImmutableCollectionsBenchmark.cs rename to src/Hyperion.Benchmarks/SerializeImmutableCollectionsBenchmark.cs diff --git a/Hyperion.Benchmarks/SerializePrimitivesBenchmark.cs b/src/Hyperion.Benchmarks/SerializePrimitivesBenchmark.cs similarity index 100% rename from Hyperion.Benchmarks/SerializePrimitivesBenchmark.cs rename to src/Hyperion.Benchmarks/SerializePrimitivesBenchmark.cs diff --git a/Hyperion.Benchmarks/SerializeStructsBenchmark.cs b/src/Hyperion.Benchmarks/SerializeStructsBenchmark.cs similarity index 100% rename from Hyperion.Benchmarks/SerializeStructsBenchmark.cs rename to src/Hyperion.Benchmarks/SerializeStructsBenchmark.cs diff --git a/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj b/src/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj similarity index 100% rename from Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj rename to src/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj diff --git a/Hyperion.Tests.FSharpData/Types.fs b/src/Hyperion.Tests.FSharpData/Types.fs similarity index 100% rename from Hyperion.Tests.FSharpData/Types.fs rename to src/Hyperion.Tests.FSharpData/Types.fs diff --git a/Hyperion.Tests/AttributeTests.cs b/src/Hyperion.Tests/AttributeTests.cs similarity index 100% rename from Hyperion.Tests/AttributeTests.cs rename to src/Hyperion.Tests/AttributeTests.cs diff --git a/Hyperion.Tests/Bugs.cs b/src/Hyperion.Tests/Bugs.cs similarity index 100% rename from Hyperion.Tests/Bugs.cs rename to src/Hyperion.Tests/Bugs.cs diff --git a/Hyperion.Tests/CollectionTests.cs b/src/Hyperion.Tests/CollectionTests.cs similarity index 100% rename from Hyperion.Tests/CollectionTests.cs rename to src/Hyperion.Tests/CollectionTests.cs diff --git a/Hyperion.Tests/CustomObjectTests.cs b/src/Hyperion.Tests/CustomObjectTests.cs similarity index 100% rename from Hyperion.Tests/CustomObjectTests.cs rename to src/Hyperion.Tests/CustomObjectTests.cs diff --git a/Hyperion.Tests/CyclicTests.cs b/src/Hyperion.Tests/CyclicTests.cs similarity index 100% rename from Hyperion.Tests/CyclicTests.cs rename to src/Hyperion.Tests/CyclicTests.cs diff --git a/Hyperion.Tests/DelegateTests.cs b/src/Hyperion.Tests/DelegateTests.cs similarity index 100% rename from Hyperion.Tests/DelegateTests.cs rename to src/Hyperion.Tests/DelegateTests.cs diff --git a/Hyperion.Tests/EncapsulationTests.cs b/src/Hyperion.Tests/EncapsulationTests.cs similarity index 100% rename from Hyperion.Tests/EncapsulationTests.cs rename to src/Hyperion.Tests/EncapsulationTests.cs diff --git a/Hyperion.Tests/ExpressionTests.cs b/src/Hyperion.Tests/ExpressionTests.cs similarity index 100% rename from Hyperion.Tests/ExpressionTests.cs rename to src/Hyperion.Tests/ExpressionTests.cs diff --git a/Hyperion.Tests/FSharpTests.cs b/src/Hyperion.Tests/FSharpTests.cs similarity index 100% rename from Hyperion.Tests/FSharpTests.cs rename to src/Hyperion.Tests/FSharpTests.cs diff --git a/Hyperion.Tests/Hyperion.Tests.csproj b/src/Hyperion.Tests/Hyperion.Tests.csproj similarity index 59% rename from Hyperion.Tests/Hyperion.Tests.csproj rename to src/Hyperion.Tests/Hyperion.Tests.csproj index f0d5dfc6..7c291918 100644 --- a/Hyperion.Tests/Hyperion.Tests.csproj +++ b/src/Hyperion.Tests/Hyperion.Tests.csproj @@ -1,15 +1,17 @@ + - net461;netcoreapp1.1 + net461;netcoreapp2.0 + 2.0.3 - + - - - + + + diff --git a/Hyperion.Tests/ISerializableTests.cs b/src/Hyperion.Tests/ISerializableTests.cs similarity index 100% rename from Hyperion.Tests/ISerializableTests.cs rename to src/Hyperion.Tests/ISerializableTests.cs diff --git a/Hyperion.Tests/IlCompilerTests.cs b/src/Hyperion.Tests/IlCompilerTests.cs similarity index 100% rename from Hyperion.Tests/IlCompilerTests.cs rename to src/Hyperion.Tests/IlCompilerTests.cs diff --git a/Hyperion.Tests/ImmutableCollectionsTests.cs b/src/Hyperion.Tests/ImmutableCollectionsTests.cs similarity index 100% rename from Hyperion.Tests/ImmutableCollectionsTests.cs rename to src/Hyperion.Tests/ImmutableCollectionsTests.cs diff --git a/Hyperion.Tests/InterfaceTests.cs b/src/Hyperion.Tests/InterfaceTests.cs similarity index 100% rename from Hyperion.Tests/InterfaceTests.cs rename to src/Hyperion.Tests/InterfaceTests.cs diff --git a/Hyperion.Tests/PrimitivesTests.cs b/src/Hyperion.Tests/PrimitivesTests.cs similarity index 100% rename from Hyperion.Tests/PrimitivesTests.cs rename to src/Hyperion.Tests/PrimitivesTests.cs diff --git a/Hyperion.Tests/Something.cs b/src/Hyperion.Tests/Something.cs similarity index 100% rename from Hyperion.Tests/Something.cs rename to src/Hyperion.Tests/Something.cs diff --git a/Hyperion.Tests/SurrogateTests.cs b/src/Hyperion.Tests/SurrogateTests.cs similarity index 100% rename from Hyperion.Tests/SurrogateTests.cs rename to src/Hyperion.Tests/SurrogateTests.cs diff --git a/Hyperion.Tests/TestBase.cs b/src/Hyperion.Tests/TestBase.cs similarity index 100% rename from Hyperion.Tests/TestBase.cs rename to src/Hyperion.Tests/TestBase.cs diff --git a/Hyperion.Tests/UnsupportedTypeSerializerTests.cs b/src/Hyperion.Tests/UnsupportedTypeSerializerTests.cs similarity index 100% rename from Hyperion.Tests/UnsupportedTypeSerializerTests.cs rename to src/Hyperion.Tests/UnsupportedTypeSerializerTests.cs diff --git a/Hyperion/.vscode/launch.json b/src/Hyperion/.vscode/launch.json similarity index 100% rename from Hyperion/.vscode/launch.json rename to src/Hyperion/.vscode/launch.json diff --git a/Hyperion/.vscode/tasks.json b/src/Hyperion/.vscode/tasks.json similarity index 100% rename from Hyperion/.vscode/tasks.json rename to src/Hyperion/.vscode/tasks.json diff --git a/Hyperion/Attributes.cs b/src/Hyperion/Attributes.cs similarity index 100% rename from Hyperion/Attributes.cs rename to src/Hyperion/Attributes.cs diff --git a/Hyperion/ByteArrayKey.cs b/src/Hyperion/ByteArrayKey.cs similarity index 100% rename from Hyperion/ByteArrayKey.cs rename to src/Hyperion/ByteArrayKey.cs diff --git a/Hyperion/ByteArrayKeyComparer.cs b/src/Hyperion/ByteArrayKeyComparer.cs similarity index 100% rename from Hyperion/ByteArrayKeyComparer.cs rename to src/Hyperion/ByteArrayKeyComparer.cs diff --git a/Hyperion/Compilation/Compiler.cs b/src/Hyperion/Compilation/Compiler.cs similarity index 100% rename from Hyperion/Compilation/Compiler.cs rename to src/Hyperion/Compilation/Compiler.cs diff --git a/Hyperion/Compilation/ExpressionEx.cs b/src/Hyperion/Compilation/ExpressionEx.cs similarity index 100% rename from Hyperion/Compilation/ExpressionEx.cs rename to src/Hyperion/Compilation/ExpressionEx.cs diff --git a/Hyperion/Compilation/ICompiler.cs b/src/Hyperion/Compilation/ICompiler.cs similarity index 100% rename from Hyperion/Compilation/ICompiler.cs rename to src/Hyperion/Compilation/ICompiler.cs diff --git a/Hyperion/Compilation/IlBuilder.cs b/src/Hyperion/Compilation/IlBuilder.cs similarity index 100% rename from Hyperion/Compilation/IlBuilder.cs rename to src/Hyperion/Compilation/IlBuilder.cs diff --git a/Hyperion/Compilation/IlCompiler.cs b/src/Hyperion/Compilation/IlCompiler.cs similarity index 100% rename from Hyperion/Compilation/IlCompiler.cs rename to src/Hyperion/Compilation/IlCompiler.cs diff --git a/Hyperion/Compilation/IlCompilerContext.cs b/src/Hyperion/Compilation/IlCompilerContext.cs similarity index 100% rename from Hyperion/Compilation/IlCompilerContext.cs rename to src/Hyperion/Compilation/IlCompilerContext.cs diff --git a/Hyperion/Compilation/IlExpression.cs b/src/Hyperion/Compilation/IlExpression.cs similarity index 100% rename from Hyperion/Compilation/IlExpression.cs rename to src/Hyperion/Compilation/IlExpression.cs diff --git a/Hyperion/DefaultCodeGenerator.cs b/src/Hyperion/DefaultCodeGenerator.cs similarity index 100% rename from Hyperion/DefaultCodeGenerator.cs rename to src/Hyperion/DefaultCodeGenerator.cs diff --git a/Hyperion/Delegates.cs b/src/Hyperion/Delegates.cs similarity index 100% rename from Hyperion/Delegates.cs rename to src/Hyperion/Delegates.cs diff --git a/Hyperion/DeserializeSession.cs b/src/Hyperion/DeserializeSession.cs similarity index 100% rename from Hyperion/DeserializeSession.cs rename to src/Hyperion/DeserializeSession.cs diff --git a/Hyperion/Extensions/ReflectionEx.cs b/src/Hyperion/Extensions/ReflectionEx.cs similarity index 100% rename from Hyperion/Extensions/ReflectionEx.cs rename to src/Hyperion/Extensions/ReflectionEx.cs diff --git a/Hyperion/Extensions/StreamEx.cs b/src/Hyperion/Extensions/StreamEx.cs similarity index 100% rename from Hyperion/Extensions/StreamEx.cs rename to src/Hyperion/Extensions/StreamEx.cs diff --git a/Hyperion/Extensions/StringEx.cs b/src/Hyperion/Extensions/StringEx.cs similarity index 100% rename from Hyperion/Extensions/StringEx.cs rename to src/Hyperion/Extensions/StringEx.cs diff --git a/Hyperion/Extensions/TypeEx.cs b/src/Hyperion/Extensions/TypeEx.cs similarity index 100% rename from Hyperion/Extensions/TypeEx.cs rename to src/Hyperion/Extensions/TypeEx.cs diff --git a/Hyperion/Hyperion.csproj b/src/Hyperion/Hyperion.csproj similarity index 100% rename from Hyperion/Hyperion.csproj rename to src/Hyperion/Hyperion.csproj diff --git a/Hyperion/ICodeGenerator.cs b/src/Hyperion/ICodeGenerator.cs similarity index 100% rename from Hyperion/ICodeGenerator.cs rename to src/Hyperion/ICodeGenerator.cs diff --git a/Hyperion/Internal/Annotations.cs b/src/Hyperion/Internal/Annotations.cs similarity index 100% rename from Hyperion/Internal/Annotations.cs rename to src/Hyperion/Internal/Annotations.cs diff --git a/Hyperion/NoAllocBitConverter.cs b/src/Hyperion/NoAllocBitConverter.cs similarity index 100% rename from Hyperion/NoAllocBitConverter.cs rename to src/Hyperion/NoAllocBitConverter.cs diff --git a/Hyperion/Properties/AssemblyInfo.cs b/src/Hyperion/Properties/AssemblyInfo.cs similarity index 100% rename from Hyperion/Properties/AssemblyInfo.cs rename to src/Hyperion/Properties/AssemblyInfo.cs diff --git a/Hyperion/Serializer.cs b/src/Hyperion/Serializer.cs similarity index 100% rename from Hyperion/Serializer.cs rename to src/Hyperion/Serializer.cs diff --git a/Hyperion/SerializerFactories/ArraySerializerFactory.cs b/src/Hyperion/SerializerFactories/ArraySerializerFactory.cs similarity index 100% rename from Hyperion/SerializerFactories/ArraySerializerFactory.cs rename to src/Hyperion/SerializerFactories/ArraySerializerFactory.cs diff --git a/Hyperion/SerializerFactories/ConsistentArraySerializerFactory.cs b/src/Hyperion/SerializerFactories/ConsistentArraySerializerFactory.cs similarity index 100% rename from Hyperion/SerializerFactories/ConsistentArraySerializerFactory.cs rename to src/Hyperion/SerializerFactories/ConsistentArraySerializerFactory.cs diff --git a/Hyperion/SerializerFactories/ConstructorInfoSerializerFactory.cs b/src/Hyperion/SerializerFactories/ConstructorInfoSerializerFactory.cs similarity index 100% rename from Hyperion/SerializerFactories/ConstructorInfoSerializerFactory.cs rename to src/Hyperion/SerializerFactories/ConstructorInfoSerializerFactory.cs diff --git a/Hyperion/SerializerFactories/DefaultDictionarySerializerFactory.cs b/src/Hyperion/SerializerFactories/DefaultDictionarySerializerFactory.cs similarity index 100% rename from Hyperion/SerializerFactories/DefaultDictionarySerializerFactory.cs rename to src/Hyperion/SerializerFactories/DefaultDictionarySerializerFactory.cs diff --git a/Hyperion/SerializerFactories/DelegateSerializerFactory.cs b/src/Hyperion/SerializerFactories/DelegateSerializerFactory.cs similarity index 100% rename from Hyperion/SerializerFactories/DelegateSerializerFactory.cs rename to src/Hyperion/SerializerFactories/DelegateSerializerFactory.cs diff --git a/Hyperion/SerializerFactories/DictionarySerializerFactory.cs b/src/Hyperion/SerializerFactories/DictionarySerializerFactory.cs similarity index 100% rename from Hyperion/SerializerFactories/DictionarySerializerFactory.cs rename to src/Hyperion/SerializerFactories/DictionarySerializerFactory.cs diff --git a/Hyperion/SerializerFactories/EnumerableSerializerFactory.cs b/src/Hyperion/SerializerFactories/EnumerableSerializerFactory.cs similarity index 100% rename from Hyperion/SerializerFactories/EnumerableSerializerFactory.cs rename to src/Hyperion/SerializerFactories/EnumerableSerializerFactory.cs diff --git a/Hyperion/SerializerFactories/ExceptionSerializerFactory.cs b/src/Hyperion/SerializerFactories/ExceptionSerializerFactory.cs similarity index 100% rename from Hyperion/SerializerFactories/ExceptionSerializerFactory.cs rename to src/Hyperion/SerializerFactories/ExceptionSerializerFactory.cs diff --git a/Hyperion/SerializerFactories/ExpandoObjectSerializerFactory.cs b/src/Hyperion/SerializerFactories/ExpandoObjectSerializerFactory.cs similarity index 100% rename from Hyperion/SerializerFactories/ExpandoObjectSerializerFactory.cs rename to src/Hyperion/SerializerFactories/ExpandoObjectSerializerFactory.cs diff --git a/Hyperion/SerializerFactories/FSharpListSerializerFactory.cs b/src/Hyperion/SerializerFactories/FSharpListSerializerFactory.cs similarity index 100% rename from Hyperion/SerializerFactories/FSharpListSerializerFactory.cs rename to src/Hyperion/SerializerFactories/FSharpListSerializerFactory.cs diff --git a/Hyperion/SerializerFactories/FSharpMapSerializerFactory.cs b/src/Hyperion/SerializerFactories/FSharpMapSerializerFactory.cs similarity index 100% rename from Hyperion/SerializerFactories/FSharpMapSerializerFactory.cs rename to src/Hyperion/SerializerFactories/FSharpMapSerializerFactory.cs diff --git a/Hyperion/SerializerFactories/FieldInfoSerializerFactory.cs b/src/Hyperion/SerializerFactories/FieldInfoSerializerFactory.cs similarity index 100% rename from Hyperion/SerializerFactories/FieldInfoSerializerFactory.cs rename to src/Hyperion/SerializerFactories/FieldInfoSerializerFactory.cs diff --git a/Hyperion/SerializerFactories/FromSurrogateSerializerFactory.cs b/src/Hyperion/SerializerFactories/FromSurrogateSerializerFactory.cs similarity index 100% rename from Hyperion/SerializerFactories/FromSurrogateSerializerFactory.cs rename to src/Hyperion/SerializerFactories/FromSurrogateSerializerFactory.cs diff --git a/Hyperion/SerializerFactories/ISerializableSerializerFactory.cs b/src/Hyperion/SerializerFactories/ISerializableSerializerFactory.cs similarity index 100% rename from Hyperion/SerializerFactories/ISerializableSerializerFactory.cs rename to src/Hyperion/SerializerFactories/ISerializableSerializerFactory.cs diff --git a/Hyperion/SerializerFactories/ImmutableCollectionsSerializerFactory.cs b/src/Hyperion/SerializerFactories/ImmutableCollectionsSerializerFactory.cs similarity index 100% rename from Hyperion/SerializerFactories/ImmutableCollectionsSerializerFactory.cs rename to src/Hyperion/SerializerFactories/ImmutableCollectionsSerializerFactory.cs diff --git a/Hyperion/SerializerFactories/MethodInfoSerializerFactory.cs b/src/Hyperion/SerializerFactories/MethodInfoSerializerFactory.cs similarity index 100% rename from Hyperion/SerializerFactories/MethodInfoSerializerFactory.cs rename to src/Hyperion/SerializerFactories/MethodInfoSerializerFactory.cs diff --git a/Hyperion/SerializerFactories/PropertyInfoSerializerFactory.cs b/src/Hyperion/SerializerFactories/PropertyInfoSerializerFactory.cs similarity index 100% rename from Hyperion/SerializerFactories/PropertyInfoSerializerFactory.cs rename to src/Hyperion/SerializerFactories/PropertyInfoSerializerFactory.cs diff --git a/Hyperion/SerializerFactories/ToSurrogateSerializerFactory.cs b/src/Hyperion/SerializerFactories/ToSurrogateSerializerFactory.cs similarity index 100% rename from Hyperion/SerializerFactories/ToSurrogateSerializerFactory.cs rename to src/Hyperion/SerializerFactories/ToSurrogateSerializerFactory.cs diff --git a/Hyperion/SerializerFactories/ValueSerializerFactory.cs b/src/Hyperion/SerializerFactories/ValueSerializerFactory.cs similarity index 100% rename from Hyperion/SerializerFactories/ValueSerializerFactory.cs rename to src/Hyperion/SerializerFactories/ValueSerializerFactory.cs diff --git a/Hyperion/SerializerOptions.cs b/src/Hyperion/SerializerOptions.cs similarity index 100% rename from Hyperion/SerializerOptions.cs rename to src/Hyperion/SerializerOptions.cs diff --git a/Hyperion/SerializerSession.cs b/src/Hyperion/SerializerSession.cs similarity index 100% rename from Hyperion/SerializerSession.cs rename to src/Hyperion/SerializerSession.cs diff --git a/Hyperion/Surrogate.cs b/src/Hyperion/Surrogate.cs similarity index 100% rename from Hyperion/Surrogate.cs rename to src/Hyperion/Surrogate.cs diff --git a/Hyperion/ValueSerializers/BoolSerializer.cs b/src/Hyperion/ValueSerializers/BoolSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/BoolSerializer.cs rename to src/Hyperion/ValueSerializers/BoolSerializer.cs diff --git a/Hyperion/ValueSerializers/ByteArraySerializer.cs b/src/Hyperion/ValueSerializers/ByteArraySerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/ByteArraySerializer.cs rename to src/Hyperion/ValueSerializers/ByteArraySerializer.cs diff --git a/Hyperion/ValueSerializers/ByteSerializer.cs b/src/Hyperion/ValueSerializers/ByteSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/ByteSerializer.cs rename to src/Hyperion/ValueSerializers/ByteSerializer.cs diff --git a/Hyperion/ValueSerializers/CharSerializer.cs b/src/Hyperion/ValueSerializers/CharSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/CharSerializer.cs rename to src/Hyperion/ValueSerializers/CharSerializer.cs diff --git a/Hyperion/ValueSerializers/ConsistentArraySerializer.cs b/src/Hyperion/ValueSerializers/ConsistentArraySerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/ConsistentArraySerializer.cs rename to src/Hyperion/ValueSerializers/ConsistentArraySerializer.cs diff --git a/Hyperion/ValueSerializers/DateTimeOffsetSerializer.cs b/src/Hyperion/ValueSerializers/DateTimeOffsetSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/DateTimeOffsetSerializer.cs rename to src/Hyperion/ValueSerializers/DateTimeOffsetSerializer.cs diff --git a/Hyperion/ValueSerializers/DateTimeSerializer.cs b/src/Hyperion/ValueSerializers/DateTimeSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/DateTimeSerializer.cs rename to src/Hyperion/ValueSerializers/DateTimeSerializer.cs diff --git a/Hyperion/ValueSerializers/DecimalSerializer.cs b/src/Hyperion/ValueSerializers/DecimalSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/DecimalSerializer.cs rename to src/Hyperion/ValueSerializers/DecimalSerializer.cs diff --git a/Hyperion/ValueSerializers/DoubleSerializer.cs b/src/Hyperion/ValueSerializers/DoubleSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/DoubleSerializer.cs rename to src/Hyperion/ValueSerializers/DoubleSerializer.cs diff --git a/Hyperion/ValueSerializers/FloatSerializer.cs b/src/Hyperion/ValueSerializers/FloatSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/FloatSerializer.cs rename to src/Hyperion/ValueSerializers/FloatSerializer.cs diff --git a/Hyperion/ValueSerializers/FromSurrogateSerializer.cs b/src/Hyperion/ValueSerializers/FromSurrogateSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/FromSurrogateSerializer.cs rename to src/Hyperion/ValueSerializers/FromSurrogateSerializer.cs diff --git a/Hyperion/ValueSerializers/GuidSerializer.cs b/src/Hyperion/ValueSerializers/GuidSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/GuidSerializer.cs rename to src/Hyperion/ValueSerializers/GuidSerializer.cs diff --git a/Hyperion/ValueSerializers/Int16Serializer.cs b/src/Hyperion/ValueSerializers/Int16Serializer.cs similarity index 100% rename from Hyperion/ValueSerializers/Int16Serializer.cs rename to src/Hyperion/ValueSerializers/Int16Serializer.cs diff --git a/Hyperion/ValueSerializers/Int32Serializer.cs b/src/Hyperion/ValueSerializers/Int32Serializer.cs similarity index 100% rename from Hyperion/ValueSerializers/Int32Serializer.cs rename to src/Hyperion/ValueSerializers/Int32Serializer.cs diff --git a/Hyperion/ValueSerializers/Int64Serializer.cs b/src/Hyperion/ValueSerializers/Int64Serializer.cs similarity index 100% rename from Hyperion/ValueSerializers/Int64Serializer.cs rename to src/Hyperion/ValueSerializers/Int64Serializer.cs diff --git a/Hyperion/ValueSerializers/KnownTypeObjectSerializer.cs b/src/Hyperion/ValueSerializers/KnownTypeObjectSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/KnownTypeObjectSerializer.cs rename to src/Hyperion/ValueSerializers/KnownTypeObjectSerializer.cs diff --git a/Hyperion/ValueSerializers/NullSerializer.cs b/src/Hyperion/ValueSerializers/NullSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/NullSerializer.cs rename to src/Hyperion/ValueSerializers/NullSerializer.cs diff --git a/Hyperion/ValueSerializers/ObjectReferenceSerializer.cs b/src/Hyperion/ValueSerializers/ObjectReferenceSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/ObjectReferenceSerializer.cs rename to src/Hyperion/ValueSerializers/ObjectReferenceSerializer.cs diff --git a/Hyperion/ValueSerializers/ObjectSerializer.cs b/src/Hyperion/ValueSerializers/ObjectSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/ObjectSerializer.cs rename to src/Hyperion/ValueSerializers/ObjectSerializer.cs diff --git a/Hyperion/ValueSerializers/SByteSerializer.cs b/src/Hyperion/ValueSerializers/SByteSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/SByteSerializer.cs rename to src/Hyperion/ValueSerializers/SByteSerializer.cs diff --git a/Hyperion/ValueSerializers/SessionAwareByteArrayRequiringValueSerializer.cs b/src/Hyperion/ValueSerializers/SessionAwareByteArrayRequiringValueSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/SessionAwareByteArrayRequiringValueSerializer.cs rename to src/Hyperion/ValueSerializers/SessionAwareByteArrayRequiringValueSerializer.cs diff --git a/Hyperion/ValueSerializers/SessionAwareByteArrayRequiringValueSerializer.cs.orig b/src/Hyperion/ValueSerializers/SessionAwareByteArrayRequiringValueSerializer.cs.orig similarity index 100% rename from Hyperion/ValueSerializers/SessionAwareByteArrayRequiringValueSerializer.cs.orig rename to src/Hyperion/ValueSerializers/SessionAwareByteArrayRequiringValueSerializer.cs.orig diff --git a/Hyperion/ValueSerializers/SessionIgnorantValueSerializer.cs b/src/Hyperion/ValueSerializers/SessionIgnorantValueSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/SessionIgnorantValueSerializer.cs rename to src/Hyperion/ValueSerializers/SessionIgnorantValueSerializer.cs diff --git a/Hyperion/ValueSerializers/StringSerializer.cs b/src/Hyperion/ValueSerializers/StringSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/StringSerializer.cs rename to src/Hyperion/ValueSerializers/StringSerializer.cs diff --git a/Hyperion/ValueSerializers/SystemObjectSerializer.cs b/src/Hyperion/ValueSerializers/SystemObjectSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/SystemObjectSerializer.cs rename to src/Hyperion/ValueSerializers/SystemObjectSerializer.cs diff --git a/Hyperion/ValueSerializers/ToSurrogateSerializer.cs b/src/Hyperion/ValueSerializers/ToSurrogateSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/ToSurrogateSerializer.cs rename to src/Hyperion/ValueSerializers/ToSurrogateSerializer.cs diff --git a/Hyperion/ValueSerializers/TypeSerializer.cs b/src/Hyperion/ValueSerializers/TypeSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/TypeSerializer.cs rename to src/Hyperion/ValueSerializers/TypeSerializer.cs diff --git a/Hyperion/ValueSerializers/UInt16Serializer.cs b/src/Hyperion/ValueSerializers/UInt16Serializer.cs similarity index 100% rename from Hyperion/ValueSerializers/UInt16Serializer.cs rename to src/Hyperion/ValueSerializers/UInt16Serializer.cs diff --git a/Hyperion/ValueSerializers/UInt32Serializer.cs b/src/Hyperion/ValueSerializers/UInt32Serializer.cs similarity index 100% rename from Hyperion/ValueSerializers/UInt32Serializer.cs rename to src/Hyperion/ValueSerializers/UInt32Serializer.cs diff --git a/Hyperion/ValueSerializers/UInt64Serializer.cs b/src/Hyperion/ValueSerializers/UInt64Serializer.cs similarity index 100% rename from Hyperion/ValueSerializers/UInt64Serializer.cs rename to src/Hyperion/ValueSerializers/UInt64Serializer.cs diff --git a/Hyperion/ValueSerializers/UnsupportedTypeSerializer.cs b/src/Hyperion/ValueSerializers/UnsupportedTypeSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/UnsupportedTypeSerializer.cs rename to src/Hyperion/ValueSerializers/UnsupportedTypeSerializer.cs diff --git a/Hyperion/ValueSerializers/ValueSerializer.cs b/src/Hyperion/ValueSerializers/ValueSerializer.cs similarity index 100% rename from Hyperion/ValueSerializers/ValueSerializer.cs rename to src/Hyperion/ValueSerializers/ValueSerializer.cs diff --git a/common.props b/src/common.props similarity index 76% rename from common.props rename to src/common.props index dbd501d2..67f066e7 100644 --- a/common.props +++ b/src/common.props @@ -3,15 +3,14 @@ Copyright © 2016-2017 Akka.NET Team Akka.NET Team 0.9.6 - Placeholder + Resolving issues with conflicting binary being downloaded via NuGet with version bump. http://getakka.net/images/akkalogo.png - https://github.com/akkadotnet/Hyperion https://github.com/akkadotnet/Hyperion/blob/master/LICENSE $(NoWarn);CS1591 - 2.3.0-beta4-* + 2.3.0 15.3.0 \ No newline at end of file