Permalink
Browse files

restructure

  • Loading branch information...
1 parent 1d00fa3 commit 49bcb9365e5239324717f95d31a2e0f7a4ed481d @rogeralsing committed Jul 30, 2016
Showing with 1,293 additions and 268 deletions.
  1. +45 −38 Wire.PerfTest/Program.cs
  2. +9 −8 Wire.PerformanceTests/SpeedAndSizeTests.cs
  3. +6 −5 Wire.Tests/IlCompilerTests.cs
  4. +1,066 −0 Wire/Annotations.cs
  5. +0 −28 Wire/BitConverterEx.cs
  6. +66 −9 Wire/ByteArray.cs
  7. +0 −24 Wire/ByteArrayEqualityComparer.cs
  8. +1 −0 Wire/Compilation/ExpressionEx.cs
  9. +1 −0 Wire/Compilation/IlBuilder.cs
  10. +5 −12 Wire/Compilation/IlCompiler.cs
  11. +1 −0 Wire/Compilation/IlExpression.cs
  12. +9 −7 Wire/DefaultCodeGenerator.cs
  13. +3 −2 Wire/DeserializeSession.cs
  14. +2 −1 Wire/{ → Extensions}/ReflectionEx.cs
  15. +2 −2 Wire/{StreamExtensions.cs → Extensions/StreamEx.cs}
  16. +1 −1 Wire/{ → Extensions}/StringEx.cs
  17. +27 −4 Wire/{ → Extensions}/TypeEx.cs
  18. +1 −1 Wire/{ValueSerializers → }/NoAllocBitConverter.cs
  19. +10 −8 Wire/Serializer.cs
  20. +1 −0 Wire/SerializerFactories/ArraySerializerFactory.cs
  21. +1 −0 Wire/SerializerFactories/DefaultDictionarySerializerFactory.cs
  22. +1 −0 Wire/SerializerFactories/DelegateSerializerFactory.cs
  23. +1 −0 Wire/SerializerFactories/DictionarySerializerFactory.cs
  24. +1 −0 Wire/SerializerFactories/EnumerableSerializerFactory.cs
  25. +1 −0 Wire/SerializerFactories/ExceptionSerializerFactory.cs
  26. +1 −0 Wire/SerializerFactories/ISerializableSerializerFactory.cs
  27. +1 −0 Wire/SerializerFactories/ImmutableCollectionsSerializerFactory.cs
  28. +1 −0 Wire/SerializerFactories/MethodInfoSerializerFactory.cs
  29. +0 −13 Wire/TrackingExtensions.cs
  30. +0 −85 Wire/Utils.cs
  31. +1 −0 Wire/ValueSerializers/ByteArraySerializer.cs
  32. +1 −0 Wire/ValueSerializers/ConsistentArraySerializer.cs
  33. +1 −0 Wire/ValueSerializers/DecimalSerializer.cs
  34. +1 −0 Wire/ValueSerializers/GuidSerializer.cs
  35. +1 −0 Wire/ValueSerializers/ObjectReferenceSerializer.cs
  36. +1 −0 Wire/ValueSerializers/ObjectSerializer.cs
  37. +2 −2 Wire/ValueSerializers/SessionAwareValueSerializer.cs
  38. +2 −2 Wire/ValueSerializers/SessionIgnorantValueSerializer.cs
  39. +1 −0 Wire/ValueSerializers/StringSerializer.cs
  40. +2 −1 Wire/ValueSerializers/ToSurrogateSerializer.cs
  41. +2 −1 Wire/ValueSerializers/TypeSerializer.cs
  42. +7 −5 Wire/ValueSerializers/ValueSerializer.cs
  43. +6 −9 Wire/Wire.csproj
  44. +1 −0 failed.playlist
@@ -7,6 +7,7 @@
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
+using System.Threading;
using Bond;
using Bond.IO.Unsafe;
using Bond.Protocols;
@@ -29,36 +30,45 @@ internal class Program
private static void Main(string[] args)
{
- Console.WriteLine("Run this in Release mode with no debugger attached for correct numbers!!");
- Console.WriteLine();
- Console.WriteLine("Running cold");
-
- SerializePocoPreRegister();
- SerializePocoPreRegisterManualSerializer();
- SerializePocoVersionInteolerant();
- //SerializePoco();
- ////SerializePocoVersionInteolerantPreserveObjects();
-
- SerializePocoProtoBufNet();
- SerializePocoBond();
- ////////SerializePocoJsonNet();
- ////////SerializePocoBinaryFormatter();
- ////Console.WriteLine();
- ////Console.WriteLine("Running hot");
- SerializePocoPreRegister();
- SerializePocoPreRegisterManualSerializer();
- SerializePocoVersionInteolerant();
- ////SerializePoco();
- //////SerializePocoVersionInteolerantPreserveObjects();
-
- SerializePocoProtoBufNet();
- SerializePocoBond();
- ////////SerializePocoJsonNet();
- ////////SerializePocoBinaryFormatter();
- //Console.ReadLine();
+ Run();
}
- private static void SerializePocoJsonNet()
+ private static void Run()
+ {
+ Console.WriteLine("Run this in Release mode with no debugger attached for correct numbers!!");
+ Console.WriteLine();
+ Console.WriteLine("Running cold");
+
+ for (int i = 0; i < 20; i++)
+ {
+ SerializePocoPreRegister();
+ }
+
+ //SerializePocoPreRegisterManualSerializer();
+ //SerializePocoVersionInteolerant();
+ ////SerializePoco();
+ //////SerializePocoVersionInteolerantPreserveObjects();
+
+ //SerializePocoProtoBufNet();
+ //SerializePocoBond();
+ //SerializePocoJsonNet();
+ //SerializePocoBinaryFormatter();
+ //Console.WriteLine();
+ //Console.WriteLine("Running hot");
+ //SerializePocoPreRegister();
+ //SerializePocoPreRegisterManualSerializer();
+ //SerializePocoVersionInteolerant();
+ //SerializePoco();
+ ////SerializePocoVersionInteolerantPreserveObjects();
+
+ //SerializePocoProtoBufNet();
+ //SerializePocoBond();
+ //SerializePocoJsonNet();
+ //SerializePocoBinaryFormatter();
+ //Console.ReadLine();
+ }
+
+ private static void SerializePocoJsonNet()
{
var settings = new JsonSerializerSettings
{
@@ -201,11 +211,13 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type
s.Initialize(
(stream, session) =>
{
- var poco = new Poco();// (Poco)typeof(Poco).GetEmptyObject();
- poco.StringProp = (string) stringS.ReadValue(stream, session);
- poco.IntProp = (int) intS.ReadValue(stream, session);
- poco.GuidProp = (Guid) guidS.ReadValue(stream, session);
- poco.DateProp = (DateTime) dateS.ReadValue(stream, session);
+ var poco = new Poco
+ {
+ StringProp = (string) stringS.ReadValue(stream, session),
+ IntProp = (int) intS.ReadValue(stream, session),
+ GuidProp = (Guid) guidS.ReadValue(stream, session),
+ DateProp = (DateTime) dateS.ReadValue(stream, session)
+ };
return poco;
},
(stream, obj, session) =>
@@ -302,22 +314,17 @@ public class Loco
[ProtoContract]
[Serializable]
- [Schema]
public class Poco
{
- [Id(0), Required]
[ProtoMember(1)]
public string StringProp { get; set; }
- [Id(1), Required]
[ProtoMember(2)]
public int IntProp { get; set; }
- [Id(2), Required]
[ProtoMember(3)]
public Guid GuidProp { get; set; }
- [Id(3), Required]
[ProtoMember(4)]
public DateTime DateProp { get; set; }
}
@@ -77,7 +77,6 @@ public void TestGuidArray()
Test(arr);
}
- //fails as we are slower than FsPickler when serializing the integer array, we have slightly smaller payload though
[TestMethod]
public void TestIntArray()
{
@@ -164,7 +163,6 @@ public void TestGuid()
Test(Guid.NewGuid());
}
- //fails as we are slower than FsPickler when serializing the integer array, we have slightly smaller payload though
[TestMethod]
public void TestBoolArray()
{
@@ -184,7 +182,7 @@ public void TestTuple()
Test(Tuple.Create(123,456));
}
- [TestMethod,Ignore,Description("Works but is slower than FS Pickler")]
+ [TestMethod]
public void TestTupleArray()
{
var arr = new Tuple<int,int>[100];
@@ -250,18 +248,21 @@ public void TestIntDictionary()
Test(dict);
}
- //TODO: F# lists are recursive cons lists, wire currently write those objects
- //we could optimize to convert to array and write it all in one go
[TestMethod]
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 });
+ 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 void Test(object value)
+ private static void Test(object value)
{
- Serializer wireSerializer = new Serializer(new SerializerOptions(false,true,null, null));
+ var wireSerializer = new Serializer(new SerializerOptions(false,true,null, null));
var pickler = FsPickler.CreateBinarySerializer();
double wireTs;
@@ -5,6 +5,7 @@
using Microsoft.FSharp.Core;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Wire.Compilation;
+using Wire.Extensions;
namespace Wire.Tests
{
@@ -51,7 +52,7 @@ public class IlCompilerTests
[TestMethod]
public void CanCallStaticMethodUsingParameter()
{
- var c = new IlCompiler<Action<Dummy>>(typeof(Dummy));
+ var c = new IlCompiler<Action<Dummy>>();
var param = c.Parameter<Dummy>("dummy");
c.EmitStaticCall(SetStatic, param);
var a = c.Compile();
@@ -63,7 +64,7 @@ public void CanCallStaticMethodUsingParameter()
[TestMethod]
public void CanCallInstanceMethodOnParameter()
{
- var c = new IlCompiler<Action<Dummy>>(typeof(Dummy));
+ var c = new IlCompiler<Action<Dummy>>();
var param = c.Parameter<Dummy>("dummy");
c.EmitCall(SetBool, param);
var a = c.Compile();
@@ -76,7 +77,7 @@ public void CanCallInstanceMethodOnParameter()
[TestMethod]
public void CanModifyParameter()
{
- var c = new IlCompiler<Action<Dummy>>(typeof(Dummy));
+ var c = new IlCompiler<Action<Dummy>>();
var param = c.Parameter<Dummy>("dummy");
var write = c.WriteField(BoolField, param, c.Constant(true));
c.Emit(write);
@@ -207,7 +208,7 @@ public void ReadSimulationOptionString()
serializer.Serialize(value, stream);
stream.Position = 3; //skip forward to payload
- var fields = type.GetFieldInfosForType();
+ var fields = ReflectionEx.GetFieldInfosForType(type);
var readAllFields = GetDelegate(type, fields, serializer);
@@ -265,7 +266,7 @@ public void ReadSimulation()
private static ObjectReader GetDelegate(Type type, FieldInfo[] fields, Serializer serializer)
{
- var c = new IlCompiler<ObjectReader>(type);
+ var c = new IlCompiler<ObjectReader>();
var stream = c.Parameter<Stream>("stream");
var session = c.Parameter<DeserializerSession>("session");
var newExpression = c.NewObject(type);
Oops, something went wrong.

0 comments on commit 49bcb93

Please sign in to comment.