├── .editorconfig ├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md └── Source ├── Serbench.Specimens ├── Properties │ └── AssemblyInfo.cs ├── Serbench.Specimens.csproj ├── Serializers │ ├── ApJsonSerializer.cs │ ├── BondSerializer.cs │ ├── FastJsonSerializer.cs │ ├── HaveBoxJSON.cs │ ├── JilSerializer.cs │ ├── JsonFxSerializer.cs │ ├── JsonNet.cs │ ├── MessageSharkSerializer.cs │ ├── MsgPackSerializer.cs │ ├── NetJSONSerializer.cs │ ├── NetSerializerSer.cs │ ├── ProtoBufSerializer.cs │ ├── ServiceStackJsonSerializer.cs │ ├── ServiceStackTypeSerializer.cs │ ├── SharpSerializer.cs │ └── WireSerializer.cs ├── Tests │ ├── EDIOrder.cs │ ├── EDI_X12_835.cs │ ├── MsgBatching.cs │ ├── ObjectGraph.cs │ ├── SimplePerson.cs │ ├── Telemetry.cs │ └── TypicalPerson.cs ├── ThirdPartyLibs │ └── Apolyton.FastJson.dll ├── app.config └── packages.config ├── Serbench ├── BaseTypes.cs ├── Data │ ├── AbortedData.cs │ ├── DefaultDataStore.cs │ ├── ITestDataStore.cs │ ├── SerializerInfoData.cs │ └── TestRunData.cs ├── Exceptions.cs ├── Properties │ └── AssemblyInfo.cs ├── Serbench.csproj ├── Serializer.cs ├── SerializerInfo.cs ├── StockSerializers │ ├── MSBinaryFormatter.cs │ ├── MSDataContractJsonSerializer.cs │ ├── MSDataContractSerializer.cs │ ├── MSJavaScriptSerializer.cs │ ├── MSXmlSerializer.cs │ ├── NFXJSON.cs │ └── NFXSlim.cs ├── StockTests │ ├── ArrayTestBase.cs │ ├── ArrayTests.cs │ ├── SimpleDictionaryStringObject.cs │ └── TypicalPerson.cs ├── Test.cs ├── TestingSystem.cs ├── WebViewer │ ├── DefaultWebPackager.cs │ ├── scripts │ │ ├── jquery-1.11.0.min.js │ │ ├── serbench.js │ │ ├── wv.chart.svg.js │ │ ├── wv.gui.js │ │ └── wv.js │ ├── styles │ │ ├── default.css │ │ ├── overview-charts.css │ │ ├── overview-table.css │ │ ├── serializers-info.css │ │ └── table.css │ └── views │ │ ├── Master.htm │ │ ├── OverviewCharts.htm │ │ ├── OverviewTable.htm │ │ └── SerializersInfo.htm └── packages.config ├── SerbenchSuite.sln └── sb ├── App.config ├── Aum.ico ├── Program.cs ├── Properties └── AssemblyInfo.cs ├── batching.laconf ├── edi.laconf ├── highPrformanceTests.laconf ├── knowntypes.Conference.laconf ├── knowntypes.EDI.laconf ├── knowntypes.SpecimensTypicalPerson.laconf ├── knowntypes.StockTypicalPerson.laconf ├── knowntypes.Telemetry.laconf ├── objgraph.laconf ├── packages.config ├── sb.csproj ├── sb.laconf ├── stock.typicalperson.laconf ├── telemetry.laconf └── typicalperson.laconf /.editorconfig: -------------------------------------------------------------------------------- 1 | root=true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = crlf 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.suo 2 | *.user 3 | *.userosscache 4 | *.sln.docstates 5 | *.db 6 | *.auto.cs 7 | 8 | Output/ 9 | .vs/ 10 | obj/ 11 | packages/ 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Serializer Benchmark Testing Suite 2 | Copyright 2014-2015 Leo_Gan, D Khmaladze, IT Adapter LLC 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SERBENCH 2 | **Serializer Benchmarking Suite** 3 | 4 | License: Apache 2.0 5 | 6 | Test Run Results: 7 | http://aumcode.github.io/serbench/ 8 | 9 | Before you begin building: make sure Nuget packages are enabled in solution/VS as this tool uses many references to 3rd party 10 | serializer packages! 11 | 12 | The purpose of this tool is to test the performance/capabilities of various 13 | serializers available for the CLR/.NET platform. 14 | 15 | Serbench is based on NFX Application Model, therefore it supports many configurable/pluggable features right out of the box: 16 | * **Logging** with various destinations (console, file, db etc.) 17 | * Test data output into **DataStore** (i.e. store data is RDBMS, CSV, JSON, etc.) 18 | * **Visualize** test data via an HTML/Web application (generated by the tool) 19 | 20 | Both tests and serializers are descendants of corresponding base classes which can 21 | be **injected via a named config** into the tool. This approach allows for **high degree of flexibility** 22 | as **everything is configurable**. 23 | 24 | Every **test determines** what **payload kind/type, pattern and size** is used against every serializer, so 25 | the tool permutes **all test instances and serializer instances** to test different combinations. 26 | 27 | The dynamic/injectable nature of Serbench allows for coverage of many non-trivial use cases like **parallel serialization**, **stateful client/server channels**. These kind of tests are usually overlooked/not considered by testers. 28 | 29 | Not all serializers support all features, i.e. JSON may not support cyclical object graphs. This 30 | is normal and actually is expected to be discovered by this tool. 31 | 32 | The tool relies on the NFX library (via Nuget), hence it does not have much code in it: 33 | https://github.com/aumcode/nfx 34 | 35 | Serbench **DOES NOT give ANY PREFERENCE to ANY PARTICULAR SERIALIZER**. Any serializer may be abstracted and tested against the tests that are already established and executed against others. 36 | 37 | Serbench uses **Stream as an output target**. This is because ultimately **ALL serializers must produce a stream of bytes** because devices (sockets, disks) are block/byte based, not string based. Keep in mind that while your favorite serializer may return a JSON string, it can not be sent (String object) over the wire as-is, an encoded string can, hence we are concerned with the "physicality" of the sent data. We assume that the **serializers of interest would be needed for saving data to storage / network communication**. Any mature **serializer must provide a way to output information (even if it is in a textual format, like JSON or XML) into a stream of bytes**, without making extra buffer copies. 38 | -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Serilaizer Benchmark Suite 3rd Party Testing Specimens Assembly")] 9 | [assembly: AssemblyDescription("3rd party libs + Serbench Wrappes for calling those libs")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("IT Adapter LLC")] 12 | [assembly: AssemblyProduct("Serbench")] 13 | [assembly: AssemblyCopyright("Copyright © IT Adapter LLC 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | 18 | // Setting ComVisible to false makes the types in this assembly not visible 19 | // to COM components. If you need to access a type in this assembly from 20 | // COM, set the ComVisible attribute to true on that type. 21 | [assembly: ComVisible(false)] 22 | 23 | // The following GUID is for the ID of the typelib if this project is exposed to COM 24 | [assembly: Guid("a515c551-af3e-4e36-8057-0e89dd62f145")] 25 | 26 | // Version information for an assembly consists of the following four values: 27 | // 28 | // Major Version 29 | // Minor Version 30 | // Build Number 31 | // Revision 32 | // 33 | // You can specify all the values or you can default the Build and Revision Numbers 34 | // by using the '*' as shown below: 35 | // [assembly: AssemblyVersion("1.0.*")] 36 | [assembly: AssemblyVersion("0.0.0.0")] 37 | [assembly: AssemblyFileVersion("0.0.0.0")] 38 | -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Serializers/ApJsonSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using NFX; 5 | using NFX.Environment; 6 | 7 | using Apolyton.FastJson; 8 | 9 | namespace Serbench.Specimens.Serializers 10 | { 11 | /// 12 | /// Represents Apolyton.FastJson.Json: 13 | /// See here http://www.codeproject.com/Articles/491742/APJSON 14 | /// Manually download a dll from mentioned site and add a reference to it. 15 | /// 16 | [SerializerInfo( 17 | Family = SerializerFamily.Textual, 18 | MetadataRequirement = MetadataRequirement.None, 19 | VendorName = "Aron Kovacs", 20 | VendorLicense = "The Code Project Open License (CPOL)", 21 | VendorURL = "http://www.codeproject.com/Articles/491742/APJSON", 22 | VendorPackageAddress = "Apolyton.FastJson.dll", 23 | FormatName = "JSON", 24 | LinesOfCodeK = 0, 25 | DataTypes = 0, 26 | Assemblies = 1, 27 | ExternalReferences = 0, 28 | PackageSizeKb = 70 29 | )] 30 | public class ApJsonSerializer : Serializer 31 | { 32 | //private Type[] m_KnownTypes; 33 | private Type m_PrimaryType; 34 | 35 | public ApJsonSerializer(TestingSystem context, IConfigSectionNode conf) 36 | : base(context, conf) 37 | { 38 | //m_KnownTypes = ReadKnownTypes(conf); 39 | } 40 | 41 | public override void BeforeRuns(Test test) 42 | { 43 | try 44 | { 45 | m_PrimaryType = test.GetPayloadRootType(); 46 | } 47 | catch (Exception error) 48 | { 49 | test.Abort(this, "Error making ApJsonSerializer instance in serializer BeforeRun() {0}. \n Did you decorate the primary known type correctly?".Args(error.ToMessageWithType())); 50 | } 51 | } 52 | 53 | 54 | public override void Serialize(object root, Stream stream) 55 | { 56 | var buf = Json.Current.ToJsonBytes(root); 57 | stream.Write(buf, 0, buf.Length); 58 | } 59 | 60 | public override object Deserialize(Stream stream) 61 | { 62 | using (var sr = new StreamReader(stream)) 63 | { 64 | return Json.Current.ReadObject(sr.ReadToEnd(), m_PrimaryType); 65 | } 66 | } 67 | 68 | public override void ParallelSerialize(object root, Stream stream) 69 | { 70 | var buf = Json.Current.ToJsonBytes(root); 71 | stream.Write(buf, 0, buf.Length); 72 | } 73 | 74 | public override object ParallelDeserialize(Stream stream) 75 | { 76 | using (var sr = new StreamReader(stream)) 77 | { 78 | return Json.Current.ReadObject(sr.ReadToEnd(), m_PrimaryType); 79 | } 80 | } 81 | public override bool AssertPayloadEquality(Test test, object original, object deserialized, bool abort = true) 82 | { 83 | string serError = null; 84 | if (test.Name.Contains("Telemetry")) 85 | { 86 | if (!Serbench.Specimens.Tests.TelemetryData.AssertPayloadEquality(original, deserialized, out serError)) 87 | { 88 | if (abort) test.Abort(this, serError); 89 | return false; 90 | } 91 | } 92 | else if (test.Name.Contains("EDI_X12_835")) 93 | { 94 | if (!Serbench.Specimens.Tests.EDI_X12_835Data.AssertPayloadEquality(original, deserialized, out serError)) 95 | { 96 | if (abort) test.Abort(this, serError); 97 | return false; 98 | } 99 | } 100 | return base.AssertPayloadEquality(test, original, deserialized, abort); 101 | } 102 | } 103 | } -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Serializers/BondSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using Bond; 4 | using Bond.IO.Unsafe; 5 | using Bond.Protocols; 6 | using NFX.Environment; 7 | using Serbench.Specimens.Tests; 8 | 9 | namespace Serbench.Specimens.Serializers 10 | { 11 | [SerializerInfo( 12 | Family = SerializerFamily.Binary, 13 | MetadataRequirement = MetadataRequirement.Attributes, 14 | VendorName = "Microsoft", 15 | VendorLicense = "The MIT License (MIT)", 16 | VendorURL = "https://github.com/Microsoft/bond/", 17 | VendorPackageAddress = "Install-Package Bond.CSharp", 18 | FormatName = "JSON", 19 | LinesOfCodeK = 0, 20 | DataTypes = 0, 21 | Assemblies = 4, 22 | ExternalReferences = 1, 23 | PackageSizeKb = 350 24 | )] 25 | public class BondSerializer : Serializer 26 | { 27 | //private Deserializer> _deserializer; 28 | //private Serializer> _serializer; 29 | private Type m_RootType; 30 | 31 | public BondSerializer(TestingSystem context, IConfigSectionNode conf) 32 | : base(context, conf) 33 | { 34 | } 35 | 36 | public override void BeforeRuns(Test test) 37 | { 38 | m_RootType = test.GetPayloadRootType(); 39 | //_serializer = new Serializer>(m_RootType); 40 | //_deserializer = new Deserializer>(m_RootType); 41 | } 42 | 43 | public override void Serialize(object root, Stream stream) 44 | { 45 | var output = new OutputStream(stream); 46 | var writer = new CompactBinaryWriter(output); 47 | Bond.Serialize.To(writer, root); 48 | output.Flush(); 49 | //stream.Position = 0; 50 | //_serializer.Serialize(root, writer); 51 | } 52 | 53 | public override object Deserialize(Stream stream) 54 | { 55 | var input = new InputStream(stream); 56 | var reader = new CompactBinaryReader(input); 57 | return Bond.Deserialize.From(reader); 58 | //return _deserializer.Deserialize(reader); 59 | } 60 | 61 | public override void ParallelSerialize(object root, Stream stream) 62 | { 63 | var output = new OutputStream(stream); 64 | var writer = new CompactBinaryWriter(output); 65 | Bond.Serialize.To(writer, root); 66 | output.Flush(); 67 | //stream.Position = 0; 68 | //_serializer.Serialize(root, writer); 69 | } 70 | 71 | public override object ParallelDeserialize(Stream stream) 72 | { 73 | var input = new InputStream(stream); 74 | var reader = new CompactBinaryReader(input); 75 | return Bond.Deserialize.From(reader); 76 | //return _deserializer.Deserialize(reader); 77 | } 78 | 79 | public override bool AssertPayloadEquality(Test test, object original, object deserialized, bool abort = true) 80 | { 81 | string serError = null; 82 | if (test.Name.Contains("Telemetry")) 83 | { 84 | if (!TelemetryData.AssertPayloadEquality(original, deserialized, out serError)) 85 | { 86 | if (abort) test.Abort(this, serError); 87 | return false; 88 | } 89 | } 90 | else if (test.Name.Contains("EDI_X12_835")) 91 | { 92 | if (!EDI_X12_835Data.AssertPayloadEquality(original, deserialized, out serError)) 93 | { 94 | if (abort) test.Abort(this, serError); 95 | return false; 96 | } 97 | } 98 | return base.AssertPayloadEquality(test, original, deserialized, abort); 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Serializers/FastJsonSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using NFX; 5 | using NFX.Environment; 6 | using fastJSON; 7 | 8 | namespace Serbench.Specimens.Serializers 9 | { 10 | /// 11 | /// Represents fastJSON: 12 | /// See here https://github.com/mgholam/fastJSON 13 | /// >PM Install-Package fastJSON 14 | /// 15 | [SerializerInfo( 16 | Family = SerializerFamily.Textual, 17 | MetadataRequirement = MetadataRequirement.None, 18 | VendorName = "Mehdi Gholam", 19 | VendorLicense = "The Code Project Open License (CPOL)", 20 | VendorURL = "https://github.com/mgholam/fastJSON", 21 | VendorPackageAddress = "Install-Package fastJSON", 22 | FormatName = "JSON", 23 | LinesOfCodeK = 0, 24 | DataTypes = 0, 25 | Assemblies = 1, 26 | ExternalReferences = 0, 27 | PackageSizeKb = 40 28 | )] 29 | public class FastJsonSerializer : Serializer 30 | { 31 | // private readonly FastJsonSerializer m_Serializer; 32 | 33 | private Type m_PrimaryType; 34 | 35 | public FastJsonSerializer(TestingSystem context, IConfigSectionNode conf) 36 | : base(context, conf) 37 | { 38 | } 39 | 40 | public override void BeforeRuns(Test test) 41 | { 42 | m_PrimaryType = test.GetPayloadRootType(); 43 | } 44 | 45 | public override void Serialize(object root, Stream stream) 46 | { 47 | using (var sw = new StreamWriter(stream)) 48 | { 49 | sw.Write(JSON.ToJSON(root)); 50 | } 51 | } 52 | 53 | public override object Deserialize(Stream stream) 54 | { 55 | using (var sr = new StreamReader(stream)) 56 | { 57 | return fastJSON.JSON.ToObject(sr.ReadToEnd(), m_PrimaryType); 58 | } 59 | } 60 | 61 | public override void ParallelSerialize(object root, Stream stream) 62 | { 63 | using (var sw = new StreamWriter(stream)) 64 | { 65 | sw.Write(JSON.ToJSON(root)); 66 | } 67 | } 68 | 69 | public override object ParallelDeserialize(Stream stream) 70 | { 71 | using (var sr = new StreamReader(stream)) 72 | { 73 | return fastJSON.JSON.ToObject(sr.ReadToEnd(), m_PrimaryType); 74 | } 75 | } 76 | public override bool AssertPayloadEquality(Test test, object original, object deserialized, bool abort = true) 77 | { 78 | string serError = null; 79 | if (test.Name.Contains("Telemetry")) 80 | { 81 | if (!Serbench.Specimens.Tests.TelemetryData.AssertPayloadEquality(original, deserialized, out serError)) 82 | { 83 | if (abort) test.Abort(this, serError); 84 | return false; 85 | } 86 | } 87 | else if (test.Name.Contains("EDI_X12_835")) 88 | { 89 | if (!Serbench.Specimens.Tests.EDI_X12_835Data.AssertPayloadEquality(original, deserialized, out serError)) 90 | { 91 | if (abort) test.Abort(this, serError); 92 | return false; 93 | } 94 | } 95 | return base.AssertPayloadEquality(test, original, deserialized, abort); 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Serializers/HaveBoxJSON.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using NFX; 5 | using NFX.Environment; 6 | 7 | using HaveBoxJSON; 8 | 9 | namespace Serbench.Specimens.Serializers 10 | { 11 | /// 12 | /// Represents HaveBoxJSON: 13 | /// See here https://www.nuget.org/packages/HaveBoxJSON/ 14 | /// >PM Install-Package HaveBoxJSON 15 | /// 16 | [SerializerInfo( 17 | Family = SerializerFamily.Textual, 18 | MetadataRequirement = MetadataRequirement.None, 19 | VendorName = "Mehdi Gholam", 20 | VendorLicense = "The Code Project Open License (CPOL)", 21 | VendorURL = "https://www.nuget.org/packages/HaveBoxJSON/", 22 | VendorPackageAddress = "Install-Package HaveBoxJSON", 23 | FormatName = "JSON", 24 | LinesOfCodeK = 0, 25 | DataTypes = 0, 26 | Assemblies = 1, 27 | ExternalReferences = 0, 28 | PackageSizeKb = 40 29 | )] 30 | public class HaveBoxJSON : Serializer 31 | { 32 | private readonly JsonConverter m_Serializer = new JsonConverter(); 33 | private Type m_primaryType; 34 | 35 | public HaveBoxJSON(TestingSystem context, IConfigSectionNode conf) 36 | : base(context, conf) 37 | { 38 | // m_KnownTypes = ReadKnownTypes(conf); 39 | } 40 | 41 | public override void BeforeRuns(Test test) 42 | { 43 | m_primaryType = test.GetPayloadRootType(); 44 | } 45 | 46 | public override void Serialize(object root, Stream stream) 47 | { 48 | using (var sw = new StreamWriter(stream)) 49 | { 50 | sw.Write(m_Serializer.Serialize(root)); 51 | } 52 | } 53 | 54 | public override object Deserialize(Stream stream) 55 | { 56 | using (var sr = new StreamReader(stream)) 57 | { 58 | return m_Serializer.Deserialize(m_primaryType, sr.ReadToEnd()); 59 | } 60 | } 61 | 62 | public override void ParallelSerialize(object root, Stream stream) 63 | { 64 | using (var sw = new StreamWriter(stream)) 65 | { 66 | sw.Write(m_Serializer.Serialize(root)); 67 | } 68 | } 69 | 70 | public override object ParallelDeserialize(Stream stream) 71 | { 72 | using (var sr = new StreamReader(stream)) 73 | { 74 | return m_Serializer.Deserialize(m_primaryType, sr.ReadToEnd()); 75 | } 76 | } 77 | public override bool AssertPayloadEquality(Test test, object original, object deserialized, bool abort = true) 78 | { 79 | string serError = null; 80 | if (test.Name.Contains("Telemetry")) 81 | { 82 | if (!Serbench.Specimens.Tests.TelemetryData.AssertPayloadEquality(original, deserialized, out serError)) 83 | { 84 | if (abort) test.Abort(this, serError); 85 | return false; 86 | } 87 | } 88 | else if (test.Name.Contains("EDI_X12_835")) 89 | { 90 | if (!Serbench.Specimens.Tests.EDI_X12_835Data.AssertPayloadEquality(original, deserialized, out serError)) 91 | { 92 | if (abort) test.Abort(this, serError); 93 | return false; 94 | } 95 | } 96 | return base.AssertPayloadEquality(test, original, deserialized, abort); 97 | } 98 | } 99 | } -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Serializers/JilSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using NFX; 5 | using NFX.Environment; 6 | 7 | using Jil; 8 | 9 | namespace Serbench.Specimens.Serializers 10 | { 11 | /// 12 | /// Represents Jil serializer: 13 | /// See here https://github.com/kevin-montrose/Jil 14 | /// >PM Install-Package Jil 15 | /// 16 | [SerializerInfo( 17 | Family = SerializerFamily.Textual, 18 | MetadataRequirement = MetadataRequirement.None, 19 | VendorName = "Kevin Montrose", 20 | VendorLicense = "The MIT License (MIT)", 21 | VendorURL = "https://github.com/kevin-montrose/Jil", 22 | VendorPackageAddress = "Install-Package Jil", 23 | FormatName = "JSON", 24 | LinesOfCodeK = 60, 25 | DataTypes = 320, //https://github.com/kevin-montrose/Jil/issues/141#issuecomment-121346441 26 | Assemblies = 2, //JIL + SIGIL 27 | ExternalReferences = 1,//SIGIL 28 | PackageSizeKb = 393 29 | )] 30 | public class JilSerializer : Serializer 31 | { 32 | //private readonly JilSerializer m_Serializer; 33 | private Type[] m_KnownTypes; 34 | private Type m_PrimaryType; 35 | 36 | public JilSerializer(TestingSystem context, IConfigSectionNode conf) 37 | : base(context, conf) 38 | { 39 | m_KnownTypes = ReadKnownTypes(conf); 40 | } 41 | 42 | public override void BeforeRuns(Test test) 43 | { 44 | m_PrimaryType = test.GetPayloadRootType(); 45 | } 46 | 47 | public override void Serialize(object root, Stream stream) 48 | { 49 | using (var sw = new StreamWriter(stream)) 50 | { 51 | JSON.Serialize(root, sw); 52 | } 53 | } 54 | 55 | public override object Deserialize(Stream stream) 56 | { 57 | using (var sr = new StreamReader(stream)) 58 | { 59 | return JSON.Deserialize(sr, m_PrimaryType); 60 | } 61 | } 62 | 63 | public override void ParallelSerialize(object root, Stream stream) 64 | { 65 | using (var sw = new StreamWriter(stream)) 66 | { 67 | JSON.Serialize(root, sw); 68 | } 69 | } 70 | 71 | public override object ParallelDeserialize(Stream stream) 72 | { 73 | using (var sr = new StreamReader(stream)) 74 | { 75 | return JSON.Deserialize(sr, m_PrimaryType); 76 | } 77 | } 78 | public override bool AssertPayloadEquality(Test test, object original, object deserialized, bool abort = true) 79 | { 80 | string serError = null; 81 | if (test.Name.Contains("Telemetry")) 82 | { 83 | if (!Serbench.Specimens.Tests.TelemetryData.AssertPayloadEquality(original, deserialized, out serError)) 84 | { 85 | if (abort) test.Abort(this, serError); 86 | return false; 87 | } 88 | } 89 | else if (test.Name.Contains("EDI_X12_835")) 90 | { 91 | if (!Serbench.Specimens.Tests.EDI_X12_835Data.AssertPayloadEquality(original, deserialized, out serError)) 92 | { 93 | if (abort) test.Abort(this, serError); 94 | return false; 95 | } 96 | } 97 | return base.AssertPayloadEquality(test, original, deserialized, abort); 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Serializers/JsonFxSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using NFX; 5 | using NFX.Environment; 6 | 7 | using JsonFx.Json; 8 | 9 | namespace Serbench.Specimens.Serializers 10 | { 11 | /// 12 | /// Represents JsonFx by Stephen M. McKamey: 13 | /// See here https://github.com/jsonfx/jsonfx 14 | /// >PM Install-Package JsonFx 15 | /// 16 | [SerializerInfo( 17 | Family = SerializerFamily.Textual, 18 | MetadataRequirement = MetadataRequirement.None, 19 | VendorName = "Stephen M. McKamey", 20 | VendorLicense = "The MIT License (MIT)", 21 | VendorURL = "https://github.com/jsonfx/jsonfx", 22 | VendorPackageAddress = "Install-Package JsonFx", 23 | FormatName = "JSON", 24 | LinesOfCodeK = 0, 25 | DataTypes = 0, 26 | Assemblies = 1, 27 | ExternalReferences = 0, 28 | PackageSizeKb = 214 29 | )] 30 | public class JsonFxSerializer : Serializer 31 | { 32 | static readonly JsonWriter m_jw = new JsonWriter(); 33 | static readonly JsonReader m_jr = new JsonReader(); 34 | private Type m_primaryType; 35 | 36 | public JsonFxSerializer(TestingSystem context, IConfigSectionNode conf) 37 | : base(context, conf) 38 | { 39 | } 40 | 41 | public override void BeforeRuns(Test test) 42 | { 43 | m_primaryType = test.GetPayloadRootType(); 44 | } 45 | 46 | public override void Serialize(object root, Stream stream) 47 | { 48 | using (var sw = new StreamWriter(stream)) 49 | { 50 | sw.Write(m_jw.Write(root)); 51 | } 52 | } 53 | 54 | public override object Deserialize(Stream stream) 55 | { 56 | using (var sr = new StreamReader(stream)) 57 | { 58 | return m_jr.Read(sr.ReadToEnd(), m_primaryType); 59 | } 60 | } 61 | 62 | public override void ParallelSerialize(object root, Stream stream) 63 | { 64 | using (var sw = new StreamWriter(stream)) 65 | { 66 | sw.Write(m_jw.Write(root)); 67 | } 68 | } 69 | 70 | public override object ParallelDeserialize(Stream stream) 71 | { 72 | using (var sr = new StreamReader(stream)) 73 | { 74 | return m_jr.Read(sr.ReadToEnd(), m_primaryType); 75 | } 76 | } 77 | public override bool AssertPayloadEquality(Test test, object original, object deserialized, bool abort = true) 78 | { 79 | string serError = null; 80 | if (test.Name.Contains("Telemetry")) 81 | { 82 | if (!Serbench.Specimens.Tests.TelemetryData.AssertPayloadEquality(original, deserialized, out serError)) 83 | { 84 | if (abort) test.Abort(this, serError); 85 | return false; 86 | } 87 | } 88 | else if (test.Name.Contains("EDI_X12_835")) 89 | { 90 | if (!Serbench.Specimens.Tests.EDI_X12_835Data.AssertPayloadEquality(original, deserialized, out serError)) 91 | { 92 | if (abort) test.Abort(this, serError); 93 | return false; 94 | } 95 | } 96 | return base.AssertPayloadEquality(test, original, deserialized, abort); 97 | } 98 | } 99 | } -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Serializers/JsonNet.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using NFX; 5 | using NFX.Environment; 6 | 7 | using Newtonsoft.Json; 8 | 9 | namespace Serbench.Specimens.Serializers 10 | { 11 | /// 12 | /// Represents Newtonsoft's Json.Net xerializer: 13 | /// See here http://www.newtonsoft.com/json 14 | /// >PM Install-Package Newtonsoft.Json 15 | /// 16 | [SerializerInfo( 17 | Family = SerializerFamily.Textual, 18 | MetadataRequirement = MetadataRequirement.None, 19 | VendorName = "James Newton-King", 20 | VendorLicense = "The MIT License (MIT)", 21 | VendorURL = "http://www.newtonsoft.com/json", 22 | VendorPackageAddress = "Install-Package Newtonsoft.Json", 23 | FormatName = "JSON", 24 | LinesOfCodeK = 0, 25 | DataTypes = 0, 26 | Assemblies = 1, 27 | ExternalReferences = 0, 28 | PackageSizeKb = 502 29 | )] 30 | public class JsonNet : Serializer 31 | { 32 | private readonly JsonSerializer m_Serializer = new JsonSerializer(); 33 | private Type[] m_KnownTypes; 34 | private Type m_PrimaryType; 35 | 36 | public JsonNet(TestingSystem context, IConfigSectionNode conf) 37 | : base(context, conf) 38 | { 39 | m_KnownTypes = ReadKnownTypes(conf); 40 | } 41 | 42 | public override void BeforeRuns(Test test) 43 | { 44 | m_PrimaryType = test.GetPayloadRootType(); 45 | } 46 | 47 | public override void Serialize(object root, Stream stream) 48 | { 49 | using (var sw = new StreamWriter(stream)) 50 | using (var jw = new JsonTextWriter(sw)) 51 | { 52 | m_Serializer.Serialize(jw, root); 53 | } 54 | } 55 | 56 | public override object Deserialize(Stream stream) 57 | { 58 | using (var sr = new StreamReader(stream)) 59 | using (var jr = new JsonTextReader(sr)) 60 | { 61 | return m_Serializer.Deserialize(jr, m_PrimaryType); 62 | } 63 | } 64 | 65 | public override void ParallelSerialize(object root, Stream stream) 66 | { 67 | using (var sw = new StreamWriter(stream)) 68 | using (var jw = new JsonTextWriter(sw)) 69 | { 70 | m_Serializer.Serialize(jw, root); 71 | } 72 | } 73 | 74 | public override object ParallelDeserialize(Stream stream) 75 | { 76 | using (var sr = new StreamReader(stream)) 77 | using (var jr = new JsonTextReader(sr)) 78 | { 79 | return m_Serializer.Deserialize(jr, m_PrimaryType); 80 | } 81 | } 82 | public override bool AssertPayloadEquality(Test test, object original, object deserialized, bool abort = true) 83 | { 84 | string serError = null; 85 | if (test.Name.Contains("Telemetry")) 86 | { 87 | if (!Serbench.Specimens.Tests.TelemetryData.AssertPayloadEquality(original, deserialized, out serError)) 88 | { 89 | if (abort) test.Abort(this, serError); 90 | return false; 91 | } 92 | } 93 | else if (test.Name.Contains("EDI_X12_835")) 94 | { 95 | if (!Serbench.Specimens.Tests.EDI_X12_835Data.AssertPayloadEquality(original, deserialized, out serError)) 96 | { 97 | if (abort) test.Abort(this, serError); 98 | return false; 99 | } 100 | } 101 | return base.AssertPayloadEquality(test, original, deserialized, abort); 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Serializers/MessageSharkSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using NFX; 5 | using NFX.Environment; 6 | 7 | using MessageShark; 8 | 9 | namespace Serbench.Specimens.Serializers 10 | { 11 | /// 12 | /// Represents MessageShark by TJ Bakre: 13 | /// See here https://github.com/rpgmaker/MessageShark 14 | /// >PM Install-Package MessageShark 15 | /// 16 | [SerializerInfo( 17 | Family = SerializerFamily.Binary, 18 | MetadataRequirement = MetadataRequirement.None, 19 | VendorName = "TJ Bakre", 20 | VendorLicense = "The GNU Library General Public License (LGPL)", 21 | VendorURL = "https://github.com/rpgmaker/MessageShark", 22 | VendorPackageAddress = "Install-Package MessageShark", 23 | FormatName = "MessageShark", 24 | LinesOfCodeK = 0, 25 | DataTypes = 0, 26 | Assemblies = 1, 27 | ExternalReferences = 0, 28 | PackageSizeKb = 49 29 | )] 30 | public class MessageSharkSerializer : Serializer 31 | { 32 | 33 | // private Type m_primaryType; 34 | 35 | public MessageSharkSerializer(TestingSystem context, IConfigSectionNode conf) 36 | : base(context, conf) 37 | { 38 | } 39 | 40 | public override void BeforeRuns(Test test) 41 | { 42 | m_RootType = test.GetPayloadRootType(); 43 | } 44 | 45 | 46 | private Type m_RootType; 47 | 48 | public override void Serialize(object root, Stream stream) 49 | { 50 | MessageShark.MessageSharkSerializer.Serialize(root, stream); 51 | } 52 | 53 | public override object Deserialize(Stream stream) 54 | { 55 | return MessageShark.MessageSharkSerializer.Deserialize(m_RootType, stream); 56 | } 57 | 58 | public override void ParallelSerialize(object root, Stream stream) 59 | { 60 | MessageShark.MessageSharkSerializer.Serialize(root, stream); 61 | } 62 | 63 | public override object ParallelDeserialize(Stream stream) 64 | { 65 | return MessageShark.MessageSharkSerializer.Deserialize(m_RootType, stream); 66 | } 67 | public override bool AssertPayloadEquality(Test test, object original, object deserialized, bool abort = true) 68 | { 69 | string serError = null; 70 | if (test.Name.Contains("Telemetry")) 71 | { 72 | if (!Serbench.Specimens.Tests.TelemetryData.AssertPayloadEquality(original, deserialized, out serError)) 73 | { 74 | if (abort) test.Abort(this, serError); 75 | return false; 76 | } 77 | } 78 | else if (test.Name.Contains("EDI_X12_835")) 79 | { 80 | if (!Serbench.Specimens.Tests.EDI_X12_835Data.AssertPayloadEquality(original, deserialized, out serError)) 81 | { 82 | if (abort) test.Abort(this, serError); 83 | return false; 84 | } 85 | } 86 | return base.AssertPayloadEquality(test, original, deserialized, abort); 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Serializers/MsgPackSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using NFX; 5 | using NFX.Environment; 6 | 7 | 8 | using MsgPack.Serialization; 9 | 10 | namespace Serbench.Specimens.Serializers 11 | { 12 | /// 13 | /// Represents MsgPack technology 14 | /// See here https://github.com/msgpack/msgpack-cli 15 | /// >PM Install-Package MsgPack.Cli 16 | /// 17 | [SerializerInfo( 18 | Family = SerializerFamily.Binary, 19 | MetadataRequirement = MetadataRequirement.None, 20 | VendorName = "Sadayuki Furuhashi", 21 | VendorLicense = "Apache 2.0", 22 | VendorURL = "https://github.com/msgpack/msgpack-cli", 23 | VendorPackageAddress = "Install-Package MsgPack.Cli", 24 | FormatName = "MsgPack", 25 | LinesOfCodeK = 0, 26 | DataTypes = 0, 27 | Assemblies = 1, 28 | ExternalReferences = 0, 29 | PackageSizeKb = 429 30 | )] 31 | public class MsgPackSerializer : Serializer 32 | { 33 | public MsgPackSerializer(TestingSystem context, IConfigSectionNode conf) 34 | : base(context, conf) 35 | { 36 | 37 | } 38 | 39 | private MessagePackSerializer m_Serializer = null; 40 | 41 | public override void BeforeRuns(Test test) 42 | { 43 | m_Serializer = MessagePackSerializer.Get(test.GetPayloadRootType()); 44 | } 45 | 46 | 47 | public override void Serialize(object root, Stream stream) 48 | { 49 | m_Serializer.Pack(stream, root); 50 | } 51 | 52 | public override object Deserialize(Stream stream) 53 | { 54 | return m_Serializer.Unpack(stream); 55 | } 56 | 57 | public override void ParallelSerialize(object root, Stream stream) 58 | { 59 | m_Serializer.Pack(stream, root); 60 | } 61 | 62 | public override object ParallelDeserialize(Stream stream) 63 | { 64 | return m_Serializer.Unpack(stream); 65 | } 66 | 67 | public override bool AssertPayloadEquality(Test test, object original, object deserialized, bool abort = true) 68 | { 69 | string serError = null; 70 | if (test.Name.Contains("Telemetry")) 71 | { 72 | if (!Serbench.Specimens.Tests.TelemetryData.AssertPayloadEquality(original, deserialized, out serError)) 73 | { 74 | if (abort) test.Abort(this, serError); 75 | return false; 76 | } 77 | } 78 | else if (test.Name.Contains("EDI_X12_835")) 79 | { 80 | if (!Serbench.Specimens.Tests.EDI_X12_835Data.AssertPayloadEquality(original, deserialized, out serError)) 81 | { 82 | if (abort) test.Abort(this, serError); 83 | return false; 84 | } 85 | } 86 | return base.AssertPayloadEquality(test, original, deserialized, abort); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Serializers/NetJSONSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using NFX; 5 | using NFX.Environment; 6 | 7 | using NetJSON; 8 | 9 | namespace Serbench.Specimens.Serializers 10 | { 11 | /// 12 | /// Represents NetJSON: 13 | /// See here https://github.com/rpgmaker/NetJSON 14 | /// >PM Install-Package NetJSON 15 | /// 16 | [SerializerInfo( 17 | Family = SerializerFamily.Textual, 18 | MetadataRequirement = MetadataRequirement.None, 19 | VendorName = "Phoenix Service Bus, Inc", 20 | VendorLicense = "The MIT License (MIT)", 21 | VendorURL = "https://github.com/rpgmaker/NetJSON", 22 | VendorPackageAddress = "Install-Package NetJSON", 23 | FormatName = "JSON", 24 | LinesOfCodeK = 0, 25 | DataTypes = 0, 26 | Assemblies = 1, 27 | ExternalReferences = 0, 28 | PackageSizeKb = 162 29 | )] 30 | public class NetJSONSerializer : Serializer 31 | { 32 | public NetJSONSerializer(TestingSystem context, IConfigSectionNode conf) 33 | : base(context, conf) 34 | { 35 | 36 | } 37 | 38 | public override void BeforeRuns(Test test) 39 | { 40 | m_RootType = test.GetPayloadRootType(); 41 | } 42 | 43 | 44 | private Type m_RootType; 45 | 46 | public override void Serialize(object root, Stream stream) 47 | { 48 | using (var sw = new StreamWriter(stream)) 49 | { 50 | sw.Write(NetJSON.NetJSON.Serialize(m_RootType, root)); 51 | } 52 | } 53 | 54 | public override object Deserialize(Stream stream) 55 | { 56 | using (var sr = new StreamReader(stream)) 57 | { 58 | return NetJSON.NetJSON.Deserialize(m_RootType, sr.ReadToEnd()); 59 | } 60 | } 61 | 62 | public override void ParallelSerialize(object root, Stream stream) 63 | { 64 | using (var sw = new StreamWriter(stream)) 65 | { 66 | sw.Write(NetJSON.NetJSON.Serialize(m_RootType, root)); 67 | } 68 | } 69 | 70 | public override object ParallelDeserialize(Stream stream) 71 | { 72 | using (var sr = new StreamReader(stream)) 73 | { 74 | return NetJSON.NetJSON.Deserialize(m_RootType, sr.ReadToEnd()); 75 | } 76 | } 77 | 78 | public override bool AssertPayloadEquality(Test test, object original, object deserialized, bool abort = true) 79 | { 80 | string serError = null; 81 | if (test.Name.Contains("Telemetry")) 82 | { 83 | if (!Serbench.Specimens.Tests.TelemetryData.AssertPayloadEquality(original, deserialized, out serError)) 84 | { 85 | if (abort) test.Abort(this, serError); 86 | return false; 87 | } 88 | } 89 | else if (test.Name.Contains("EDI_X12_835")) 90 | { 91 | if (!Serbench.Specimens.Tests.EDI_X12_835Data.AssertPayloadEquality(original, deserialized, out serError)) 92 | { 93 | if (abort) test.Abort(this, serError); 94 | return false; 95 | } 96 | } 97 | return base.AssertPayloadEquality(test, original, deserialized, abort); 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Serializers/NetSerializerSer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.IO; 5 | using NFX; 6 | using NFX.Environment; 7 | 8 | using NetSerializer; 9 | 10 | 11 | namespace Serbench.Specimens.Serializers 12 | { 13 | /// 14 | /// Represents NetSerializer: 15 | /// See here: https://github.com/tomba/netserializer 16 | /// Add: PM> Install-Package NetSerializer 17 | /// 18 | [SerializerInfo( 19 | Family = SerializerFamily.Binary, 20 | MetadataRequirement = MetadataRequirement.Attributes, 21 | VendorName = "Tomi Valkeinen", 22 | VendorLicense = "The Mozilla Public License 2.0 (MPL)", 23 | VendorURL = "https://github.com/tomba/netserializer", 24 | VendorPackageAddress = "Install-Package NetSerializer", 25 | FormatName = "NetSerializer", 26 | LinesOfCodeK = 0, 27 | DataTypes = 0, 28 | Assemblies = 1, 29 | ExternalReferences = 0, 30 | PackageSizeKb = 30 31 | )] 32 | public class NetSerializerSer : Serializer 33 | { 34 | public NetSerializerSer(TestingSystem context, IConfigSectionNode conf) 35 | : base(context, conf) 36 | { 37 | m_KnownTypes = ReadKnownTypes(conf); 38 | } 39 | 40 | private NetSerializer.Serializer m_Serializer; 41 | private Type[] m_KnownTypes; 42 | 43 | 44 | public override void BeforeRuns(Test test) 45 | { 46 | try 47 | { 48 | m_Serializer = m_KnownTypes==null ? new NetSerializer.Serializer( new Type[]{test.GetPayloadRootType() }) 49 | : new NetSerializer.Serializer( new Type[]{test.GetPayloadRootType() }.Concat(m_KnownTypes)); 50 | } 51 | catch (Exception error) 52 | { 53 | test.Abort(this, "Error making NetSerializer instance in serializer BeforeRun() {0}. \n Did you decorate the primary known type correctly?".Args(error.ToMessageWithType())); 54 | } 55 | } 56 | 57 | 58 | public override void Serialize(object root, Stream stream) 59 | { 60 | m_Serializer.Serialize(stream, root); 61 | } 62 | 63 | public override object Deserialize(Stream stream) 64 | { 65 | return m_Serializer.Deserialize(stream); 66 | } 67 | 68 | public override void ParallelSerialize(object root, Stream stream) 69 | { 70 | m_Serializer.Serialize(stream, root); 71 | } 72 | 73 | public override object ParallelDeserialize(Stream stream) 74 | { 75 | return m_Serializer.Deserialize(stream); 76 | } 77 | public override bool AssertPayloadEquality(Test test, object original, object deserialized, bool abort = true) 78 | { 79 | string serError = null; 80 | if (test.Name.Contains("Telemetry")) 81 | { 82 | if (!Serbench.Specimens.Tests.TelemetryData.AssertPayloadEquality(original, deserialized, out serError)) 83 | { 84 | if (abort) test.Abort(this, serError); 85 | return false; 86 | } 87 | } 88 | else if (test.Name.Contains("EDI_X12_835")) 89 | { 90 | if (!Serbench.Specimens.Tests.EDI_X12_835Data.AssertPayloadEquality(original, deserialized, out serError)) 91 | { 92 | if (abort) test.Abort(this, serError); 93 | return false; 94 | } 95 | } 96 | return base.AssertPayloadEquality(test, original, deserialized, abort); 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Serializers/ProtoBufSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | using NFX; 8 | using NFX.Environment; 9 | 10 | using ProtoBuf; 11 | using ProtoBuf.Meta; 12 | 13 | namespace Serbench.Specimens.Serializers 14 | { 15 | /// 16 | /// Represents ProtoBuf: 17 | /// See here: https://github.com/mgravell/protobuf-net 18 | /// Add: PM> Install-Package protobuf-net 19 | /// NOTE: I use the protobuf-net NuGet package because of 20 | /// [http://stackoverflow.com/questions/2522376/how-to-choose-between-protobuf-csharp-port-and-protobuf-net] 21 | /// 22 | [SerializerInfo( 23 | Family = SerializerFamily.Binary, 24 | MetadataRequirement = MetadataRequirement.Attributes, 25 | VendorName = "Marc Gravell", 26 | VendorLicense = "The Apache License 2.0", 27 | VendorURL = "https://github.com/mgravell/protobuf-net", 28 | VendorPackageAddress = "Install-Package protobuf-net", 29 | FormatName = "protobuf", 30 | LinesOfCodeK = 0, 31 | DataTypes = 0, 32 | Assemblies = 1, 33 | ExternalReferences = 0, 34 | PackageSizeKb = 193 35 | )] 36 | public class ProtoBufSerializer : Serializer 37 | { 38 | public ProtoBufSerializer(TestingSystem context, IConfigSectionNode conf) 39 | : base(context, conf) 40 | { 41 | m_KnownTypes = ReadKnownTypes(conf); 42 | foreach (var knownType in m_KnownTypes) 43 | m_Model.Add(knownType, true); 44 | 45 | m_Model.CompileInPlace(); 46 | } 47 | 48 | 49 | private RuntimeTypeModel m_Model = RuntimeTypeModel.Create(); 50 | private Type[] m_KnownTypes; 51 | private Type m_PrimaryType; 52 | 53 | 54 | public override void BeforeRuns(Test test) 55 | { 56 | m_PrimaryType = test.GetPayloadRootType(); 57 | } 58 | 59 | 60 | public override void Serialize(object root, Stream stream) 61 | { 62 | m_Model.Serialize(stream, root); 63 | } 64 | 65 | public override object Deserialize(Stream stream) 66 | { 67 | return m_Model.Deserialize(stream, null, m_PrimaryType); 68 | } 69 | 70 | public override void ParallelSerialize(object root, Stream stream) 71 | { 72 | m_Model.Serialize(stream, root); 73 | } 74 | 75 | public override object ParallelDeserialize(Stream stream) 76 | { 77 | return m_Model.Deserialize(stream, null, m_PrimaryType); 78 | } 79 | public override bool AssertPayloadEquality(Test test, object original, object deserialized, bool abort = true) 80 | { 81 | string serError = null; 82 | if (test.Name.Contains("Telemetry")) 83 | { 84 | if (!Serbench.Specimens.Tests.TelemetryData.AssertPayloadEquality(original, deserialized, out serError)) 85 | { 86 | if (abort) test.Abort(this, serError); 87 | return false; 88 | } 89 | } 90 | else if (test.Name.Contains("EDI_X12_835")) 91 | { 92 | if (!Serbench.Specimens.Tests.EDI_X12_835Data.AssertPayloadEquality(original, deserialized, out serError)) 93 | { 94 | if (abort) test.Abort(this, serError); 95 | return false; 96 | } 97 | } 98 | return base.AssertPayloadEquality(test, original, deserialized, abort); 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Serializers/ServiceStackJsonSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using NFX; 5 | using NFX.Environment; 6 | 7 | using ServiceStack.Text; 8 | 9 | namespace Serbench.Specimens.Serializers 10 | { 11 | /// 12 | /// Represents ServiceStack: 13 | /// See here https://github.com/ServiceStack/ServiceStack.Text 14 | /// >PM Install-Package ServiceStack.Text 15 | /// 16 | [SerializerInfo( 17 | Family = SerializerFamily.Textual, 18 | MetadataRequirement = MetadataRequirement.Attributes, 19 | VendorName = "Service Stack", 20 | VendorLicense = "All OSS Licenses + Commercial", 21 | VendorURL = "https://github.com/ServiceStack/ServiceStack.Text", 22 | VendorPackageAddress = "Install-Package ServiceStack.Text", 23 | FormatName = "JSON", 24 | LinesOfCodeK = 0, 25 | DataTypes = 0, 26 | Assemblies = 1, 27 | ExternalReferences = 0, 28 | PackageSizeKb = 307 29 | )] 30 | public class ServiceStackJsonSerializer : Serializer 31 | { 32 | private Type[] m_KnownTypes; 33 | private Type m_primaryType; 34 | 35 | public ServiceStackJsonSerializer(TestingSystem context, IConfigSectionNode conf) 36 | : base(context, conf) 37 | { 38 | m_KnownTypes = ReadKnownTypes(conf); 39 | } 40 | 41 | public override void BeforeRuns(Test test) 42 | { 43 | try 44 | { 45 | m_primaryType = test.GetPayloadRootType(); 46 | } 47 | catch (Exception error) 48 | { 49 | test.Abort(this, "Error making ServiceStackJsonSerializer instance in serializer BeforeRun() {0}. \n Did you decorate the primary known type correctly?".Args(error.ToMessageWithType())); 50 | } 51 | } 52 | 53 | public override void Serialize(object root, Stream stream) 54 | { 55 | TypeSerializer.SerializeToStream(root, m_primaryType, stream); 56 | } 57 | 58 | public override object Deserialize(Stream stream) 59 | { 60 | return TypeSerializer.DeserializeFromStream(m_primaryType, stream); 61 | } 62 | 63 | public override void ParallelSerialize(object root, Stream stream) 64 | { 65 | TypeSerializer.SerializeToStream(root, m_primaryType, stream); 66 | } 67 | 68 | public override object ParallelDeserialize(Stream stream) 69 | { 70 | return TypeSerializer.DeserializeFromStream(m_primaryType, stream); 71 | } 72 | public override bool AssertPayloadEquality(Test test, object original, object deserialized, bool abort = true) 73 | { 74 | string serError = null; 75 | if (test.Name.Contains("Telemetry")) 76 | { 77 | if (!Serbench.Specimens.Tests.TelemetryData.AssertPayloadEquality(original, deserialized, out serError)) 78 | { 79 | if (abort) test.Abort(this, serError); 80 | return false; 81 | } 82 | } 83 | else if (test.Name.Contains("EDI_X12_835")) 84 | { 85 | if (!Serbench.Specimens.Tests.EDI_X12_835Data.AssertPayloadEquality(original, deserialized, out serError)) 86 | { 87 | if (abort) test.Abort(this, serError); 88 | return false; 89 | } 90 | } 91 | return base.AssertPayloadEquality(test, original, deserialized, abort); 92 | } 93 | } 94 | } -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Serializers/ServiceStackTypeSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using NFX; 5 | using NFX.Environment; 6 | 7 | using ServiceStack.Text; 8 | 9 | namespace Serbench.Specimens.Serializers 10 | { 11 | /// 12 | /// Represents ServiceStack: 13 | /// See here https://github.com/ServiceStack/ServiceStack.Text 14 | /// >PM Install-Package ServiceStack.Text 15 | /// 16 | [SerializerInfo( 17 | Family = SerializerFamily.Textual, 18 | MetadataRequirement = MetadataRequirement.Attributes, 19 | VendorName = "Service Stack", 20 | VendorLicense = "All OSS Licenses + Commercial", 21 | VendorURL = "https://github.com/ServiceStack/ServiceStack.Text", 22 | VendorPackageAddress = "Install-Package ServiceStack.Text", 23 | FormatName = "JSV", 24 | LinesOfCodeK = 0, 25 | DataTypes = 0, 26 | Assemblies = 1, 27 | ExternalReferences = 0, 28 | PackageSizeKb = 307 29 | )] 30 | public class ServiceStackTypeSerializer : Serializer 31 | { 32 | private Type[] m_KnownTypes; 33 | private Type m_primaryType; 34 | 35 | public ServiceStackTypeSerializer(TestingSystem context, IConfigSectionNode conf) 36 | : base(context, conf) 37 | { 38 | m_KnownTypes = ReadKnownTypes(conf); 39 | } 40 | 41 | public override void BeforeRuns(Test test) 42 | { 43 | try 44 | { 45 | m_primaryType = test.GetPayloadRootType(); 46 | } 47 | catch (Exception error) 48 | { 49 | test.Abort(this, "Error making ServiceStackTypeSerializer instance in serializer BeforeRun() {0}. \n Did you decorate the primary known type correctly?".Args(error.ToMessageWithType())); 50 | } 51 | } 52 | 53 | public override void Serialize(object root, Stream stream) 54 | { 55 | JsonSerializer.SerializeToStream(root, m_primaryType, stream); 56 | } 57 | 58 | public override object Deserialize(Stream stream) 59 | { 60 | return JsonSerializer.DeserializeFromStream(m_primaryType, stream); 61 | } 62 | 63 | public override void ParallelSerialize(object root, Stream stream) 64 | { 65 | JsonSerializer.SerializeToStream(root, m_primaryType, stream); 66 | } 67 | 68 | public override object ParallelDeserialize(Stream stream) 69 | { 70 | return JsonSerializer.DeserializeFromStream(m_primaryType, stream); 71 | } 72 | public override bool AssertPayloadEquality(Test test, object original, object deserialized, bool abort = true) 73 | { 74 | string serError = null; 75 | if (test.Name.Contains("Telemetry")) 76 | { 77 | if (!Serbench.Specimens.Tests.TelemetryData.AssertPayloadEquality(original, deserialized, out serError)) 78 | { 79 | if (abort) test.Abort(this, serError); 80 | return false; 81 | } 82 | } 83 | else if (test.Name.Contains("EDI_X12_835")) 84 | { 85 | if (!Serbench.Specimens.Tests.EDI_X12_835Data.AssertPayloadEquality(original, deserialized, out serError)) 86 | { 87 | if (abort) test.Abort(this, serError); 88 | return false; 89 | } 90 | } 91 | return base.AssertPayloadEquality(test, original, deserialized, abort); 92 | } 93 | } 94 | } -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Serializers/SharpSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.IO; 5 | using NFX; 6 | using NFX.Environment; 7 | 8 | using Polenter.Serialization; 9 | 10 | 11 | namespace Serbench.Specimens.Serializers 12 | { 13 | /// 14 | /// Represents SharpSerializer: 15 | /// See here: http://www.sharpserializer.com/en/index.html 16 | /// Add: PM> Install-Package SharpSerializer 17 | /// 18 | [SerializerInfo( 19 | Family = SerializerFamily.Binary, 20 | MetadataRequirement = MetadataRequirement.Attributes, 21 | VendorName = "Pawel Idzikowski / Polenter-Software Solutions", 22 | VendorLicense = "New BSD License (BSD)", 23 | VendorURL = "http://www.sharpserializer.com/en/index.html", 24 | VendorPackageAddress = "Install-Package SharpSerializer", 25 | FormatName = "SharpSerializer", 26 | LinesOfCodeK = 0, 27 | DataTypes = 0, 28 | Assemblies = 1, 29 | ExternalReferences = 0, 30 | PackageSizeKb = 244 31 | )] 32 | public class SharpSerializer : Serializer 33 | { 34 | public SharpSerializer(TestingSystem context, IConfigSectionNode conf) 35 | : base(context, conf) 36 | { 37 | var settings = new Polenter.Serialization.SharpSerializerBinarySettings 38 | { 39 | Mode = BinarySerializationMode.Burst 40 | }; 41 | m_Serializer = new Polenter.Serialization.SharpSerializer(settings); 42 | } 43 | 44 | private Polenter.Serialization.SharpSerializer m_Serializer; 45 | 46 | 47 | public override void Serialize(object root, Stream stream) 48 | { 49 | m_Serializer.Serialize(root, stream); 50 | } 51 | 52 | public override object Deserialize(Stream stream) 53 | { 54 | return m_Serializer.Deserialize(stream); 55 | } 56 | 57 | public override void ParallelSerialize(object root, Stream stream) 58 | { 59 | m_Serializer.Serialize(root, stream); 60 | } 61 | 62 | public override object ParallelDeserialize(Stream stream) 63 | { 64 | return m_Serializer.Deserialize(stream); 65 | } 66 | 67 | public override bool AssertPayloadEquality(Test test, object original, object deserialized, bool abort = true) 68 | { 69 | string serError = null; 70 | if (test.Name.Contains("Telemetry")) 71 | { 72 | if (!Serbench.Specimens.Tests.TelemetryData.AssertPayloadEquality(original, deserialized, out serError)) 73 | { 74 | if (abort) test.Abort(this, serError); 75 | return false; 76 | } 77 | } 78 | else if (test.Name.Contains("EDI_X12_835")) 79 | { 80 | if (!Serbench.Specimens.Tests.EDI_X12_835Data.AssertPayloadEquality(original, deserialized, out serError)) 81 | { 82 | if (abort) test.Abort(this, serError); 83 | return false; 84 | } 85 | } 86 | return base.AssertPayloadEquality(test, original, deserialized, abort); 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Serializers/WireSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using NFX.Environment; 8 | 9 | namespace Serbench.Specimens.Serializers 10 | { 11 | /// 12 | /// Represents Wire Binary serializer for POCO objects 13 | /// See here https://github.com/akkadotnet/Wire 14 | /// >PM Install-Package Wire 15 | /// 16 | [SerializerInfo( 17 | Family = SerializerFamily.Binary, 18 | 19 | MetadataRequirement = MetadataRequirement.None, 20 | VendorName = "Akka.NET Team", 21 | VendorLicense = "Apache 2.0", 22 | VendorURL = "http://getakka.net", 23 | VendorPackageAddress = "http://github.com/akkadotnet/wire", 24 | FormatName = "Wire", 25 | LinesOfCodeK = 0, 26 | DataTypes = 0, 27 | Assemblies = 1, 28 | ExternalReferences = 0, 29 | PackageSizeKb = 193 30 | )] 31 | public class WireSerializer : Serializer 32 | { 33 | public WireSerializer(TestingSystem context, IConfigSectionNode conf) : base(context, conf) 34 | { 35 | var opt = new Wire.SerializerOptions(false, true); 36 | m_Serializer = new Wire.Serializer(opt); 37 | } 38 | 39 | private Wire.Serializer m_Serializer; 40 | 41 | public override object Deserialize(Stream stream) 42 | { 43 | return m_Serializer.Deserialize(stream); 44 | } 45 | 46 | public override object ParallelDeserialize(Stream stream) 47 | { 48 | return m_Serializer.Deserialize(stream); 49 | } 50 | 51 | public override void ParallelSerialize(object root, Stream stream) 52 | { 53 | m_Serializer.Serialize(root, stream); 54 | } 55 | 56 | public override void Serialize(object root, Stream stream) 57 | { 58 | m_Serializer.Serialize(root, stream); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Tests/EDIOrder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Runtime.Serialization; 7 | using ProtoBuf; 8 | 9 | namespace Serbench.Specimens.Tests 10 | { 11 | [ProtoContract] 12 | [DataContract] 13 | [Serializable] 14 | public class EDIOrder 15 | { 16 | [ProtoMember(1)] 17 | [DataMember] 18 | public Header Header; 19 | [ProtoMember(2)] 20 | [DataMember] 21 | public CustomerDetails CustomerDetails; 22 | [ProtoMember(3)] 23 | [DataMember] 24 | public List OrderItems; 25 | } 26 | 27 | [ProtoContract] 28 | [DataContract] 29 | [Serializable] 30 | public class Header 31 | { 32 | [ProtoMember(1)] 33 | [DataMember] 34 | public int OrderId; 35 | [ProtoMember(2)] 36 | [DataMember] 37 | public int StatusCode; 38 | [ProtoMember(3)] 39 | [DataMember] 40 | public decimal NetAmount; 41 | [ProtoMember(4)] 42 | [DataMember] 43 | public double TotalAmount; 44 | [ProtoMember(5)] 45 | [DataMember] 46 | public double Tax; 47 | [ProtoMember(6)] 48 | [DataMember] 49 | public DateTime Date; 50 | } 51 | 52 | [ProtoContract] 53 | [DataContract] 54 | [Serializable] 55 | public class CustomerDetails 56 | { 57 | [ProtoMember(1)] 58 | [DataMember] 59 | public string UserName; 60 | [ProtoMember(2)] 61 | [DataMember] 62 | public string FirstName; 63 | [ProtoMember(3)] 64 | [DataMember] 65 | public string LastName; 66 | [ProtoMember(4)] 67 | [DataMember] 68 | public string AddressLine; 69 | [ProtoMember(5)] 70 | [DataMember] 71 | public string City; 72 | [ProtoMember(5)] 73 | [DataMember] 74 | public string State; 75 | [ProtoMember(6)] 76 | [DataMember] 77 | public string Zip; 78 | } 79 | 80 | [ProtoContract] 81 | [DataContract] 82 | [CollectionDataContract] 83 | [Serializable] 84 | public class OrderItem 85 | { 86 | [ProtoMember(1)] 87 | [DataMember] 88 | public int Position; 89 | [ProtoMember(2)] 90 | [DataMember] 91 | public int Quantity; 92 | [ProtoMember(3)] 93 | [DataMember] 94 | public int ProductId; 95 | [ProtoMember(4)] 96 | [DataMember] 97 | public string Title; 98 | [ProtoMember(5)] 99 | [DataMember] 100 | public double Price; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Tests/SimplePerson.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using NFX; 7 | using NFX.Environment; 8 | 9 | 10 | namespace Serbench.Specimens.Tests 11 | { 12 | 13 | //public class SimplePerson : Test 14 | //{ 15 | // protected SimplePerson(TestingSystem context, IConfigSectionNode conf) : base(context, conf) 16 | // { 17 | 18 | // } 19 | 20 | 21 | //} 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Tests/Telemetry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Runtime.Serialization; 8 | using NFX; 9 | using NFX.Environment; 10 | using NFX.Parsing; 11 | using ProtoBuf; 12 | 13 | namespace Serbench.Specimens.Tests 14 | { 15 | public class Telemetry : Test 16 | { 17 | public Telemetry(TestingSystem context, IConfigSectionNode conf) 18 | : base(context, conf) 19 | { 20 | if (m_MeasurementsNumber < 1) m_MeasurementsNumber = 1; 21 | m_Data = TelemetryData.Make(m_MeasurementsNumber); 22 | } 23 | 24 | 25 | public override Type GetPayloadRootType() 26 | { 27 | return m_Data.GetType(); 28 | } 29 | 30 | public override void PerformSerializationTest(Serializer serializer, Stream target) 31 | { 32 | serializer.Serialize(m_Data, target); 33 | } 34 | 35 | public override void PerformDeserializationTest(Serializer serializer, Stream target) 36 | { 37 | var deserialized = serializer.Deserialize(target); 38 | serializer.AssertPayloadEquality(this, m_Data, deserialized); 39 | } 40 | 41 | [Config(Default = 64)] 42 | private int m_MeasurementsNumber; 43 | public int MeasurementsNumber 44 | { 45 | get { return m_MeasurementsNumber; } 46 | } 47 | 48 | private TelemetryData m_Data; 49 | } 50 | 51 | [ProtoContract] 52 | [DataContract] 53 | [Serializable] 54 | public class TelemetryData 55 | { 56 | /// 57 | /// Required by some serilizers (i.e. XML) 58 | /// 59 | public TelemetryData() { } 60 | 61 | 62 | [ProtoMember(1)] 63 | [DataMember] 64 | public string Id; 65 | 66 | [ProtoMember(2)] 67 | [DataMember] 68 | public string DataSource; 69 | 70 | [ProtoMember(3)] 71 | [DataMember] 72 | public DateTime TimeStamp; 73 | 74 | [ProtoMember(4)] 75 | [DataMember] 76 | public int Param1; 77 | 78 | [ProtoMember(5)] 79 | [DataMember] 80 | public uint Param2; 81 | 82 | [ProtoMember(6)] 83 | [DataMember] 84 | public double[] Measurements; 85 | 86 | [ProtoMember(7)] 87 | [DataMember] 88 | public long AssociatedProblemID; 89 | 90 | [ProtoMember(8)] 91 | [DataMember] 92 | public long AssociatedLogID; 93 | 94 | [ProtoMember(9)] 95 | [DataMember] 96 | public bool WasProcessed; 97 | 98 | public static TelemetryData Make(int measurementsNumber) 99 | { 100 | TelemetryData data = new TelemetryData() 101 | { 102 | Id = Guid.NewGuid().ToString(), 103 | DataSource = Guid.NewGuid().ToString(), 104 | TimeStamp = DateTime.Now, 105 | Param1 = ExternalRandomGenerator.Instance.NextRandomInteger, 106 | Param2 = (uint)ExternalRandomGenerator.Instance.NextRandomInteger, 107 | Measurements = new double[measurementsNumber], 108 | AssociatedProblemID = 123, 109 | AssociatedLogID = 89032, 110 | WasProcessed = true 111 | }; 112 | for (var i = 0; i < measurementsNumber; i++) 113 | data.Measurements[i] = ExternalRandomGenerator.Instance.NextRandomDouble; 114 | return data; 115 | } 116 | 117 | public static bool AssertPayloadEquality(object original, object deserialized, out string errorString) 118 | { 119 | errorString = null; 120 | 121 | var originalTyped = original as Serbench.Specimens.Tests.TelemetryData; 122 | var deserializedTyped = deserialized as Serbench.Specimens.Tests.TelemetryData; 123 | 124 | if (originalTyped == null || deserializedTyped == null) 125 | errorString = "Error: originalTyped or deserializedTyped == null"; 126 | else if (originalTyped.Measurements == null || deserializedTyped.Measurements == null) 127 | errorString = "Error: originalTyped or deserializedTyped == null"; 128 | else if (originalTyped.Measurements.Length != deserializedTyped.Measurements.Length) 129 | errorString = "Error: originalTyped.Measurements.Length == deserializedTyped.Measurements.Length ({0} != {1}".Args(originalTyped.Measurements.Length, deserializedTyped.Measurements.Length); 130 | else if (originalTyped.AssociatedProblemID != deserializedTyped.AssociatedProblemID || originalTyped.AssociatedLogID != deserializedTyped.AssociatedLogID) 131 | errorString = "Error: originalTyped.AssociatedProblemID != deserializedTyped.AssociatedProblemID ({0} != {1}) || originalTyped.AssociatedLogID != deserializedTyped.AssociatedLogID ({2} != {3})".Args( 132 | originalTyped.AssociatedProblemID, deserializedTyped.AssociatedProblemID, 133 | originalTyped.AssociatedLogID, deserializedTyped.AssociatedLogID 134 | ); 135 | return (errorString == null) ? true : false; 136 | } 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /Source/Serbench.Specimens/Tests/TypicalPerson.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Runtime.Serialization; 5 | using NFX; 6 | using NFX.Environment; 7 | using NFX.Parsing; 8 | using ProtoBuf; 9 | 10 | namespace Serbench.Specimens.Tests 11 | { 12 | [DataContract] 13 | public enum MaritalStatus 14 | { 15 | [EnumMember] 16 | Married, 17 | [EnumMember] 18 | Divorced, 19 | [EnumMember] 20 | HatesAll 21 | } 22 | 23 | [ProtoContract] 24 | [DataContract] 25 | [Serializable] 26 | public class TypicalPersonData 27 | { 28 | /// 29 | /// Required by some serilizers (i.e. XML) 30 | /// 31 | public TypicalPersonData() { } 32 | 33 | 34 | [ProtoMember(1)] 35 | [DataMember] 36 | public string Address1; 37 | 38 | [ProtoMember(2)] 39 | [DataMember] 40 | public string Address2; 41 | 42 | [ProtoMember(3)] 43 | [DataMember] 44 | public string AddressCity; 45 | 46 | [ProtoMember(4)] 47 | [DataMember] 48 | public string AddressState; 49 | 50 | [ProtoMember(5)] 51 | [DataMember] 52 | public string AddressZip; 53 | 54 | [ProtoMember(6)] 55 | [DataMember] 56 | public double CreditScore; 57 | 58 | [ProtoMember(7)] 59 | [DataMember] 60 | public DateTime DOB; 61 | 62 | [ProtoMember(8)] 63 | [DataMember] 64 | public string EMail; 65 | 66 | [ProtoMember(9)] 67 | [DataMember] 68 | public string FirstName; 69 | 70 | [ProtoMember(10)] 71 | [DataMember] 72 | public string HomePhone; 73 | 74 | [ProtoMember(11)] 75 | [DataMember] 76 | public string LastName; 77 | 78 | [ProtoMember(12)] 79 | [DataMember] 80 | public MaritalStatus MaritalStatus; 81 | 82 | [ProtoMember(13)] 83 | [DataMember] 84 | public string MiddleName; 85 | 86 | [ProtoMember(14)] 87 | [DataMember] 88 | public string MobilePhone; 89 | 90 | [ProtoMember(15)] 91 | [DataMember] 92 | public bool RegisteredToVote; 93 | 94 | [ProtoMember(16)] 95 | [DataMember] 96 | public decimal Salary; 97 | 98 | [ProtoMember(17)] 99 | [DataMember] 100 | public int YearsOfService; 101 | 102 | 103 | 104 | [ProtoMember(18)][DataMember] public string SkypeID; 105 | [ProtoMember(19)][DataMember] public string YahooID; 106 | [ProtoMember(20)][DataMember] public string GoogleID; 107 | 108 | [ProtoMember(21)][DataMember] public string Notes; 109 | 110 | [ProtoMember(22)][DataMember] public bool? IsSmoker; 111 | [ProtoMember(23)][DataMember] public bool? IsLoving; 112 | [ProtoMember(24)][DataMember] public bool? IsLoved; 113 | [ProtoMember(25)][DataMember] public bool? IsDangerous; 114 | [ProtoMember(26)][DataMember] public bool? IsEducated; 115 | [ProtoMember(27)][DataMember] public DateTime? LastSmokingDate; 116 | 117 | [ProtoMember(28)][DataMember] public decimal? DesiredSalary; 118 | [ProtoMember(29)][DataMember] public double? ProbabilityOfSpaceFlight; 119 | 120 | [ProtoMember(30)][DataMember] public int? CurrentFriendCount; 121 | [ProtoMember(31)][DataMember] public int? DesiredFriendCount; 122 | 123 | 124 | public static TypicalPersonData MakeRandom() 125 | { 126 | var rnd = ExternalRandomGenerator.Instance.NextRandomInteger; 127 | 128 | var data = new TypicalPersonData 129 | { 130 | FirstName = NaturalTextGenerator.GenerateFirstName(), 131 | MiddleName = 132 | ExternalRandomGenerator.Instance.NextRandomInteger > 500000000 133 | ? NaturalTextGenerator.GenerateFirstName() 134 | : null, 135 | LastName = NaturalTextGenerator.GenerateLastName(), 136 | DOB = DateTime.Now.AddYears(ExternalRandomGenerator.Instance.NextScaledRandomInteger(-90, -1)), 137 | Salary = ExternalRandomGenerator.Instance.NextScaledRandomInteger(30, 250) * 1000m, 138 | YearsOfService = 25, 139 | CreditScore = 0.7562, 140 | RegisteredToVote = (DateTime.UtcNow.Ticks & 1) == 0, 141 | MaritalStatus = MaritalStatus.HatesAll, 142 | Address1 = NaturalTextGenerator.GenerateAddressLine(), 143 | Address2 = NaturalTextGenerator.GenerateAddressLine(), 144 | AddressCity = NaturalTextGenerator.GenerateCityName(), 145 | AddressState = "CA", 146 | AddressZip = "91606", 147 | HomePhone = (DateTime.UtcNow.Ticks & 1) == 0 ? "(555) 123-4567" : null, 148 | EMail = NaturalTextGenerator.GenerateEMail() 149 | }; 150 | 151 | if (0!=(rnd & (1<<32))) data.Notes = NaturalTextGenerator.Generate(45); 152 | if (0!=(rnd & (1<<31))) data.SkypeID = NaturalTextGenerator.GenerateEMail(); 153 | if (0!=(rnd & (1<<30))) data.YahooID = NaturalTextGenerator.GenerateEMail(); 154 | 155 | if (0!=(rnd & (1<<29))) data.IsSmoker = 0!=(rnd & (1<<17)); 156 | if (0!=(rnd & (1<<28))) data.IsLoving = 0!=(rnd & (1<<16)); 157 | if (0!=(rnd & (1<<27))) data.IsLoved = 0!=(rnd & (1<<15)); 158 | if (0!=(rnd & (1<<26))) data.IsDangerous = 0!=(rnd & (1<<14)); 159 | if (0!=(rnd & (1<<25))) data.IsEducated = 0!=(rnd & (1<<13)); 160 | 161 | if (0!=(rnd & (1<<24))) data.LastSmokingDate = DateTime.Now.AddYears(-10); 162 | 163 | 164 | if (0!=(rnd & (1<<23))) data.DesiredSalary = rnd / 1000m; 165 | if (0!=(rnd & (1<<22))) data.ProbabilityOfSpaceFlight = rnd / (double)int.MaxValue; 166 | 167 | if (0!=(rnd & (1<<21))) 168 | { 169 | data.CurrentFriendCount = rnd % 123; 170 | data.DesiredFriendCount = rnd % 121000; 171 | } 172 | 173 | return data; 174 | } 175 | } 176 | 177 | public class TypicalPerson : Test 178 | { 179 | 180 | public TypicalPerson(TestingSystem context, IConfigSectionNode conf) 181 | : base(context, conf) 182 | { 183 | if (m_Count < 1) m_Count = 1; 184 | 185 | for (var i = 0; i < m_Count; i++) 186 | m_Data.Add(TypicalPersonData.MakeRandom()); 187 | } 188 | 189 | 190 | [Config] 191 | private int m_Count; 192 | 193 | private List m_Data = new List(); 194 | 195 | [Config] 196 | private bool m_List; 197 | 198 | 199 | /// 200 | /// How many records in the list 201 | /// 202 | public int Count 203 | { 204 | get { return m_Count; } 205 | } 206 | 207 | /// 208 | /// Determines whether list of objects is serialized isntead of a single object 209 | /// 210 | public bool List 211 | { 212 | get { return m_List; } 213 | } 214 | 215 | public override Type GetPayloadRootType() 216 | { 217 | var root = m_List ? (object)m_Data : m_Data[0]; 218 | return root.GetType(); 219 | } 220 | 221 | public override void PerformSerializationTest(Serializer serializer, Stream target) 222 | { 223 | var root = m_List ? (object)m_Data : m_Data[0]; 224 | serializer.Serialize(root, target); 225 | } 226 | 227 | public override void PerformDeserializationTest(Serializer serializer, Stream target) 228 | { 229 | var got = serializer.Deserialize(target); 230 | 231 | var originalRoot = m_List ? (object)m_Data : m_Data[0]; 232 | serializer.AssertPayloadEquality(this, originalRoot, got); 233 | } 234 | } 235 | } -------------------------------------------------------------------------------- /Source/Serbench.Specimens/ThirdPartyLibs/Apolyton.FastJson.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aumcode/serbench/4e7a0e7d64cd20c348bdfc4205691a63d61ddf76/Source/Serbench.Specimens/ThirdPartyLibs/Apolyton.FastJson.dll -------------------------------------------------------------------------------- /Source/Serbench.Specimens/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Source/Serbench.Specimens/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Source/Serbench/BaseTypes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | 7 | using NFX; 8 | using NFX.Environment; 9 | 10 | namespace Serbench 11 | { 12 | /// 13 | /// Provides abstract base for all test artifacts - such as serializers and tests 14 | /// 15 | public abstract class TestArtifact : INamed, IOrdered 16 | { 17 | protected TestArtifact(TestingSystem context, IConfigSectionNode conf) 18 | { 19 | Context = context; 20 | 21 | ConfigAttribute.Apply(this, conf); 22 | 23 | if (m_Name.IsNullOrWhiteSpace()) 24 | m_Name = Guid.NewGuid().ToString(); 25 | } 26 | 27 | [Config] 28 | private string m_Name; 29 | 30 | [Config] 31 | private int m_Order; 32 | 33 | [Config] 34 | private string m_NotSupportedAbortMessage; 35 | 36 | [Config] 37 | private bool? m_DumpPayload; 38 | 39 | 40 | /// 41 | /// The context of test execution 42 | /// 43 | public readonly TestingSystem Context; 44 | 45 | 46 | /// 47 | /// Returns the name of the test instance (do not confuse with test type) 48 | /// 49 | public string Name { get { return m_Name; }} 50 | 51 | /// 52 | /// Returns the relative order of test instance execution 53 | /// 54 | public int Order { get { return m_Order; }} 55 | 56 | 57 | /// 58 | /// When set aborts the test or serializer as a whole - when capability is not supported in general, 59 | /// i.e. you can set this field for some serializer that crashes the test run, while retaining it in the config file. 60 | /// The abort message will be issued instead of a serializer run 61 | /// 62 | public string NotSupportedAbortMessage { get { return m_NotSupportedAbortMessage; }} 63 | 64 | 65 | /// 66 | /// When set, either saves the payload into the datastore or instucts the test runtime not to save it 67 | /// even though global flag is set to true. This is an override of global TestingSystem.DumpPayload 68 | /// This flag cascades down from every serializer to every individual test 69 | /// 70 | public bool? DumpPayload { get { return m_DumpPayload; } } 71 | 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Source/Serbench/Data/AbortedData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using NFX; 7 | using NFX.DataAccess.CRUD; 8 | 9 | namespace Serbench.Data 10 | { 11 | 12 | /// 13 | /// Denotes types of abort sources - from where abort was thrown 14 | /// 15 | public enum AbortedFrom{ ExceptionLeak, ConfigOther, ConfigSer, ConfigTest, BeforeRunsTest, BeforeRunsSer, Serialization, Deserialization } 16 | 17 | 18 | /// 19 | /// Represents data about aborts, gathered during test runs. 20 | /// This data is saved into App.DataStore 21 | /// 22 | public class AbortedData : TypedRow 23 | { 24 | public AbortedData() {} 25 | 26 | public AbortedData(Serializer serializer, Test test, AbortedFrom from, string msg) 27 | { 28 | SerializerType = serializer.GetType().FullName; 29 | SerializerName = serializer.Name; 30 | TestType = test.GetType().FullName; 31 | TestName = test.Name; 32 | 33 | From = from; 34 | Message = msg; 35 | } 36 | 37 | 38 | [Field] 39 | public string TestType {get; set;} 40 | 41 | [Field] 42 | public string TestName {get; set;} 43 | 44 | [Field] 45 | public string SerializerType {get; set;} 46 | 47 | [Field] 48 | public string SerializerName {get; set;} 49 | 50 | [Field] 51 | public AbortedFrom From{get; set;} 52 | 53 | [Field] 54 | public string Message{get; set;} 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /Source/Serbench/Data/DefaultDataStore.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | 8 | using NFX; 9 | using NFX.Environment; 10 | using NFX.ApplicationModel; 11 | using NFX.ServiceModel; 12 | using NFX.DataAccess; 13 | using NFX.DataAccess.CRUD; 14 | using NFX.Serialization.JSON; 15 | 16 | namespace Serbench.Data 17 | { 18 | 19 | /// 20 | /// Represents a data store that saves data as JSON records on disk 21 | /// 22 | public class DefaultDataStore : Service, IDataStoreImplementation, ITestDataStore 23 | { 24 | 25 | 26 | [Config] 27 | private string m_RootPath; 28 | 29 | private string m_RunSessionPath; 30 | 31 | private Dictionary> m_Data; 32 | 33 | #region Properties 34 | 35 | public string TargetName 36 | { 37 | get { return this.GetType().Namespace; } 38 | } 39 | 40 | [Config] 41 | public string RootPath 42 | { 43 | get{ return m_RootPath;} 44 | set 45 | { 46 | CheckServiceInactive(); 47 | m_RootPath = value; 48 | } 49 | } 50 | 51 | 52 | [Config(Default=true)] public bool OutputWeb{get; set;} 53 | [Config] public bool OutputJSON{get; set;} 54 | [Config] public bool OutputCSV{get; set;} 55 | 56 | 57 | #endregion 58 | 59 | #region Pub 60 | public void TestConnection() 61 | { 62 | throw new NotImplementedException(); 63 | } 64 | 65 | 66 | public void SaveTestData(Row data) 67 | { 68 | if (!Running) return; 69 | 70 | var key = data.GetType().Name; 71 | List lst; 72 | if (!m_Data.TryGetValue(key, out lst)) 73 | { 74 | lst = new List(); 75 | m_Data[key] = lst; 76 | } 77 | lst.Add( data ); 78 | } 79 | 80 | public void SaveTestPayloadDump(Serializer serializer, Test test, Stream dumpData) 81 | { 82 | var dir = DoCreatePayloadDumpFolder(serializer, test); 83 | 84 | var fname = Path.Combine(dir, SanitizeName( serializer.Name ) + "." + serializer.GetType().Name); 85 | 86 | using(var fs = new FileStream(fname, FileMode.Create)) 87 | dumpData.CopyTo(fs, 512 * 1024); 88 | } 89 | 90 | #endregion 91 | 92 | #region IDataStoreImplementation 93 | public StoreLogLevel LogLevel { get { return StoreLogLevel.None;} set {}} 94 | 95 | public bool InstrumentationEnabled { get{ return false;} set{}} 96 | 97 | public bool ExternalGetParameter(string name, out object value, params string[] groups) 98 | { 99 | throw new NotImplementedException(); 100 | } 101 | 102 | public IEnumerable> ExternalParameters 103 | { 104 | get { throw new NotImplementedException(); } 105 | } 106 | 107 | public IEnumerable> ExternalParametersForGroups(params string[] groups) 108 | { 109 | throw new NotImplementedException(); 110 | } 111 | 112 | public bool ExternalSetParameter(string name, object value, params string[] groups) 113 | { 114 | throw new NotImplementedException(); 115 | } 116 | #endregion 117 | 118 | #region Protected 119 | 120 | protected override void DoStart() 121 | { 122 | if (m_RootPath.IsNullOrWhiteSpace() || !Directory.Exists(m_RootPath)) 123 | throw new SerbenchException("Data store directory [{0}] not found".Args(m_RootPath)); 124 | 125 | if (!OutputWeb && !OutputJSON && !OutputCSV) 126 | throw new SerbenchException("None of 'Output-*' flags are set. Data store is not going to save anything. Set at least one of 'Output-[Web|JSON|CSV]' to true "); 127 | 128 | m_Data = new Dictionary>(StringComparer.OrdinalIgnoreCase); 129 | 130 | m_RunSessionPath = DoCreateRunSessionFolder(); 131 | } 132 | 133 | 134 | protected override void DoWaitForCompleteStop() 135 | { 136 | 137 | foreach(var kvp in m_Data.Where(kvp => kvp.Value.Count>0)) 138 | { 139 | if (OutputWeb) writeWeb(kvp); 140 | if (OutputJSON) writeJSON(kvp); 141 | if (OutputCSV) writeCSV(kvp); 142 | } 143 | } 144 | 145 | 146 | protected string SanitizeName(string name) 147 | { 148 | return new String( name.Select( c => !Char.IsLetterOrDigit(c) ? '_' : c).ToArray() ); 149 | } 150 | 151 | protected virtual string DoCreateRunSessionFolder() 152 | { 153 | var appName = App.Name; 154 | if (appName.IsNullOrWhiteSpace()) appName = "Serbench"; 155 | 156 | //sanitize app name so it can be used for directory name 157 | appName = SanitizeName( appName ); 158 | 159 | var name = Path.Combine(m_RootPath, "{0}-{1:yyyyMMddHHmm}".Args(appName, App.LocalizedTime)); 160 | 161 | var dname = name; 162 | for(var i=0; Directory.Exists(dname); i++) dname = name + i.ToString(); 163 | 164 | Directory.CreateDirectory(dname); 165 | 166 | return dname; 167 | } 168 | 169 | protected virtual string DoCreatePayloadDumpFolder(Serializer serializer, Test test) 170 | { 171 | var name = test.Name; 172 | 173 | 174 | //sanitize app name so it can be used for directory name 175 | name = SanitizeName( name ); 176 | 177 | name = Path.Combine( m_RunSessionPath , name ); 178 | 179 | var dname = name; 180 | 181 | if (!Directory.Exists(dname)) 182 | Directory.CreateDirectory(dname); 183 | 184 | return dname; 185 | } 186 | 187 | #endregion 188 | 189 | 190 | #region .pvt 191 | 192 | private void writeWeb(KeyValuePair> table) 193 | { 194 | var packager = new WebViewer.DefaultWebPackager(this, null); 195 | var targetDir = packager.Build(m_RunSessionPath); 196 | using(var fs = new FileStream(Path.Combine(targetDir, "scripts", "data-{0}.js".Args(table.Key)), FileMode.Create, FileAccess.Write, FileShare.None, 256*1024)) 197 | using(var wri = new StreamWriter(fs, Encoding.UTF8)) 198 | { 199 | wri.WriteLine("//Java script file for Serbench Web output. Table '{0}'".Args(table.Key)); 200 | wri.WriteLine("var data_{0} = ".Args(table.Key)); 201 | JSONWriter.Write(table.Value, wri, JSONWritingOptions.PrettyPrintRowsAsMap); 202 | wri.WriteLine(";"); 203 | } 204 | } 205 | 206 | 207 | private void writeJSON(KeyValuePair> table) 208 | { 209 | using(var fs = new FileStream(Path.Combine(m_RunSessionPath, table.Key+".json"), FileMode.Create, FileAccess.Write, FileShare.None, 256*1024)) 210 | JSONWriter.Write(table.Value, fs, JSONWritingOptions.PrettyPrintRowsAsMap); 211 | } 212 | 213 | 214 | private void writeCSV(KeyValuePair> table) 215 | { 216 | using(var fs = new FileStream(Path.Combine(m_RunSessionPath, table.Key+".csv"), FileMode.Create, FileAccess.Write, FileShare.None, 256*1024)) 217 | using(var sw = new StreamWriter(fs, Encoding.UTF8)) 218 | { 219 | var firstRow = table.Value[0]; 220 | sw.WriteLine( string.Join(",", firstRow.Schema.Select(fd => fd.Name))); 221 | 222 | foreach(var row in table.Value.Where( lst => lst!=null)) 223 | sw.WriteLine( string.Join(",", row.Select(v => (v==null) ? string.Empty : "\"{0}\"".Args(v.ToString().Replace("\"",@"""")) ))); 224 | } 225 | } 226 | 227 | 228 | #endregion 229 | 230 | }//class 231 | 232 | } 233 | -------------------------------------------------------------------------------- /Source/Serbench/Data/ITestDataStore.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | using NFX.DataAccess; 8 | using NFX.DataAccess.CRUD; 9 | 10 | namespace Serbench.Data 11 | { 12 | /// 13 | /// Represents a data store that SerbenchApp uses to save the data 14 | /// 15 | public interface ITestDataStore : IDataStore 16 | { 17 | 18 | /// 19 | /// Saves test data into the store 20 | /// 21 | void SaveTestData(Row data); 22 | 23 | /// 24 | /// Saves payload dump into the store 25 | /// 26 | void SaveTestPayloadDump(Serializer serializer, Test test, Stream dumpData); 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Source/Serbench/Data/SerializerInfoData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using NFX; 7 | using NFX.DataAccess.CRUD; 8 | 9 | namespace Serbench.Data 10 | { 11 | 12 | /// 13 | /// Represents data gathered during test runs. 14 | /// This data is saved into App.DataStore 15 | /// 16 | public class SerializerInfoData : TypedRow 17 | { 18 | public SerializerInfoData() {} 19 | 20 | /// 21 | /// Inits the data from attribute if one is set, or allocates empty instance if there is not attr 22 | /// 23 | public SerializerInfoData(Serializer ser) 24 | { 25 | SerializerType = ser.GetType().FullName; 26 | SerializerName = ser.Name; 27 | 28 | var t = ser.GetType(); 29 | var attr = t.GetCustomAttributes(typeof(SerializerInfo), false).FirstOrDefault() as SerializerInfo; 30 | if (attr==null) return; 31 | 32 | foreach(var pi in attr.GetType().GetProperties(System.Reflection.BindingFlags.DeclaredOnly | 33 | System.Reflection.BindingFlags.Instance | 34 | System.Reflection.BindingFlags.Public)) 35 | this[pi.Name] = pi.GetValue(attr); 36 | } 37 | 38 | 39 | [Field] 40 | public string SerializerType {get; set;} 41 | 42 | [Field] 43 | public string SerializerName {get; set;} 44 | 45 | 46 | /// 47 | /// I.e. Bin vs Text 48 | /// 49 | [Field] 50 | public SerializerFamily Family{ get; set;} 51 | 52 | /// 53 | /// What kind of decoration is needed for source types 54 | /// 55 | [Field] 56 | public MetadataRequirement MetadataRequirement{ get; set;} 57 | 58 | 59 | /// 60 | /// Who did the serializer implementation 61 | /// 62 | [Field] 63 | public string VendorName{ get; set;} 64 | 65 | /// 66 | /// License name 67 | /// 68 | [Field] 69 | public string VendorLicense{ get; set;} 70 | 71 | 72 | /// 73 | /// Where to get the code/info 74 | /// 75 | [Field] 76 | public string VendorURL{ get; set;} 77 | 78 | 79 | /// 80 | /// Name of package, .i.e. NUGET name or name of dll or address of code base 81 | /// 82 | [Field] 83 | public string VendorPackageAddress{ get; set;} 84 | 85 | 86 | /// 87 | /// Name of format, such as XML, JSON etc... 88 | /// 89 | [Field] 90 | public string FormatName{get; set;} 91 | 92 | 93 | /// 94 | /// Approximate number of lines of code in the implementation 95 | /// 96 | [Field] 97 | public int LinesOfCodeK {get; set;} 98 | 99 | 100 | /// 101 | /// Approximate number of data structures in the implementation, such as classes, intfs and structs etc. 102 | /// 103 | [Field] 104 | public int DataTypes {get; set;} 105 | 106 | 107 | /// 108 | /// How many assemblies/files the serializer is shipped in 109 | /// 110 | [Field] 111 | public int Assemblies{ get; set;} 112 | 113 | /// 114 | /// Number of references to external assemblies which are not a part of the serialization technology 115 | /// and are not a part of .NET core framework (System.* namespaces) 116 | /// 117 | [Field] 118 | public int ExternalReferences { get; set;} 119 | 120 | 121 | /// 122 | /// The size of all files which are needed to install serializer (Assemblies+ExtRefs+other files) 123 | /// 124 | [Field] 125 | public int PackageSizeKb { get; set;} 126 | 127 | } 128 | 129 | 130 | 131 | } 132 | -------------------------------------------------------------------------------- /Source/Serbench/Data/TestRunData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using NFX; 7 | using NFX.DataAccess.CRUD; 8 | 9 | namespace Serbench.Data 10 | { 11 | 12 | /// 13 | /// Represents data gathered during test runs. 14 | /// This data is saved into App.DataStore 15 | /// 16 | public class TestRunData : TypedRow 17 | { 18 | [Field] 19 | public string TestType {get; set;} 20 | 21 | [Field] 22 | public string TestName {get; set;} 23 | 24 | [Field] 25 | public string SerializerType {get; set;} 26 | 27 | [Field] 28 | public string SerializerName {get; set;} 29 | 30 | 31 | [Field] 32 | public int RunNumber{get; set;} 33 | 34 | /// 35 | /// Populated when test run crashed with exception 36 | /// 37 | [Field] 38 | public string RunException{get; set;} 39 | 40 | 41 | [Field] 42 | public bool DoGc{get; set;} 43 | 44 | 45 | 46 | [Field] 47 | public bool SerSupported {get; set;} 48 | 49 | [Field] 50 | public int SerIterations {get; set;} 51 | 52 | [Field] 53 | public int SerExceptions {get; set;} 54 | 55 | [Field] 56 | public int SerAborts {get; set;} 57 | 58 | [Field] 59 | public string FirstSerAbortMsg {get; set;} 60 | 61 | [Field] 62 | public long SerDurationMs {get; set;} 63 | 64 | [Field] 65 | public long SerDurationTicks {get; set;} 66 | 67 | [Field] 68 | public int SerOpsSec {get; set;} 69 | 70 | 71 | 72 | [Field] 73 | public int PayloadSize {get; set;} 74 | 75 | 76 | [Field] 77 | public bool DeserSupported {get; set;} 78 | 79 | [Field] 80 | public int DeserIterations {get; set;} 81 | 82 | [Field] 83 | public int DeserExceptions {get; set;} 84 | 85 | [Field] 86 | public int DeserAborts {get; set;} 87 | 88 | [Field] 89 | public string FirstDeserAbortMsg {get; set;} 90 | 91 | [Field] 92 | public long DeserDurationMs {get; set;} 93 | 94 | [Field] 95 | public long DeserDurationTicks {get; set;} 96 | 97 | [Field] 98 | public int DeserOpsSec {get; set;} 99 | 100 | } 101 | 102 | 103 | 104 | } 105 | -------------------------------------------------------------------------------- /Source/Serbench/Exceptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | 7 | namespace Serbench 8 | { 9 | /// 10 | /// Base exception thrown by the tool 11 | /// 12 | [Serializable] 13 | public class SerbenchException : Exception 14 | { 15 | public SerbenchException() 16 | { 17 | } 18 | 19 | public SerbenchException(string message) 20 | : base(message) 21 | { 22 | } 23 | 24 | public SerbenchException(string message, Exception inner) 25 | : base(message, inner) 26 | { 27 | } 28 | 29 | protected SerbenchException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) 30 | : base(info, context) 31 | { 32 | 33 | } 34 | 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Source/Serbench/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Serilaizer Benchmark Suite Core Assembly")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("IT Adapter LLC")] 12 | [assembly: AssemblyProduct("Serbench")] 13 | [assembly: AssemblyCopyright("Copyright © IT Adapter LLC 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("dc358da2-5b60-4b90-836e-de3fed044ee2")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("0.0.0.0")] 36 | [assembly: AssemblyFileVersion("0.0.0.0")] 37 | -------------------------------------------------------------------------------- /Source/Serbench/Serbench.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {2DA28C3B-6250-41CA-91A0-3A9045B473AC} 8 | Library 9 | Properties 10 | Serbench 11 | Serbench 12 | v4.5 13 | 512 14 | ..\ 15 | true 16 | 17 | 18 | true 19 | full 20 | true 21 | ..\..\Output\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | ..\..\Output\Debug\Serbench.XML 26 | 1591,0649 27 | true 28 | 29 | 30 | none 31 | true 32 | ..\..\Output\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | ..\..\Output\Release\Serbench.XML 37 | 1591 38 | 39 | 40 | 41 | ..\packages\NFX.3.1.0.1\tools\delbydate.exe 42 | True 43 | 44 | 45 | ..\packages\NFX.3.1.0.1\tools\getdatetime.exe 46 | True 47 | 48 | 49 | ..\packages\NFX.3.1.0.1\tools\gluec.exe 50 | True 51 | 52 | 53 | ..\packages\NFX.3.1.0.1\lib\MySql.Data.dll 54 | True 55 | 56 | 57 | ..\packages\NFX.3.1.0.1\lib\NFX.dll 58 | True 59 | 60 | 61 | ..\packages\NFX.3.1.0.1\lib\NFX.Erlang.dll 62 | True 63 | 64 | 65 | ..\packages\NFX.3.1.0.1\lib\NFX.MySQL.dll 66 | True 67 | 68 | 69 | ..\packages\NFX.3.1.0.1\lib\NFX.Wave.dll 70 | True 71 | 72 | 73 | ..\packages\NFX.3.1.0.1\lib\NFX.Web.dll 74 | True 75 | 76 | 77 | ..\packages\NFX.3.1.0.1\lib\NFX.WinForms.dll 78 | True 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | ..\packages\NFX.3.1.0.1\tools\TelemetryViewer.exe 89 | True 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | Master.htm 119 | 120 | 121 | OverviewTable.htm 122 | 123 | 124 | OverviewCharts.htm 125 | 126 | 127 | SerializersInfo.htm 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | Designer 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | "$(SolutionDir)packages\NFX.3.1.0.1\tools\ntc" "$(ProjectDir)\WebViewer\*.htm" -r -ext ".auto.cs" /src 162 | 163 | 170 | -------------------------------------------------------------------------------- /Source/Serbench/Serializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | 8 | using NFX; 9 | using NFX.Environment; 10 | 11 | namespace Serbench 12 | { 13 | /// 14 | /// Provides abstract base for all serializers that get tested in a suite 15 | /// 16 | public abstract class Serializer : TestArtifact 17 | { 18 | public const string CONFIG_KNOWN_TYPE_SECTION = "known-type"; 19 | 20 | 21 | protected Serializer(TestingSystem context, IConfigSectionNode conf) : base(context, conf) {} 22 | 23 | /// 24 | /// Invoked by single-threaded tests to serialize payload 25 | /// 26 | public abstract void Serialize(object root, Stream stream); 27 | 28 | 29 | /// 30 | /// Invoked by single-threaded tests to deserialize payload into an object 31 | /// 32 | public abstract object Deserialize(Stream stream); 33 | 34 | 35 | /// 36 | /// Invoked by parallel tests, the implementation must be thread-safe 37 | /// 38 | public abstract void ParallelSerialize(object root, Stream stream); 39 | 40 | /// 41 | /// Invoked by parallel tests, the implementation must be thread-safe 42 | /// 43 | public abstract object ParallelDeserialize(Stream stream); 44 | 45 | 46 | /// 47 | /// Override to perform logic before initiation of runs of the specified test against this serializer 48 | /// 49 | public virtual void BeforeRuns(Test test) 50 | { 51 | 52 | } 53 | 54 | 55 | /// 56 | /// Override to perform logic right befroe the iterations batch starts 57 | /// 58 | public virtual void BeforeSerializationIterationBatch(Test test) 59 | { 60 | 61 | } 62 | 63 | /// 64 | /// Override to perform logic right befroe the iterations batch starts 65 | /// 66 | public virtual void BeforeDeserializationIterationBatch(Test test) 67 | { 68 | 69 | } 70 | 71 | 72 | /// 73 | /// QUICKLY asserts the equality of what has deserialized with the original payload. 74 | /// Warning! This test is done as a part of time measurement, it must be very fast. 75 | /// DO NOT perform very detailed tests, just test that you have received logcally equal object back. 76 | /// No need for detailed comparison, as this is not a unit-testing framework 77 | /// 78 | /// Test that the assertion is made for 79 | /// Original serialization data root 80 | /// Deserialized data root object 81 | /// If true then the method should abort the test befoe returning 82 | /// 83 | /// True when both payloads are LOGICALLY equal, i.e. you can serialize TypedPerson but get Dictionary(string, object) of the same data 84 | /// which may be considered correct response for some serializers (that's why this method is in the serializer class) 85 | /// 86 | public virtual bool AssertPayloadEquality(Test test, object original, object deserialized, bool abort = true) 87 | { 88 | if (deserialized==null) 89 | { 90 | if (original==null) return true; 91 | if (abort) test.Abort(this, "Deserialized null from non-null original"); 92 | return false; 93 | } 94 | 95 | if (original==null) 96 | { 97 | if (abort) test.Abort(this, "Original was null but deserialized into non-null"); 98 | return false; 99 | } 100 | 101 | if (original is System.Collections.ICollection) 102 | { 103 | var orgCol = original as System.Collections.ICollection; 104 | var gotCol = deserialized as System.Collections.ICollection; 105 | 106 | if (gotCol==null || gotCol.Count!=orgCol.Count) 107 | { 108 | if (abort) test.Abort(this, "Original and deserized collections size or type mismatch"); 109 | return false; 110 | } 111 | } 112 | 113 | return true; 114 | } 115 | 116 | 117 | /// 118 | /// Reads config sections into Type[] 119 | /// 120 | protected virtual Type[] ReadKnownTypes(IConfigSectionNode conf) 121 | { 122 | try 123 | { 124 | return conf.Children.Where(cn => cn.IsSameName(CONFIG_KNOWN_TYPE_SECTION)) 125 | .Select( cn => Type.GetType( cn.AttrByName(Configuration.CONFIG_NAME_ATTR).Value, true )) 126 | .ToArray(); //force execution now 127 | } 128 | catch(Exception error) 129 | { 130 | throw new SerbenchException("{0} serializer config error in '{1}' section: {2}".Args(GetType().FullName, 131 | conf.ToLaconicString(), 132 | error.ToMessageWithType()), error); 133 | } 134 | } 135 | 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /Source/Serbench/SerializerInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | 7 | namespace Serbench 8 | { 9 | 10 | public enum SerializerFamily 11 | { 12 | Binary, 13 | Textual, 14 | Hybrid 15 | } 16 | 17 | 18 | public enum MetadataRequirement 19 | { 20 | /// 21 | /// Any type can be serialized without the need for explicit decoration 22 | /// 23 | None, 24 | 25 | /// 26 | /// The type must be decorated with attributes in code 27 | /// 28 | Attributes, 29 | 30 | /// 31 | /// The type must be described in the IDL-like language (i.e. Thrift/Protobuf/BOND etc.) 32 | /// 33 | IDL 34 | } 35 | 36 | 37 | 38 | 39 | [AttributeUsage(AttributeTargets.Class, AllowMultiple=false, Inherited=false)] 40 | public class SerializerInfo : Attribute 41 | { 42 | /// 43 | /// I.e. Bin vs Text 44 | /// 45 | public SerializerFamily Family{ get; set;} 46 | 47 | /// 48 | /// What kind of decoration is needed for source types 49 | /// 50 | public MetadataRequirement MetadataRequirement{ get; set;} 51 | 52 | 53 | /// 54 | /// Who did the serializer implementation 55 | /// 56 | public string VendorName{ get; set;} 57 | 58 | /// 59 | /// License name 60 | /// 61 | public string VendorLicense{ get; set;} 62 | 63 | 64 | /// 65 | /// Where to get the code/info 66 | /// 67 | public string VendorURL{ get; set;} 68 | 69 | 70 | /// 71 | /// Name of package, .i.e. NUGET name or name of dll or address of code base 72 | /// 73 | public string VendorPackageAddress{ get; set;} 74 | 75 | 76 | /// 77 | /// Name of format, such as XML, JSON etc... 78 | /// 79 | public string FormatName{get; set;} 80 | 81 | 82 | /// 83 | /// Approximate number of lines of code in the implementation 84 | /// 85 | public int LinesOfCodeK {get; set;} 86 | 87 | 88 | /// 89 | /// Approximate number of data structures in the implementation, such as classes, intfs and structs etc. 90 | /// 91 | public int DataTypes {get; set;} 92 | 93 | 94 | /// 95 | /// How many assemblies/files the serializer is shipped in 96 | /// 97 | public int Assemblies{ get; set;} 98 | 99 | /// 100 | /// Number of references to external assemblies which are not a part of the serialization technology 101 | /// and are not a part of .NET core framework (System.* namespaces) 102 | /// 103 | public int ExternalReferences { get; set;} 104 | 105 | 106 | /// 107 | /// The size of all files which are needed to install serializer (Assemblies+ExtRefs+other files) 108 | /// 109 | public int PackageSizeKb { get; set;} 110 | } 111 | 112 | 113 | 114 | } 115 | -------------------------------------------------------------------------------- /Source/Serbench/StockSerializers/MSBinaryFormatter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | using System.Runtime.Serialization.Formatters.Binary; 7 | 8 | 9 | using NFX.Environment; 10 | 11 | namespace Serbench.StockSerializers 12 | { 13 | /// 14 | /// Represents Microsoft's BinaryFormatter technology 15 | /// 16 | [SerializerInfo( 17 | Family = SerializerFamily.Binary, 18 | MetadataRequirement = MetadataRequirement.Attributes, 19 | VendorName = "Microsoft", 20 | VendorLicense = "Windows", 21 | VendorURL = "https://msdn.microsoft.com/en-us/library/system.runtime.serialization.formatters.binary.binaryformatter(v=vs.110).aspx", 22 | VendorPackageAddress = "mscorlib.dll", 23 | FormatName = "BinaryFormatter", 24 | LinesOfCodeK = 0, 25 | DataTypes = 0, 26 | Assemblies = 1, 27 | ExternalReferences = 0, 28 | PackageSizeKb = 0 29 | )] 30 | public class MSBinaryFormatter : Serializer 31 | { 32 | private BinaryFormatter m_Formatter; 33 | 34 | public MSBinaryFormatter(TestingSystem context, IConfigSectionNode conf) 35 | : base(context, conf) 36 | { 37 | m_Formatter = new BinaryFormatter(); 38 | 39 | } 40 | 41 | public override void Serialize(object root, Stream stream) 42 | { 43 | m_Formatter.Serialize(stream, root); 44 | } 45 | 46 | public override object Deserialize(Stream stream) 47 | { 48 | return m_Formatter.Deserialize(stream); 49 | } 50 | 51 | public override void ParallelSerialize(object root, Stream stream) 52 | { 53 | m_Formatter.Serialize(stream, root); 54 | } 55 | 56 | public override object ParallelDeserialize(Stream stream) 57 | { 58 | return m_Formatter.Deserialize(stream); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Source/Serbench/StockSerializers/MSDataContractJsonSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using System.Runtime.Serialization.Json; 5 | using NFX; 6 | using NFX.Environment; 7 | 8 | namespace Serbench.StockSerializers 9 | { 10 | /// 11 | /// Represents Microsoft's System.Runtime.Serialization.Json.DataContractJsonSerializer: 12 | /// Add: a reference: System.Runtime.Serialization.dll 13 | /// Add: a line: using System.Runtime.Serialization.Json 14 | /// 15 | [SerializerInfo( 16 | Family = SerializerFamily.Textual, 17 | MetadataRequirement = MetadataRequirement.Attributes, 18 | VendorName = "Microsoft", 19 | VendorLicense = "Windows", 20 | VendorURL = "https://msdn.microsoft.com/en-us/library/system.runtime.serialization.json.datacontractjsonserializer(v=vs.110).aspx", 21 | VendorPackageAddress = "System.Runtime.Serialization.dll", 22 | FormatName = "JSON", 23 | LinesOfCodeK = 0, 24 | DataTypes = 0, 25 | Assemblies = 1, 26 | ExternalReferences = 0, 27 | PackageSizeKb = 0 28 | )] 29 | public class MSDataContractJsonSerializer : Serializer 30 | { 31 | private DataContractJsonSerializer m_Serializer; 32 | private Type[] m_KnownTypes; 33 | 34 | public MSDataContractJsonSerializer(TestingSystem context, IConfigSectionNode conf) 35 | : base(context, conf) 36 | { 37 | m_KnownTypes = ReadKnownTypes(conf); 38 | } 39 | 40 | 41 | 42 | 43 | public override void BeforeRuns(Test test) 44 | { 45 | var primaryType = test.GetPayloadRootType(); 46 | 47 | try 48 | { 49 | m_Serializer = m_KnownTypes.Any() ? 50 | new DataContractJsonSerializer(primaryType, m_KnownTypes) : 51 | new DataContractJsonSerializer(primaryType); 52 | } 53 | catch (Exception error) 54 | { 55 | test.Abort(this, "Error making DataContractJsonSerializer instance in serializer BeforeRun() {0}. \n Did you decorate the primary known type correctly?".Args(error.ToMessageWithType())); 56 | } 57 | } 58 | 59 | 60 | public override void Serialize(object root, Stream stream) 61 | { 62 | m_Serializer.WriteObject(stream, root); 63 | } 64 | 65 | public override object Deserialize(Stream stream) 66 | { 67 | return m_Serializer.ReadObject(stream); 68 | } 69 | 70 | public override void ParallelSerialize(object root, Stream stream) 71 | { 72 | m_Serializer.WriteObject(stream, root); 73 | } 74 | 75 | public override object ParallelDeserialize(Stream stream) 76 | { 77 | return m_Serializer.ReadObject(stream); 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /Source/Serbench/StockSerializers/MSDataContractSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using System.Runtime.Serialization; 5 | using NFX; 6 | using NFX.Environment; 7 | 8 | namespace Serbench.StockSerializers 9 | { 10 | /// 11 | /// Represents Microsoft's DataContract: 12 | /// Add: a reference: System.Runtime.Serialization.dll 13 | /// Add: a line: using System.Runtime.Serialization 14 | /// 15 | [SerializerInfo( 16 | Family = SerializerFamily.Textual, 17 | MetadataRequirement = MetadataRequirement.Attributes, 18 | VendorName = "Microsoft", 19 | VendorLicense = "Windows", 20 | VendorURL = "https://msdn.microsoft.com/en-us/library/system.runtime.serialization.json.datacontractjsonserializer(v=vs.110).aspx", 21 | VendorPackageAddress = "System.Runtime.Serialization.dll", 22 | FormatName = "DataContractSerializer", 23 | LinesOfCodeK = 0, 24 | DataTypes = 0, 25 | Assemblies = 1, 26 | ExternalReferences = 0, 27 | PackageSizeKb = 0 28 | )] 29 | public class MSDataContractSerializer : Serializer 30 | { 31 | private Type[] m_KnownTypes; 32 | private DataContractSerializer m_Serializer; 33 | 34 | public MSDataContractSerializer(TestingSystem context, IConfigSectionNode conf) 35 | : base(context, conf) 36 | { 37 | m_KnownTypes = ReadKnownTypes(conf); 38 | } 39 | 40 | public override void BeforeRuns(Test test) 41 | { 42 | var primaryType = test.GetPayloadRootType(); 43 | 44 | try 45 | { 46 | m_Serializer = m_KnownTypes.Any() ? 47 | new DataContractSerializer(primaryType, m_KnownTypes) : 48 | new DataContractSerializer(primaryType); 49 | } 50 | catch (Exception error) 51 | { 52 | test.Abort(this, "Error making DataContractSerializer instance in serializer BeforeRun() {0}. \n Did you decorate the primary known type correctly?".Args(error.ToMessageWithType())); 53 | } 54 | } 55 | 56 | 57 | public override void Serialize(object root, Stream stream) 58 | { 59 | m_Serializer.WriteObject(stream, root); 60 | } 61 | 62 | public override object Deserialize(Stream stream) 63 | { 64 | return m_Serializer.ReadObject(stream); 65 | } 66 | 67 | public override void ParallelSerialize(object root, Stream stream) 68 | { 69 | m_Serializer.WriteObject(stream, root); 70 | } 71 | 72 | public override object ParallelDeserialize(Stream stream) 73 | { 74 | return m_Serializer.ReadObject(stream); 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /Source/Serbench/StockSerializers/MSJavaScriptSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using NFX; 5 | using NFX.Environment; 6 | 7 | using System.Web.Script.Serialization; 8 | 9 | namespace Serbench.StockSerializers 10 | { 11 | /// 12 | /// Represents fastJSON: 13 | /// See here https://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer%28v=vs.110%29.aspx 14 | /// Add: reference to System.Web.Extensions.dll 15 | /// Add: using System.Web.Script.Serialization; 16 | /// 17 | [SerializerInfo( 18 | Family = SerializerFamily.Textual, 19 | MetadataRequirement = MetadataRequirement.None, 20 | VendorName = "Microsoft", 21 | VendorLicense = "Windows", 22 | VendorURL = "https://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer%28v=vs.110%29.aspx", 23 | VendorPackageAddress = "System.Web.Extensions.dll", 24 | FormatName = "JSON", 25 | LinesOfCodeK = 0, 26 | DataTypes = 0, 27 | Assemblies = 1, 28 | ExternalReferences = 0, 29 | PackageSizeKb = 0 30 | )] 31 | public class MSJavaScriptSerializer : Serializer 32 | { 33 | private readonly JavaScriptSerializer m_Serializer = new JavaScriptSerializer(); 34 | private Type[] m_KnownTypes; 35 | private Type m_primaryType; 36 | 37 | public MSJavaScriptSerializer(TestingSystem context, IConfigSectionNode conf) 38 | : base(context, conf) 39 | { 40 | m_KnownTypes = ReadKnownTypes(conf); 41 | } 42 | 43 | public override void BeforeRuns(Test test) 44 | { 45 | m_primaryType = test.GetPayloadRootType(); 46 | } 47 | 48 | public override void Serialize(object root, Stream stream) 49 | { 50 | using (var sw = new StreamWriter(stream)) 51 | { 52 | sw.Write(m_Serializer.Serialize(root)); 53 | } 54 | } 55 | 56 | public override object Deserialize(Stream stream) 57 | { 58 | using (var sr = new StreamReader(stream)) 59 | { 60 | return m_Serializer.Deserialize(sr.ReadToEnd(), m_primaryType); 61 | } 62 | } 63 | 64 | public override void ParallelSerialize(object root, Stream stream) 65 | { 66 | using (var sw = new StreamWriter(stream)) 67 | { 68 | sw.Write(m_Serializer.Serialize(root)); 69 | } 70 | } 71 | 72 | public override object ParallelDeserialize(Stream stream) 73 | { 74 | using (var sr = new StreamReader(stream)) 75 | { 76 | return m_Serializer.Deserialize(sr.ReadToEnd(), m_primaryType); 77 | } 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /Source/Serbench/StockSerializers/MSXmlSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using System.Xml.Serialization; 5 | using System.Runtime.Serialization; 6 | 7 | 8 | using NFX; 9 | using NFX.Environment; 10 | 11 | namespace Serbench.StockSerializers 12 | { 13 | /// 14 | /// Represents Microsoft's XmlSerializer: 15 | /// Add: a reference: System.Xml.Serialization.dll 16 | /// Add: a line: using System.Xml.Serialization.dll 17 | /// 18 | [SerializerInfo( 19 | Family = SerializerFamily.Textual, 20 | MetadataRequirement = MetadataRequirement.None, 21 | VendorName = "Microsoft", 22 | VendorLicense = "Windows", 23 | VendorURL = "https://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer(v=vs.110).aspx", 24 | VendorPackageAddress = "System.Xml.dll, System.Xml.Serialization.dll", 25 | FormatName = "XML", 26 | LinesOfCodeK = 0, 27 | DataTypes = 0, 28 | Assemblies = 2, 29 | ExternalReferences = 0, 30 | PackageSizeKb = 4533 // 4510 + 23 // for .NET 4.0 31 | )] 32 | public class MSXmlSerializer : Serializer 33 | { 34 | private Type[] m_KnownTypes; 35 | private XmlSerializer m_Serializer; 36 | 37 | public MSXmlSerializer(TestingSystem context, IConfigSectionNode conf) 38 | : base(context, conf) 39 | { 40 | m_KnownTypes = ReadKnownTypes(conf); 41 | } 42 | 43 | public override void BeforeRuns(Test test) 44 | { 45 | var primaryType = test.GetPayloadRootType(); 46 | 47 | try 48 | { 49 | m_Serializer = m_KnownTypes.Any() ? 50 | new XmlSerializer(primaryType, m_KnownTypes) : 51 | new XmlSerializer(primaryType); 52 | } 53 | catch (Exception error) 54 | { 55 | test.Abort(this, "Error making XmlSerializer instance in serializer BeforeRun() {0}. \n Did you decorate the primary known type correctly?".Args(error.ToMessageWithType())); 56 | } 57 | } 58 | 59 | 60 | public override void Serialize(object root, Stream stream) 61 | { 62 | m_Serializer.Serialize(stream, root); 63 | } 64 | 65 | public override object Deserialize(Stream stream) 66 | { 67 | return m_Serializer.Deserialize(stream); 68 | } 69 | 70 | public override void ParallelSerialize(object root, Stream stream) 71 | { 72 | m_Serializer.Serialize(stream, root); 73 | } 74 | 75 | public override object ParallelDeserialize(Stream stream) 76 | { 77 | return m_Serializer.Deserialize(stream); 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /Source/Serbench/StockSerializers/NFXJSON.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | 8 | 9 | using NFX; 10 | using NFX.Environment; 11 | using NFX.Serialization.JSON; 12 | 13 | namespace Serbench.StockSerializers 14 | { 15 | 16 | /// 17 | /// Represents NFX.Serialization.JSON technology 18 | /// 19 | [SerializerInfo( 20 | Family = SerializerFamily.Textual, 21 | MetadataRequirement = MetadataRequirement.None, 22 | VendorName = "IT Adapter LLC", 23 | VendorLicense = "Apache 2.0 + Commercial", 24 | VendorURL = "http://itadapter.com", 25 | VendorPackageAddress = "https://github.com/aumcode/nfx", 26 | FormatName = "JSON", 27 | LinesOfCodeK = 2, 28 | DataTypes = 10, 29 | Assemblies = 1, 30 | ExternalReferences = 0, 31 | PackageSizeKb = 1777 32 | )] 33 | public class NFXJson : Serializer 34 | { 35 | public const string CONFIG_OPTIONS_SECTION = "options"; 36 | 37 | 38 | public NFXJson(TestingSystem context, IConfigSectionNode conf) : base(context, conf) 39 | { 40 | var nopt = conf[CONFIG_OPTIONS_SECTION]; 41 | if (nopt.Exists) 42 | { 43 | m_Options = new JSONWritingOptions(); 44 | m_Options.Configure(nopt); 45 | } 46 | else 47 | m_Options = JSONWritingOptions.Compact; 48 | } 49 | 50 | private JSONWritingOptions m_Options; 51 | 52 | /// 53 | /// Returns options used for writing as configured 54 | /// 55 | public JSONWritingOptions Options { get{ return m_Options;}} 56 | 57 | 58 | public override void Serialize(object root, Stream stream) 59 | { 60 | JSONWriter.Write(root, stream, m_Options); 61 | } 62 | 63 | public override object Deserialize(Stream stream) 64 | { 65 | return JSONReader.DeserializeDataObject(stream); 66 | } 67 | 68 | public override void ParallelSerialize(object root, Stream stream) 69 | { 70 | JSONWriter.Write(root, stream, m_Options); 71 | } 72 | 73 | public override object ParallelDeserialize(Stream stream) 74 | { 75 | return JSONReader.DeserializeDataObject(stream); 76 | } 77 | 78 | 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /Source/Serbench/StockSerializers/NFXSlim.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | 8 | 9 | using NFX; 10 | using NFX.Environment; 11 | using NFX.Serialization.Slim; 12 | 13 | namespace Serbench.StockSerializers 14 | { 15 | 16 | /// 17 | /// Represents NFX.Serialization.Slim technology 18 | /// 19 | [SerializerInfo( 20 | Family = SerializerFamily.Binary, 21 | MetadataRequirement = MetadataRequirement.None, 22 | VendorName = "IT Adapter LLC", 23 | VendorLicense = "Apache 2.0 + Commercial", 24 | VendorURL = "http://itadapter.com", 25 | VendorPackageAddress = "http://github.com/aumcode/nfx", 26 | FormatName = "Slim", 27 | LinesOfCodeK = 7, 28 | DataTypes = 32, 29 | Assemblies = 1, 30 | ExternalReferences = 0, 31 | PackageSizeKb = 1500 32 | )] 33 | public class NFXSlim : Serializer 34 | { 35 | 36 | public NFXSlim(TestingSystem context, IConfigSectionNode conf) : base(context, conf) 37 | { 38 | Type[] known = ReadKnownTypes(conf); 39 | 40 | //we create type registry with well-known types that serializer does not have to emit every time 41 | m_TypeRegistry = new TypeRegistry(TypeRegistry.BoxedCommonTypes, 42 | TypeRegistry.BoxedCommonNullableTypes, 43 | TypeRegistry.CommonCollectionTypes, 44 | known); 45 | 46 | m_Serializer = new SlimSerializer(m_TypeRegistry); 47 | 48 | //batching allows to remember the encountered types and hence it is a "stateful" mode 49 | //where serialization part and deserialization part retain the type registries that 50 | //get auto-updated. This mode is not thread safe 51 | if (m_Batching) 52 | { 53 | m_BatchSer = new SlimSerializer(m_TypeRegistry); 54 | m_BatchSer.TypeMode = TypeRegistryMode.Batch; 55 | 56 | m_BatchDeser = new SlimSerializer(m_TypeRegistry); 57 | m_BatchDeser.TypeMode = TypeRegistryMode.Batch; 58 | } 59 | } 60 | 61 | private TypeRegistry m_TypeRegistry; 62 | private SlimSerializer m_Serializer; 63 | private SlimSerializer m_BatchSer; 64 | private SlimSerializer m_BatchDeser; 65 | 66 | [Config] 67 | private bool m_Batching; 68 | 69 | public override void Serialize(object root, Stream stream) 70 | { 71 | if (m_Batching) 72 | m_BatchSer.Serialize(stream, root); 73 | else 74 | m_Serializer.Serialize(stream, root); 75 | } 76 | 77 | public override object Deserialize(Stream stream) 78 | { 79 | if (m_Batching) 80 | return m_BatchDeser.Deserialize(stream); 81 | 82 | return m_Serializer.Deserialize(stream); 83 | } 84 | 85 | public override void BeforeSerializationIterationBatch(Test test) 86 | { 87 | if (m_Batching && 88 | (test.SerIterations>1 || test.DeserIterations>1)) 89 | throw new SerbenchException("SlimSerializer test is not properly configured. If BATCHING=true, then test may have many runs, not many ser/deser iterations as batching retains the stream state and is not an idempotent operation"); 90 | 91 | if (m_Batching) 92 | { 93 | m_BatchSer.ResetCallBatch(); 94 | m_BatchDeser.ResetCallBatch(); 95 | } 96 | 97 | } 98 | 99 | 100 | public override void ParallelSerialize(object root, Stream stream) 101 | { 102 | //parallel mode can not use batching because it is not thread-safe 103 | m_Serializer.Serialize(stream, root); 104 | } 105 | 106 | public override object ParallelDeserialize(Stream stream) 107 | { 108 | //parallel mode can not use batching because it is not thread-safe 109 | return m_Serializer.Deserialize(stream); 110 | } 111 | 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /Source/Serbench/StockTests/ArrayTestBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | using NFX; 8 | using NFX.Environment; 9 | using NFX.Parsing; 10 | 11 | namespace Serbench.StockTests 12 | { 13 | 14 | public abstract class ArrayTestBase : Test 15 | { 16 | public const string CONFIG_DIMENSIONS_ATTR = "dimensions"; 17 | 18 | protected ArrayTestBase(TestingSystem context, IConfigSectionNode conf) : base(context, conf) 19 | { 20 | var dims = conf.AttrByName(CONFIG_DIMENSIONS_ATTR).Value; 21 | 22 | if (dims.IsNullOrWhiteSpace()) 23 | throw new SerbenchException("Array dimensions attribute '{0}' is not specified".Args(CONFIG_DIMENSIONS_ATTR)); 24 | 25 | m_Dimensions = dims.Split(',',';').Where(s => s.IsNotNullOrWhiteSpace()) 26 | .Select(s => s.AsInt()) 27 | .ToArray(); 28 | 29 | if (m_Dimensions.Length<1 || m_Dimensions.Any(d => d<=0)) 30 | throw new SerbenchException("Invalid array dimensions attribute '{0}' = '{1}'".Args(CONFIG_DIMENSIONS_ATTR, dims)); 31 | } 32 | 33 | 34 | private int[] m_Dimensions; 35 | 36 | protected Array m_Data; 37 | 38 | /// 39 | /// Returns array dimensions 40 | /// 41 | public int[] Dimensions{ get{ return m_Dimensions;}} 42 | 43 | 44 | 45 | public override Type GetPayloadRootType() 46 | { 47 | return m_Data.GetType(); 48 | } 49 | 50 | 51 | public override void PerformSerializationTest(Serializer serializer, Stream target) 52 | { 53 | serializer.Serialize(m_Data, target); 54 | } 55 | 56 | public override void PerformDeserializationTest(Serializer serializer, Stream target) 57 | { 58 | var got = serializer.Deserialize(target); 59 | serializer.AssertPayloadEquality(this, m_Data, got); 60 | } 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Source/Serbench/StockTests/ArrayTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | using NFX; 8 | using NFX.Environment; 9 | using NFX.Parsing; 10 | 11 | namespace Serbench.StockTests 12 | { 13 | 14 | 15 | public class ArrayOfInt : ArrayTestBase 16 | { 17 | public ArrayOfInt(TestingSystem context, IConfigSectionNode conf) : base(context, conf) 18 | { 19 | m_Data = Array.CreateInstance(typeof(int), Dimensions); 20 | 21 | NFX.Serialization.SerializationUtils.WalkArrayRead(m_Data, 22 | ()=> NFX.ExternalRandomGenerator.Instance.NextScaledRandomInteger(m_Min, m_Max) 23 | ); 24 | } 25 | 26 | [Config(Default=-1000)] private int m_Min; 27 | [Config(Default=+1000)] private int m_Max; 28 | 29 | } 30 | 31 | 32 | public class ArrayOfNullableInt : ArrayTestBase 33 | { 34 | public ArrayOfNullableInt(TestingSystem context, IConfigSectionNode conf) : base(context, conf) 35 | { 36 | m_Data = Array.CreateInstance(typeof(int?), Dimensions); 37 | 38 | NFX.Serialization.SerializationUtils.WalkArrayRead(m_Data, 39 | ()=> NFX.ExternalRandomGenerator.Instance.NextRandomInteger >0 ? (int?)null : NFX.ExternalRandomGenerator.Instance.NextScaledRandomInteger(m_Min, m_Max) 40 | ); 41 | } 42 | 43 | [Config(Default=-1000)] private int m_Min; 44 | [Config(Default=+1000)] private int m_Max; 45 | 46 | } 47 | 48 | 49 | public class ArrayOfString : ArrayTestBase 50 | { 51 | public ArrayOfString(TestingSystem context, IConfigSectionNode conf) : base(context, conf) 52 | { 53 | m_Data = Array.CreateInstance(typeof(string), Dimensions); 54 | 55 | NFX.Serialization.SerializationUtils.WalkArrayRead(m_Data, 56 | ()=> NFX.Parsing.NaturalTextGenerator.Generate( m_StringSize ) 57 | ); 58 | } 59 | 60 | [Config] 61 | private int m_StringSize; 62 | 63 | } 64 | 65 | 66 | public class ArrayOfDouble : ArrayTestBase 67 | { 68 | public ArrayOfDouble(TestingSystem context, IConfigSectionNode conf) : base(context, conf) 69 | { 70 | m_Data = Array.CreateInstance(typeof(double), Dimensions); 71 | 72 | NFX.Serialization.SerializationUtils.WalkArrayRead(m_Data, 73 | ()=> NFX.ExternalRandomGenerator.Instance.NextRandomDouble 74 | ); 75 | } 76 | } 77 | 78 | 79 | public class ArrayOfDecimal : ArrayTestBase 80 | { 81 | public ArrayOfDecimal(TestingSystem context, IConfigSectionNode conf) : base(context, conf) 82 | { 83 | m_Data = Array.CreateInstance(typeof(decimal), Dimensions); 84 | 85 | NFX.Serialization.SerializationUtils.WalkArrayRead(m_Data, 86 | ()=> (decimal)NFX.ExternalRandomGenerator.Instance.NextRandomDouble 87 | ); 88 | } 89 | 90 | } 91 | 92 | 93 | } 94 | -------------------------------------------------------------------------------- /Source/Serbench/StockTests/SimpleDictionaryStringObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | using NFX; 8 | using NFX.Environment; 9 | 10 | namespace Serbench.StockTests 11 | { 12 | 13 | public class SimpleDictionaryStringObject : Test 14 | { 15 | public SimpleDictionaryStringObject(TestingSystem context, IConfigSectionNode conf) : base(context, conf) 16 | { 17 | for(var i=0; i m_Dict = new Dictionary(); 29 | 30 | /// 31 | /// How many items to keep in the dictionary 32 | /// 33 | public int Count{ get{ return m_Count;}} 34 | 35 | /// 36 | /// How long should the key be 37 | /// 38 | public int KeyLength{ get{ return m_KeyLength;}} 39 | 40 | 41 | public override Type GetPayloadRootType() 42 | { 43 | return m_Dict.GetType(); 44 | } 45 | 46 | public override void PerformSerializationTest(Serializer serializer, Stream target) 47 | { 48 | serializer.Serialize(m_Dict, target); 49 | } 50 | 51 | public override void PerformDeserializationTest(Serializer serializer, Stream target) 52 | { 53 | var got = serializer.Deserialize(target); 54 | serializer.AssertPayloadEquality(this, m_Dict, got); 55 | } 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Source/Serbench/StockTests/TypicalPerson.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | using NFX; 8 | using NFX.Environment; 9 | using NFX.Parsing; 10 | 11 | namespace Serbench.StockTests 12 | { 13 | 14 | public enum MaritalStatus { Married, Divorced, HatesAll } 15 | 16 | [Serializable] 17 | public class TypicalPersonData 18 | { 19 | public string FirstName; 20 | public string MiddleName; 21 | public string LastName; 22 | public DateTime DOB; 23 | public decimal Salary; 24 | public int YearsOfService; 25 | public double CreditScore; 26 | public bool RegisteredToVote; 27 | public MaritalStatus MaritalStatus; 28 | 29 | public string Address1; 30 | public string Address2; 31 | public string AddressCity; 32 | public string AddressState; 33 | public string AddressZip; 34 | 35 | public string HomePhone; 36 | public string MobilePhone; 37 | 38 | public string EMail; 39 | 40 | public string SkypeID; 41 | public string YahooID; 42 | public string GoogleID; 43 | 44 | public string Notes; 45 | 46 | public bool? IsSmoker; 47 | public bool? IsLoving; 48 | public bool? IsLoved; 49 | public bool? IsDangerous; 50 | public bool? IsEducated; 51 | public DateTime? LastSmokingDate; 52 | 53 | public decimal? DesiredSalary; 54 | public double? ProbabilityOfSpaceFlight; 55 | 56 | public int? CurrentFriendCount; 57 | public int? DesiredFriendCount; 58 | 59 | // public object SomeObject; 60 | 61 | public static TypicalPersonData MakeRandom(bool extraData = false) 62 | { 63 | var rnd = ExternalRandomGenerator.Instance.NextRandomInteger; 64 | 65 | var data = new TypicalPersonData 66 | { 67 | FirstName = NaturalTextGenerator.GenerateFirstName(), 68 | MiddleName = ExternalRandomGenerator.Instance.NextRandomInteger > 500000000 ? NaturalTextGenerator.GenerateFirstName() : null, 69 | LastName = NaturalTextGenerator.GenerateLastName(), 70 | DOB = DateTime.Now.AddYears(ExternalRandomGenerator.Instance.NextScaledRandomInteger(-90, -1)), 71 | Salary = ExternalRandomGenerator.Instance.NextScaledRandomInteger(30,250)*1000m, 72 | YearsOfService = 25, 73 | CreditScore = 0.7562, 74 | RegisteredToVote = (DateTime.UtcNow.Ticks & 1) == 0, 75 | MaritalStatus = MaritalStatus.HatesAll, 76 | Address1 = NaturalTextGenerator.GenerateAddressLine(), 77 | Address2 = NaturalTextGenerator.GenerateAddressLine(), 78 | AddressCity = NaturalTextGenerator.GenerateCityName(), 79 | AddressState = "CA", 80 | AddressZip = "91606", 81 | HomePhone = (DateTime.UtcNow.Ticks & 1) == 0 ? "(555) 123-4567" : null, 82 | EMail = NaturalTextGenerator.GenerateEMail() 83 | }; 84 | 85 | //if (extraData) 86 | // data.SomeObject = new Dictionary 87 | // { 88 | // { "1aaaaa", TypicalPersonData.MakeRandom(false)}, { 2212, -234123}, {13000,100}, { Tuple.Create(2, false,true), "yes"}, {"4aaa",'a'}, 89 | // { "a2aaaa", TypicalPersonData.MakeRandom(false)}, { 132, TypicalPersonData.MakeRandom(false)}, {130400,100}, { Tuple.Create(3, false,true), "yes"}, {"a234aa",'a'}, 90 | // { "aa4aaa", TypicalPersonData.MakeRandom(false)}, { 412, -123}, {2100d,100L}, { Tuple.Create(4, false,TypicalPersonData.MakeRandom(false)), "yes"}, {"a5aa",'a'}, 91 | // { "aa3aaa", TypicalPersonData.MakeRandom(false)}, { 212, 0}, {1222200m,100}, { Tuple.Create(5, false,true), "yes"}, {"a43aa1",'a'}, 92 | // { "a5aaaa", TypicalPersonData.MakeRandom(false)}, { 512, new int[]{1,2,-3,4,5,-6,-1,-2,-3,-4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,60}}, 93 | // {102200,100}, { Tuple.Create(-213232d, false,false), "yes"}, {"222222222222aaa",'a'}, 94 | // }; 95 | 96 | if (0!=(rnd & (1<<32))) data.Notes = NaturalTextGenerator.Generate(45); 97 | if (0!=(rnd & (1<<31))) data.SkypeID = NaturalTextGenerator.GenerateEMail(); 98 | if (0!=(rnd & (1<<30))) data.YahooID = NaturalTextGenerator.GenerateEMail(); 99 | 100 | if (0!=(rnd & (1<<29))) data.IsSmoker = 0!=(rnd & (1<<17)); 101 | if (0!=(rnd & (1<<28))) data.IsLoving = 0!=(rnd & (1<<16)); 102 | if (0!=(rnd & (1<<27))) data.IsLoved = 0!=(rnd & (1<<15)); 103 | if (0!=(rnd & (1<<26))) data.IsDangerous = 0!=(rnd & (1<<14)); 104 | if (0!=(rnd & (1<<25))) data.IsEducated = 0!=(rnd & (1<<13)); 105 | 106 | if (0!=(rnd & (1<<24))) data.LastSmokingDate = DateTime.Now.AddYears(-10); 107 | 108 | 109 | if (0!=(rnd & (1<<23))) data.DesiredSalary = rnd / 1000m; 110 | if (0!=(rnd & (1<<22))) data.ProbabilityOfSpaceFlight = rnd / (double)int.MaxValue; 111 | 112 | if (0!=(rnd & (1<<21))) 113 | { 114 | data.CurrentFriendCount = rnd % 123; 115 | data.DesiredFriendCount = rnd % 121000; 116 | } 117 | 118 | 119 | return data; 120 | } 121 | } 122 | 123 | 124 | public class TypicalPerson : Test 125 | { 126 | public TypicalPerson(TestingSystem context, IConfigSectionNode conf) 127 | : base(context, conf) 128 | { 129 | if (m_Count < 1) m_Count = 1; 130 | 131 | for (var i = 0; i < m_Count; i++) 132 | m_Data.Add(TypicalPersonData.MakeRandom()); 133 | } 134 | 135 | 136 | [Config] 137 | private int m_Count; 138 | 139 | [Config] 140 | private bool m_List; 141 | 142 | private List m_Data = new List(); 143 | 144 | /// 145 | /// How many records in the list 146 | /// 147 | public int Count { get { return m_Count; } } 148 | 149 | 150 | /// 151 | /// Determines whether list of objects is serialized isntead of a single object 152 | /// 153 | public bool List { get { return m_List; } } 154 | 155 | 156 | public override Type GetPayloadRootType() 157 | { 158 | var root = m_List ? (object)m_Data : m_Data[0]; 159 | return root.GetType(); 160 | } 161 | 162 | 163 | public override void PerformSerializationTest(Serializer serializer, Stream target) 164 | { 165 | var root = m_List ? (object)m_Data : m_Data[0]; 166 | serializer.Serialize(root, target); 167 | } 168 | 169 | public override void PerformDeserializationTest(Serializer serializer, Stream target) 170 | { 171 | var got = serializer.Deserialize(target); 172 | 173 | var originalRoot = m_List ? (object)m_Data : m_Data[0]; 174 | serializer.AssertPayloadEquality(this, originalRoot, got); 175 | } 176 | 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /Source/Serbench/Test.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | 8 | using NFX; 9 | using NFX.Log; 10 | using NFX.Environment; 11 | 12 | namespace Serbench 13 | { 14 | /// 15 | /// Provides abstract base for all tests that get executed against the serializers 16 | /// 17 | public abstract class Test : TestArtifact 18 | { 19 | 20 | public const string CONFIG_SERIALIZER_SETUP_SECTION = "serializer-setup"; 21 | 22 | protected Test(TestingSystem context, IConfigSectionNode conf) : base(context, conf) 23 | { 24 | m_SerializerSetupConfig = conf[CONFIG_SERIALIZER_SETUP_SECTION]; 25 | } 26 | 27 | 28 | private IConfigSectionNode m_SerializerSetupConfig; 29 | 30 | [Config(Default=100)] 31 | private int m_SerIterations; 32 | 33 | [Config(Default=100)] 34 | private int m_DeserIterations; 35 | 36 | [Config(Default=1)] 37 | private int m_Runs; 38 | 39 | [Config(Default=true)] 40 | private bool m_DoGc; 41 | 42 | 43 | private bool m_Aborted; 44 | private string m_AbortMessage; 45 | 46 | 47 | 48 | /// 49 | /// Returns section which is declared under TEST for serializer setup. 50 | /// Particular serializers may elect to read some relevant values that are needed for execution of THIS test 51 | /// 52 | public IConfigSectionNode SerializerSetupConfig { get{ return m_SerializerSetupConfig;} } 53 | 54 | /// 55 | /// Returns how many serialization iterations per run the test performs 56 | /// 57 | public int SerIterations{ get{ return m_SerIterations;}} 58 | 59 | /// 60 | /// Returns how many deserialization iterations per run the test performs 61 | /// 62 | public int DeserIterations{ get{ return m_DeserIterations;}} 63 | 64 | /// 65 | /// Returns how many runs the test executes 66 | /// 67 | public int Runs{ get{ return m_Runs;}} 68 | 69 | 70 | /// 71 | /// True to do a full GC before test run execution 72 | /// 73 | public bool DoGc{ get{ return m_DoGc;}} 74 | 75 | 76 | /// 77 | /// Indicates whether the test could not proceed due to unrecoverable/impossible/unsupported condition 78 | /// 79 | public bool Aborted{ get{ return m_Aborted;}} 80 | 81 | /// 82 | /// Returns abort message (if any) for Aborted tests 83 | /// 84 | public string AbortMessage{get{ return m_AbortMessage;}} 85 | 86 | /// 87 | /// Override to perform the test logic 88 | /// 89 | public abstract void PerformSerializationTest(Serializer serializer, Stream target); 90 | 91 | /// 92 | /// Override to perform the test logic 93 | /// 94 | public abstract void PerformDeserializationTest(Serializer serializer, Stream target); 95 | 96 | /// 97 | /// Reports abort of the test due to error. This is MUCH faster than using exceptions 98 | /// 99 | public void Abort(Serializer serializer, string msg) 100 | { 101 | m_Aborted = true; 102 | m_AbortMessage = msg; 103 | 104 | App.Log.Write( new NFX.Log.Message 105 | { 106 | Type = MessageType.Error, 107 | Topic = "Test", 108 | From = "{0}('{1}').Abort({2}('{3}'))".Args(GetType().FullName, Name, serializer.GetType().FullName, serializer.Name), 109 | Text = msg ?? "Aborted" 110 | }); 111 | } 112 | 113 | internal void ResetAbort() 114 | { 115 | m_Aborted = false; 116 | m_AbortMessage = null; 117 | } 118 | 119 | 120 | /// 121 | /// Override to perform logic before initiation of runs with the specified serializer 122 | /// 123 | public virtual void BeforeRuns(Serializer serializer) 124 | { 125 | 126 | } 127 | 128 | /// 129 | /// Override to perform logic right befroe the iterations batch starts 130 | /// 131 | public virtual void BeforeSerializationIterationBatch(Serializer serializer) 132 | { 133 | 134 | } 135 | 136 | /// 137 | /// Override to perform logic right befroe the iterations batch starts 138 | /// 139 | public virtual void BeforeDeserializationIterationBatch(Serializer serializer) 140 | { 141 | 142 | } 143 | 144 | 145 | /// 146 | /// Override to return the type of payload root. This is needed for some serializers (like XML) 147 | /// 148 | public abstract Type GetPayloadRootType(); 149 | 150 | 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /Source/Serbench/WebViewer/DefaultWebPackager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | 8 | using NFX; 9 | using NFX.Environment; 10 | 11 | namespace Serbench.WebViewer 12 | { 13 | /// 14 | /// Represents a base default implementation of packager that preps fiels for web viewer (bundles java script, css and other files) 15 | /// 16 | public class DefaultWebPackager 17 | { 18 | private const string SCRIPTS_DIR = "scripts"; 19 | private const string STYLES_DIR = "styles"; 20 | private const string WEB_DIR = "web"; 21 | 22 | public DefaultWebPackager(Data.ITestDataStore data, IConfigSectionNode config) 23 | { 24 | 25 | } 26 | 27 | 28 | /// 29 | /// Builds a HTML web view package with all resources 30 | /// 31 | public string Build(string rootPath) 32 | { 33 | var dir = DoCreateTargetDir(rootPath); 34 | 35 | DoAddResources(dir); 36 | DoGeneratePages(dir); 37 | 38 | return dir; 39 | } 40 | 41 | /// 42 | /// Override to package web output into sub-folder 43 | /// 44 | protected virtual string DoCreateTargetDir(string rootPath) 45 | { 46 | var targetDir = Path.Combine(rootPath, WEB_DIR); 47 | var scriptsDir = Path.Combine(targetDir, SCRIPTS_DIR); 48 | var stylesDir = Path.Combine(targetDir, STYLES_DIR); 49 | Directory.CreateDirectory(scriptsDir); 50 | Directory.CreateDirectory(stylesDir); 51 | 52 | return targetDir; 53 | } 54 | 55 | protected virtual void DoAddResources(string path) 56 | { 57 | AddStockScriptResource(path, SCRIPTS_DIR, "jquery-1.11.0.min.js"); 58 | AddStockScriptResource(path, SCRIPTS_DIR, "wv.js"); 59 | AddStockScriptResource(path, SCRIPTS_DIR, "wv.gui.js"); 60 | AddStockScriptResource(path, SCRIPTS_DIR, "wv.chart.svg.js"); 61 | AddResourceFile(path, SCRIPTS_DIR, "serbench.js", @"scripts.serbench.js"); 62 | 63 | AddResourceFile(path, STYLES_DIR, "default.css", @"styles.default.css"); 64 | AddResourceFile(path, STYLES_DIR, "table.css", @"styles.table.css"); 65 | AddResourceFile(path, STYLES_DIR, "overview-table.css", @"styles.overview-table.css"); 66 | AddResourceFile(path, STYLES_DIR, "overview-charts.css", @"styles.overview-charts.css"); 67 | AddResourceFile(path, STYLES_DIR, "serializers-info.css", @"styles.serializers-info.css"); 68 | } 69 | 70 | protected virtual void DoGeneratePages(string path) 71 | { 72 | var target = new NFX.Templatization.StringRenderingTarget(false); 73 | new OverviewTable().Render(target, null); 74 | File.WriteAllText(Path.Combine(path, "overview-table.htm"), target.Value); 75 | 76 | target = new NFX.Templatization.StringRenderingTarget(false); 77 | new OverviewCharts().Render(target, null); 78 | File.WriteAllText(Path.Combine(path, "overview-charts.htm"), target.Value); 79 | 80 | target = new NFX.Templatization.StringRenderingTarget(false); 81 | new SerializersInfo().Render(target, null); 82 | File.WriteAllText(Path.Combine(path, "serializers-info.htm"), target.Value); 83 | } 84 | 85 | 86 | // Copies a named stock script into the output path. 87 | // 20150701 DKh: This was taking it from WAVE before, moved to local files, decided to keep stock resource in separate method 88 | protected void AddStockScriptResource(string targetDir, string subDir, string scriptName) 89 | { 90 | var destinationName = Path.Combine(targetDir, subDir, scriptName); 91 | File.WriteAllText(destinationName, typeof(DefaultWebPackager).GetText("scripts." + scriptName)); 92 | } 93 | 94 | protected void AddResourceFile(string targetDir, string subDir, string fileName, string resourceName) 95 | { 96 | var destinationName = Path.Combine(targetDir, subDir, fileName); 97 | File.WriteAllText(destinationName, typeof(DefaultWebPackager).GetText(resourceName)); 98 | } 99 | 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Source/Serbench/WebViewer/styles/overview-charts.css: -------------------------------------------------------------------------------- 1 | .seralization-bar { 2 | } 3 | 4 | .deseralization-bar { 5 | position: relative; 6 | margin-top: 10px; 7 | } 8 | 9 | .performance-small-bar { 10 | height: 10px; 11 | } 12 | 13 | .performance-bar { 14 | height: 20px; 15 | } 16 | 17 | .performance-bar-container { 18 | height: 20px; 19 | padding-bottom: 2px; 20 | background: linear-gradient(to bottom, #fafafa 0%, #ffffff 25%,#f0f0f0 100%); 21 | } 22 | 23 | .performance-bar, .performance-small-bar, .absent-serializer-test, .error-serializer-test { 24 | border-right: 1px solid rgba(10, 10, 10, 0.3); 25 | position: absolute; 26 | } 27 | 28 | .performance-label { 29 | position: relative; 30 | margin-left: 3px; 31 | } 32 | 33 | .label-header { 34 | display: inline-block; 35 | text-shadow: 1px 1px 4px #e0e0e0; 36 | color: #404040; 37 | font-size: 12px; 38 | float: left; 39 | } 40 | 41 | .label-value { 42 | font-size: 12px; 43 | float: right; 44 | } 45 | 46 | .absent-serializer-test, .error-serializer-test { 47 | height: 20px; 48 | width: 10px; 49 | } 50 | 51 | .absent-serializer-test { 52 | background-color: lightgray; 53 | } 54 | 55 | .error-serializer-test { 56 | background-color: gray; 57 | } 58 | 59 | .back-speed-bar { 60 | background: linear-gradient(to bottom, #ffffff 0%,#eaeaea 47%,#909090 50%,#f0f0f0 65%,#ffffff 100%); 61 | } 62 | 63 | .wvToast { 64 | display: block; 65 | position: fixed; 66 | background: white; 67 | border: 1px solid #808080; 68 | width: auto; 69 | padding: 8px; 70 | top: 45%; 71 | left: 50%; 72 | color: black; 73 | box-shadow: 2px 2px 10px #888888; 74 | } -------------------------------------------------------------------------------- /Source/Serbench/WebViewer/styles/overview-table.css: -------------------------------------------------------------------------------- 1 | .inner-table td, .inner-table th { 2 | border: 0; 3 | } 4 | 5 | .test-header-table { 6 | table-layout: fixed; 7 | width:300px 8 | } 9 | 10 | .supported { 11 | background: #CFFCBF; 12 | } 13 | 14 | .unsupported { 15 | background: #FDCCCC; 16 | } 17 | 18 | .absent-test { 19 | background-color: lightgray; 20 | } 21 | 22 | .stat-result { 23 | color: #f0f0f0; 24 | font-size: 17px; 25 | font-weight: bold; 26 | text-align: center; 27 | text-shadow: 1px 1px 4px black; 28 | } 29 | -------------------------------------------------------------------------------- /Source/Serbench/WebViewer/styles/serializers-info.css: -------------------------------------------------------------------------------- 1 | .serializers-table { 2 | font-size: 9pt; 3 | width: 2000px; 4 | } 5 | 6 | .vendor-link-container { 7 | text-align: center; 8 | } 9 | 10 | .vendor-link { 11 | font-size: 12px; 12 | } -------------------------------------------------------------------------------- /Source/Serbench/WebViewer/styles/table.css: -------------------------------------------------------------------------------- 1 | .main-table, .aborted-table { 2 | border-collapse: collapse; 3 | font-family: verdana; 4 | } 5 | 6 | .aborted-table { 7 | font-size: 8pt !important; 8 | } 9 | 10 | .main-table { 11 | font-size: 6pt; 12 | } 13 | 14 | .main-table td, .main-table th { 15 | border: 1px dotted #a0a0a0; 16 | font-weight: normal; 17 | } 18 | 19 | .main-table .main-table-row-header, .main-table-column-header { 20 | background-color: #e4e4e0; 21 | position: relative; 22 | padding: 3px; 23 | font-size: 10px; 24 | } 25 | 26 | .aborted-table-column-header { 27 | font-size: 8pt; 28 | font-weight: bold; 29 | } 30 | 31 | .row-header { 32 | text-align: left; 33 | } 34 | 35 | .corner-cell { 36 | border: 0 !important; 37 | } 38 | 39 | .hidden { 40 | display: none; 41 | } 42 | 43 | .empty { 44 | } 45 | 46 | .left { 47 | float: left; 48 | } 49 | 50 | .aborted-container { 51 | margin: 5px; 52 | } 53 | 54 | .aborted-header { 55 | margin: 10px; 56 | font-size: 9pt; 57 | font-weight: bold; 58 | } 59 | -------------------------------------------------------------------------------- /Source/Serbench/WebViewer/views/Master.htm: -------------------------------------------------------------------------------- 1 | # 2 | compiler 3 | { 4 | base-class-name="NFX.Templatization.Template" 5 | namespace="Serbench.WebViewer" 6 | abstract="true" 7 | summary="Master page for all pages" 8 | 9 | 10 | using{ns="NFX"} 11 | } 12 | # 13 | #[class] 14 | 15 | public virtual string Title { get {return "{0} - {1}".Args(App.Name, App.LocalizedTime); } } 16 | 17 | protected abstract void renderHeader(); 18 | protected abstract void renderBody(); 19 | protected virtual void renderFooter() { defaultFooter(); } 20 | 21 | public override bool CanReuseInstance { get { return false; } } 22 | #[render] 23 | 24 | 25 | 26 | ?[Title] 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | @[renderBody();] 43 | 44 |
45 | 46 |
47 | Aum Code Blog |  48 | Serbench Tool |  49 | NFX
50 | © 2003-2015  IT Adapter / Aum Code 51 |
52 | This site was generated by the Serbench tool / NFX Framework 53 |
54 | Generated on ?[DateTime.Now] 55 |
56 |
57 | 58 | 59 | 60 | #[defaultFooter()] 61 | 62 | -------------------------------------------------------------------------------- /Source/Serbench/WebViewer/views/SerializersInfo.htm: -------------------------------------------------------------------------------- 1 | # 2 | compiler 3 | { 4 | base-class-name="Serbench.WebViewer.Master" 5 | namespace="Serbench.WebViewer" 6 | abstract="false" 7 | summary="Aggregate information about different serializers tests" 8 | 9 | } 10 | # 11 | #[class] 12 | 13 | #[override renderHeader()] 14 | 15 | #[override renderBody()] 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 |
24 |
25 |

Serializers Info

26 |
27 |
28 | Overview Table |  29 | Overview Charts 30 |
31 |
32 | 33 |
34 | 35 |
36 | 37 | 38 | 39 | 40 | 41 | 175 | -------------------------------------------------------------------------------- /Source/Serbench/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Source/SerbenchSuite.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serbench", "Serbench\Serbench.csproj", "{2DA28C3B-6250-41CA-91A0-3A9045B473AC}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sb", "sb\sb.csproj", "{691E204E-228B-4F76-B23D-465B4B9FCEEA}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serbench.Specimens", "Serbench.Specimens\Serbench.Specimens.csproj", "{78D93D3B-2F69-4D1E-B947-C75BA098E627}" 9 | EndProject 10 | Global 11 | GlobalSection(SubversionScc) = preSolution 12 | Svn-Managed = True 13 | Manager = AnkhSVN - Subversion Support for Visual Studio 14 | EndGlobalSection 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {2DA28C3B-6250-41CA-91A0-3A9045B473AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {2DA28C3B-6250-41CA-91A0-3A9045B473AC}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {2DA28C3B-6250-41CA-91A0-3A9045B473AC}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {2DA28C3B-6250-41CA-91A0-3A9045B473AC}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {691E204E-228B-4F76-B23D-465B4B9FCEEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {691E204E-228B-4F76-B23D-465B4B9FCEEA}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {691E204E-228B-4F76-B23D-465B4B9FCEEA}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {691E204E-228B-4F76-B23D-465B4B9FCEEA}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {78D93D3B-2F69-4D1E-B947-C75BA098E627}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {78D93D3B-2F69-4D1E-B947-C75BA098E627}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {78D93D3B-2F69-4D1E-B947-C75BA098E627}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {78D93D3B-2F69-4D1E-B947-C75BA098E627}.Release|Any CPU.Build.0 = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | EndGlobal 37 | -------------------------------------------------------------------------------- /Source/sb/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Source/sb/Aum.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aumcode/serbench/4e7a0e7d64cd20c348bdfc4205691a63d61ddf76/Source/sb/Aum.ico -------------------------------------------------------------------------------- /Source/sb/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using NFX; 7 | using NFX.Log; 8 | using NFX.Log.Destinations; 9 | using NFX.Environment; 10 | using NFX.ApplicationModel; 11 | 12 | namespace sb 13 | { 14 | class Program 15 | { 16 | static void Main(string[] args) 17 | { 18 | const string CONFIG_TESTING_SYSTEM_SECTION = "testing-system"; 19 | try 20 | { 21 | ConfigSectionNode appConfig = null; 22 | if (args.Length>0) 23 | { 24 | var cname = args[0]; 25 | Console.WriteLine("Trying to load config file: '{0}'...".Args(cname)); 26 | appConfig = Configuration.ProviderLoadFromFile(cname).Root; 27 | Console.WriteLine("... loaded."); 28 | } 29 | else 30 | Console.WriteLine("Using the default config file"); 31 | 32 | using(new ServiceBaseApplication(args, appConfig)) 33 | try 34 | { 35 | App.ConfigRoot.ProcessIncludePragmas(true); 36 | 37 | using(var testing = FactoryUtils.MakeAndConfigure( 38 | App.ConfigRoot[CONFIG_TESTING_SYSTEM_SECTION], 39 | typeof(Serbench.TestingSystem) ) 40 | ) 41 | { 42 | testing.Start(); 43 | 44 | Console.WriteLine("Press to abort test execution"); 45 | while(testing.Running) 46 | { 47 | if (Console.KeyAvailable) 48 | if (Console.ReadKey().Key==ConsoleKey.Enter) break; 49 | 50 | System.Threading.Thread.Sleep(250); 51 | } 52 | } 53 | } 54 | catch(Exception loggableError)//the exception under the APP container scope can be logged 55 | { 56 | App.Log.Write( new Message 57 | { 58 | Type = MessageType.CatastrophicError, 59 | Topic = "App", 60 | From = "Program", 61 | Text = loggableError.ToMessageWithType(), 62 | Exception = loggableError 63 | }); 64 | 65 | throw; 66 | } 67 | } 68 | catch(Exception error) 69 | { 70 | Console.WriteLine(); 71 | Console.WriteLine("Exception in main()"); 72 | Console.WriteLine("-------------------"); 73 | Console.WriteLine(error.ToMessageWithType()); 74 | System.Environment.ExitCode = -1; 75 | } 76 | 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Source/sb/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("sb")] 9 | [assembly: AssemblyDescription("Serilaizer Benchmark Suite Executable")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("IT Adapter LLC")] 12 | [assembly: AssemblyProduct("sb")] 13 | [assembly: AssemblyCopyright("Copyright © IT Adapter LLC 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("5565c2a3-cae3-42cd-b9a5-7c99c11794f4")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("0.0.0.0")] 36 | [assembly: AssemblyFileVersion("0.0.0.0")] 37 | -------------------------------------------------------------------------------- /Source/sb/edi.laconf: -------------------------------------------------------------------------------- 1 | nfx 2 | { 3 | application-name="EDI X12 835" 4 | 5 | //The output of this tool will be directed into the value of SERBENCH_OUTPUT_ROOT 6 | //OS environment variable. Please set it up via Windows/ControlPanel/System.... 7 | output-root-path=$(~SERBENCH_OUTPUT_ROOT) 8 | 9 | 10 | 11 | //Configure data store where the results will be saved 12 | data-store 13 | { 14 | type="Serbench.Data.DefaultDataStore, Serbench" 15 | root-path=$(/$output-root-path) 16 | output-web=true 17 | output-json=true 18 | output-csv=true 19 | } 20 | 21 | 22 | testing-system 23 | { 24 | //type="your custom type inject your testing system if you want, by default it will use the one supplied within SerBench " 25 | 26 | 27 | tests 28 | { 29 | test { type="Serbench.Specimens.Tests.EDI_X12_835, Serbench.Specimens" name="Warmup EDI_X12_835" order=000 runs=1 ser-iterations=1 deser-iterations=1} 30 | test { type="Serbench.Specimens.Tests.EDI_X12_835, Serbench.Specimens" name="EDI_X12_835 Single" order=010 runs=1 ser-iterations=1000 deser-iterations=1000} 31 | test { type="Serbench.Specimens.Tests.EDI_X12_835, Serbench.Specimens" name="EDI_X12_835 List(100)" order=010 list = true count=100 runs=1 ser-iterations=25 deser-iterations=25} 32 | test { type="Serbench.Specimens.Tests.EDI_X12_835, Serbench.Specimens" name="EDI_X12_835 List(500)" order=020 list = true count=500 runs=1 ser-iterations=5 deser-iterations=5} 33 | 34 | }//tests 35 | 36 | 37 | serializers 38 | { 39 | // Stock serializers: they use only Microsoft .NET libraries 40 | serializer 41 | { 42 | type="Serbench.StockSerializers.MSBinaryFormatter, Serbench" 43 | name="MS.BinaryFormatter" 44 | order=10 45 | } 46 | 47 | serializer 48 | { 49 | type="Serbench.StockSerializers.MSDataContractJsonSerializer, Serbench" 50 | name="MS.DataContractJsonSerializer" 51 | order=20 52 | _include { file="knowntypes.EDI.laconf"} //include file contents 53 | } 54 | 55 | 56 | serializer 57 | { 58 | type="Serbench.StockSerializers.MSDataContractSerializer, Serbench" 59 | name="MS.DataContractSerializer" 60 | order=30 61 | _include { file="knowntypes.EDI.laconf"} //include file contents 62 | } 63 | 64 | serializer 65 | { 66 | type="Serbench.StockSerializers.MSJavaScriptSerializer, Serbench" 67 | name="MS.JavaScriptSerializer" 68 | order=40 69 | } 70 | 71 | serializer 72 | { 73 | type="Serbench.StockSerializers.MSXmlSerializer, Serbench" 74 | name="MS.XmlSerializer" 75 | _include { file="knowntypes.EDI.laconf"} //include file contents 76 | order=50 77 | } 78 | 79 | serializer 80 | { 81 | type="Serbench.StockSerializers.NFXJson, Serbench" 82 | name="NFX.Json Default" 83 | order=60 84 | } 85 | 86 | serializer 87 | { 88 | type="Serbench.StockSerializers.NFXJson, Serbench" 89 | name="NFX.Json Pretty Print" 90 | order=65 91 | options 92 | { 93 | IndentWidth = 2 94 | ObjectLineBreak = true 95 | MemberLineBreak = true 96 | SpaceSymbols = true 97 | ASCIITarget = false 98 | } 99 | } 100 | 101 | serializer 102 | { 103 | type="Serbench.StockSerializers.NFXSlim, Serbench" 104 | name="NFX.Slim Default" 105 | order=70 106 | } 107 | /* 108 | serializer 109 | { 110 | type="Serbench.StockSerializers.NFXSlim, Serbench" 111 | name="NFX.Slim Batching" 112 | order=75 113 | batching=true 114 | } 115 | */ 116 | serializer 117 | { 118 | type="Serbench.StockSerializers.NFXSlim, Serbench" 119 | name="NFX.Slim Known Types" 120 | order=78 121 | _include { file="knowntypes.EDI.laconf"} //include file contents 122 | } 123 | 124 | 125 | // Specimens serializers: they require additional libraries 126 | //------------------------------------------------------------------------------------------ 127 | serializer 128 | { 129 | type="Serbench.Specimens.Serializers.ApJsonSerializer, Serbench.Specimens" 130 | name="Apolyton.FastJson" 131 | order=110 132 | } 133 | 134 | serializer 135 | { 136 | type="Serbench.Specimens.Serializers.FastJsonSerializer, Serbench.Specimens" 137 | name="FastJson" 138 | order=130 139 | } 140 | 141 | serializer 142 | { 143 | type="Serbench.Specimens.Serializers.JilSerializer, Serbench.Specimens" 144 | name="Jil" 145 | order=150 146 | _include { file="knowntypes.EDI.laconf"} //include file contents 147 | } 148 | 149 | serializer 150 | { 151 | type="Serbench.Specimens.Serializers.JsonFxSerializer, Serbench.Specimens" 152 | name="JsonFx" 153 | order=160 154 | _include { file="knowntypes.EDI.laconf"} //include file contents 155 | } 156 | 157 | serializer 158 | { 159 | type="Serbench.Specimens.Serializers.JsonNet, Serbench.Specimens" 160 | name="Json.Net" 161 | order=170 162 | _include { file="knowntypes.EDI.laconf"} //include file contents 163 | } 164 | 165 | serializer 166 | { 167 | type="Serbench.Specimens.Serializers.MessageSharkSerializer, Serbench.Specimens" 168 | name="MessageShark" 169 | order=180 170 | _include { file="knowntypes.EDI.laconf"} //include file contents 171 | 172 | not-supported-abort-message="This serializer crashes the process without even throwing any exceptions that can be caught. This happens on List" 173 | } 174 | 175 | 176 | serializer 177 | { 178 | type="Serbench.Specimens.Serializers.MsgPackSerializer, Serbench.Specimens" 179 | name="MsgPack" 180 | order=190 181 | } 182 | 183 | 184 | serializer 185 | { 186 | type="Serbench.Specimens.Serializers.NetJSONSerializer, Serbench.Specimens" 187 | name="NetJSON" 188 | order=200 189 | 190 | not-supported-abort-message="Generates zero payloads with unrealistic speeds (millions ops/sec). Needs to be researched" 191 | } 192 | 193 | 194 | serializer 195 | { 196 | type="Serbench.Specimens.Serializers.NetSerializerSer, Serbench.Specimens" 197 | name="NetSerializer" 198 | order=210 199 | // _include { file="knowntypes.EDI.laconf"} //include file contents 200 | } 201 | 202 | 203 | serializer 204 | { 205 | type="Serbench.Specimens.Serializers.ProtoBufSerializer, Serbench.Specimens" 206 | name="ProtoBuf" 207 | order=220 208 | // _include { file="knowntypes.EDI.laconf"} //include file contents 209 | } 210 | 211 | serializer 212 | { 213 | type="Serbench.Specimens.Serializers.ServiceStackJsonSerializer, Serbench.Specimens" 214 | name="ServiceStack.JsonSerializer" 215 | order=230 216 | _include { file="knowntypes.EDI.laconf"} //include file contents 217 | } 218 | 219 | serializer 220 | { 221 | type="Serbench.Specimens.Serializers.ServiceStackTypeSerializer, Serbench.Specimens" 222 | name="ServiceStack.TypeSerializer" 223 | order=235 224 | _include { file="knowntypes.EDI.laconf"} //include file contents 225 | } 226 | 227 | serializer 228 | { 229 | type="Serbench.Specimens.Serializers.SharpSerializer, Serbench.Specimens" 230 | name="SharpSerializer" 231 | order=240 232 | 233 | not-supported-abort-message="Generates zero payloads with unrealistic speeds (millions ops/sec). Needs to be researched" 234 | } 235 | 236 | serializer 237 | { 238 | type="Serbench.Specimens.Serializers.WireSerializer, Serbench.Specimens" 239 | name="WireSerializer" 240 | order=250 241 | } 242 | } //serializers 243 | 244 | }//testing-system 245 | 246 | 247 | log 248 | { 249 | destination 250 | { 251 | type="NFX.Log.Destinations.ConsoleDestination, NFX" 252 | colored=true 253 | } 254 | 255 | destination 256 | { 257 | type="NFX.Log.Destinations.CSVFileDestination, NFX" 258 | name="SerbenchLog" 259 | path=$(/$output-root-path) 260 | name-time-format='yyyyMMdd' 261 | generate-failover-msg=false 262 | } 263 | } 264 | 265 | } -------------------------------------------------------------------------------- /Source/sb/knowntypes.Conference.laconf: -------------------------------------------------------------------------------- 1 | known-types 2 | { 3 | known-type{name="Serbench.Specimens.Tests.Conference, Serbench.Specimens"} 4 | known-type{name="System.Collections.Generic.List`1[[Serbench.Specimens.Tests.Conference, Serbench.Specimens]]"} 5 | known-type{name="Serbench.Specimens.Tests.Conference[], Serbench.Specimens"} 6 | 7 | known-type{name="Serbench.Specimens.Tests.Address, Serbench.Specimens"} 8 | 9 | known-type{name="Serbench.Specimens.Tests.Relationship, Serbench.Specimens"} 10 | known-type{name="System.Collections.Generic.List`1[[Serbench.Specimens.Tests.Relationship, Serbench.Specimens]]"} 11 | known-type{name="Serbench.Specimens.Tests.Relationship[], Serbench.Specimens"} 12 | 13 | known-type{name="Serbench.Specimens.Tests.Participant, Serbench.Specimens"} 14 | known-type{name="System.Collections.Generic.List`1[[Serbench.Specimens.Tests.Participant, Serbench.Specimens]]"} 15 | known-type{name="Serbench.Specimens.Tests.Participant[], Serbench.Specimens"} 16 | 17 | known-type{name="Serbench.Specimens.Tests.Event, Serbench.Specimens"} 18 | known-type{name="System.Collections.Generic.List`1[[Serbench.Specimens.Tests.Event, Serbench.Specimens]]"} 19 | known-type{name="Serbench.Specimens.Tests.Event[], Serbench.Specimens"} 20 | 21 | known-type{name="Serbench.Specimens.Tests.ConferenceTopic, Serbench.Specimens"} 22 | known-type{name="System.Collections.Generic.List`1[[Serbench.Specimens.Tests.ConferenceTopic, Serbench.Specimens]]"} 23 | known-type{name="Serbench.Specimens.Tests.ConferenceTopic[], Serbench.Specimens"} 24 | 25 | } -------------------------------------------------------------------------------- /Source/sb/knowntypes.EDI.laconf: -------------------------------------------------------------------------------- 1 | known-types 2 | { 3 | known-type{name="Serbench.Specimens.Tests.EDI_X12_835Data, Serbench.Specimens"} 4 | known-type{name="Serbench.Specimens.Tests.Segment, Serbench.Specimens"} 5 | known-type{name="Serbench.Specimens.Tests.AccoungInfo, Serbench.Specimens"} 6 | known-type{name="Serbench.Specimens.Tests.BPR_FinancialInformation, Serbench.Specimens"} 7 | known-type{name="Serbench.Specimens.Tests.TRN_ReassociationTraceNumber, Serbench.Specimens"} 8 | known-type{name="Serbench.Specimens.Tests.CUR_DateTime, Serbench.Specimens"} 9 | known-type{name="Serbench.Specimens.Tests.CUR_ForeignCurrencyInformation, Serbench.Specimens"} 10 | known-type{name="Serbench.Specimens.Tests.REF_SubLoop, Serbench.Specimens"} 11 | known-type{name="Serbench.Specimens.Tests.REF_Identification, Serbench.Specimens"} 12 | known-type{name="Serbench.Specimens.Tests.DTM_Date, Serbench.Specimens"} 13 | known-type{name="Serbench.Specimens.Tests.N1_SubLoop, Serbench.Specimens"} 14 | known-type{name="Serbench.Specimens.Tests.TS835_1000A_Loop, Serbench.Specimens"} 15 | known-type{name="Serbench.Specimens.Tests.TS835_1000B_Loop, Serbench.Specimens"} 16 | known-type{name="Serbench.Specimens.Tests.N1_PartyIdentification, Serbench.Specimens"} 17 | known-type{name="Serbench.Specimens.Tests.N3_PartyAddress, Serbench.Specimens"} 18 | known-type{name="Serbench.Specimens.Tests.N4_PartyCity_State_ZIPCode, Serbench.Specimens"} 19 | known-type{name="Serbench.Specimens.Tests.REF_AdditionalPartyIdentification, Serbench.Specimens"} 20 | known-type{name="Serbench.Specimens.Tests.PER_SubLoop, Serbench.Specimens"} 21 | known-type{name="Serbench.Specimens.Tests.PER_PartyContactInformation, Serbench.Specimens"} 22 | known-type{name="Serbench.Specimens.Tests.CommunicationNumber, Serbench.Specimens"} 23 | known-type{name="Serbench.Specimens.Tests.RDM_RemittanceDeliveryMethod, Serbench.Specimens"} 24 | known-type{name="Serbench.Specimens.Tests.TS835_2000_Loop, Serbench.Specimens"} 25 | known-type{name="Serbench.Specimens.Tests.LX_HeaderNumber, Serbench.Specimens"} 26 | known-type{name="Serbench.Specimens.Tests.TS3_ProviderSummaryInformation, Serbench.Specimens"} 27 | known-type{name="Serbench.Specimens.Tests.TS2_ProviderSupplementalSummaryInformation, Serbench.Specimens"} 28 | known-type{name="Serbench.Specimens.Tests.TS835_2100_Loop, Serbench.Specimens"} 29 | known-type{name="Serbench.Specimens.Tests.CLP_ClaimPaymentInformation, Serbench.Specimens"} 30 | known-type{name="Serbench.Specimens.Tests.CAS_Adjustment, Serbench.Specimens"} 31 | known-type{name="Serbench.Specimens.Tests.ClaimAdjustment, Serbench.Specimens"} 32 | known-type{name="Serbench.Specimens.Tests.NM1_SubLoop, Serbench.Specimens"} 33 | known-type{name="Serbench.Specimens.Tests.NM1_PartyName, Serbench.Specimens"} 34 | known-type{name="Serbench.Specimens.Tests.MIA_InpatientAdjudicationInformation, Serbench.Specimens"} 35 | known-type{name="Serbench.Specimens.Tests.MOA_OutpatientAdjudicationInformation, Serbench.Specimens"} 36 | known-type{name="Serbench.Specimens.Tests.DTM_SubLoop, Serbench.Specimens"} 37 | known-type{name="Serbench.Specimens.Tests.PER_ClaimContactInformation, Serbench.Specimens"} 38 | known-type{name="Serbench.Specimens.Tests.AMT_ClaimSupplementalInformation, Serbench.Specimens"} 39 | known-type{name="Serbench.Specimens.Tests.QTY_ClaimSupplementalInformationQuantity, Serbench.Specimens"} 40 | known-type{name="Serbench.Specimens.Tests.TS835_2110_Loop, Serbench.Specimens"} 41 | known-type{name="Serbench.Specimens.Tests.SVC_ServicePaymentInformation, Serbench.Specimens"} 42 | known-type{name="Serbench.Specimens.Tests.AMT_ServiceSupplementalAmount, Serbench.Specimens"} 43 | known-type{name="Serbench.Specimens.Tests.QTY_ServiceSupplementalQuantity, Serbench.Specimens"} 44 | known-type{name="Serbench.Specimens.Tests.LQ_HealthCareRemarkCode, Serbench.Specimens"} 45 | known-type{name="Serbench.Specimens.Tests.PLB_ProviderAdjustment, Serbench.Specimens"} 46 | known-type{name="Serbench.Specimens.Tests.MonetaryAmountAdjustment, Serbench.Specimens"} 47 | } -------------------------------------------------------------------------------- /Source/sb/knowntypes.SpecimensTypicalPerson.laconf: -------------------------------------------------------------------------------- 1 | known-types 2 | { 3 | known-type{name="Serbench.Specimens.Tests.TypicalPersonData, Serbench.Specimens"} 4 | known-type{name="System.Collections.Generic.List`1[[Serbench.Specimens.Tests.TypicalPersonData, Serbench.Specimens]]"} 5 | known-type{name="Serbench.Specimens.Tests.TypicalPersonData[], Serbench.Specimens"} 6 | } -------------------------------------------------------------------------------- /Source/sb/knowntypes.StockTypicalPerson.laconf: -------------------------------------------------------------------------------- 1 | known-types 2 | { 3 | known-type{name="Serbench.StockTests.TypicalPersonData"} 4 | known-type{name="System.Collections.Generic.List`1[[Serbench.StockTests.TypicalPersonData, Serbench]]"} 5 | known-type{name="Serbench.StockTests.TypicalPersonData[]"} 6 | } -------------------------------------------------------------------------------- /Source/sb/knowntypes.Telemetry.laconf: -------------------------------------------------------------------------------- 1 | known-types 2 | { 3 | known-type{name="Serbench.Specimens.Tests.TelemetryData, Serbench.Specimens"} 4 | } -------------------------------------------------------------------------------- /Source/sb/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Source/sb/sb.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {691E204E-228B-4F76-B23D-465B4B9FCEEA} 8 | Exe 9 | Properties 10 | sb 11 | sb 12 | v4.5 13 | 512 14 | Svn 15 | Svn 16 | Svn 17 | SubversionScc 18 | ..\ 19 | true 20 | 21 | 22 | AnyCPU 23 | true 24 | full 25 | true 26 | ..\..\Output\Debug\ 27 | DEBUG;TRACE 28 | prompt 29 | 4 30 | false 31 | true 32 | 33 | 34 | 35 | 36 | AnyCPU 37 | none 38 | true 39 | ..\..\Output\Release\ 40 | TRACE 41 | prompt 42 | 4 43 | false 44 | 45 | 46 | Aum.ico 47 | 48 | 49 | 50 | ..\packages\NFX.3.1.0.1\tools\delbydate.exe 51 | True 52 | 53 | 54 | ..\packages\NFX.3.1.0.1\tools\getdatetime.exe 55 | True 56 | 57 | 58 | ..\packages\NFX.3.1.0.1\tools\gluec.exe 59 | True 60 | 61 | 62 | False 63 | ..\packages\NFX.3.1.0.1\lib\NFX.dll 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | ..\packages\NFX.3.1.0.1\tools\TelemetryViewer.exe 73 | True 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | Always 84 | 85 | 86 | Always 87 | 88 | 89 | Always 90 | 91 | 92 | Always 93 | 94 | 95 | Always 96 | 97 | 98 | 99 | Always 100 | 101 | 102 | Always 103 | 104 | 105 | Always 106 | 107 | 108 | Always 109 | 110 | 111 | Always 112 | 113 | 114 | Always 115 | 116 | 117 | Always 118 | 119 | 120 | Always 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | {2da28c3b-6250-41ca-91a0-3a9045b473ac} 129 | Serbench 130 | 131 | 132 | 133 | 140 | -------------------------------------------------------------------------------- /Source/sb/stock.typicalperson.laconf: -------------------------------------------------------------------------------- 1 | nfx 2 | { 3 | application-name="Typical Person" 4 | 5 | //The output of this tool will be directed into the value of SERBENCH_OUTPUT_ROOT 6 | //OS environment variable. Please set it up via Windows/ControlPanel/System.... 7 | output-root-path=$(~SERBENCH_OUTPUT_ROOT) 8 | 9 | 10 | 11 | //Configure data store where the results will be saved 12 | data-store 13 | { 14 | type="Serbench.Data.DefaultDataStore, Serbench" 15 | root-path=$(/$output-root-path) 16 | output-web=true 17 | output-json=true 18 | output-csv=true 19 | } 20 | 21 | 22 | testing-system 23 | { 24 | //type="your custom type inject your testing system if you want, by default it will use the one supplied within SerBench " 25 | 26 | 27 | tests 28 | { 29 | test { type="Serbench.StockTests.TypicalPerson, Serbench" name="Warmup TypicalPerson(single)" order=000 list=false runs=1 ser-iterations=1 deser-iterations=1} 30 | test { type="Serbench.StockTests.TypicalPerson, Serbench" name="Warmup TypicalPerson(list)" order=001 list=true count=1 runs=1 ser-iterations=1 deser-iterations=1} 31 | 32 | test { type="Serbench.StockTests.TypicalPerson, Serbench" name="TypicalPerson(single)" order=100 list=false runs=1 ser-iterations=75000 deser-iterations=75000} 33 | test { type="Serbench.StockTests.TypicalPerson, Serbench" name="TypicalPerson(list, 100)" order=200 list=true count=100 runs=1 ser-iterations=2000 deser-iterations=2000} 34 | }//tests 35 | 36 | 37 | serializers 38 | { 39 | // Stock serializers: they use only Microsoft .NET libraries 40 | 41 | serializer 42 | { 43 | type="Serbench.StockSerializers.MSBinaryFormatter, Serbench" 44 | name="MS.BinaryFormatter" 45 | order=10 46 | } 47 | 48 | serializer 49 | { 50 | type="Serbench.StockSerializers.MSDataContractJsonSerializer, Serbench" 51 | name="MS.DataContractJsonSerializer" 52 | order=20 53 | _include { file="knowntypes.StockTypicalPerson.laconf"} //include file contents 54 | } 55 | 56 | 57 | serializer 58 | { 59 | type="Serbench.StockSerializers.MSDataContractSerializer, Serbench" 60 | name="MS.DataContractSerializer" 61 | order=30 62 | _include { file="knowntypes.StockTypicalPerson.laconf"} //include file contents 63 | } 64 | 65 | serializer 66 | { 67 | type="Serbench.StockSerializers.MSJavaScriptSerializer, Serbench" 68 | name="MSJavaScriptSerializer" 69 | order=40 70 | } 71 | 72 | serializer 73 | { 74 | type="Serbench.StockSerializers.MSXmlSerializer, Serbench" 75 | name="MSXmlSerializer" 76 | _include { file="knowntypes.StockTypicalPerson.laconf"} //include file contents 77 | order=50 78 | } 79 | 80 | serializer 81 | { 82 | type="Serbench.StockSerializers.NFXJson, Serbench" 83 | name="NFX.Json Default" 84 | order=60 85 | } 86 | 87 | serializer 88 | { 89 | type="Serbench.StockSerializers.NFXJson, Serbench" 90 | name="NFX.Json Pretty Print" 91 | order=65 92 | options 93 | { 94 | IndentWidth = 2 95 | ObjectLineBreak = true 96 | MemberLineBreak = true 97 | SpaceSymbols = true 98 | ASCIITarget = false 99 | } 100 | } 101 | 102 | serializer 103 | { 104 | type="Serbench.StockSerializers.NFXSlim, Serbench" 105 | name="NFX.Slim Default" 106 | order=70 107 | } 108 | 109 | /* 110 | serializer 111 | { 112 | type="Serbench.StockSerializers.NFXSlim, Serbench" 113 | name="NFX.Slim Batching" 114 | order=75 115 | batching=true 116 | } 117 | */ 118 | serializer 119 | { 120 | type="Serbench.StockSerializers.NFXSlim, Serbench" 121 | name="NFX.Slim Known Types" 122 | order=78 123 | _include { file="knowntypes.StockTypicalPerson.laconf"} //include file contents 124 | } 125 | 126 | 127 | // Specimens serializers: they require additional libraries 128 | //------------------------------------------------------------------------------------------ 129 | serializer 130 | { 131 | type="Serbench.Specimens.Serializers.ApJsonSerializer, Serbench.Specimens" 132 | name="Apolyton.FastJson" 133 | order=110 134 | } 135 | 136 | serializer 137 | { 138 | type="Serbench.Specimens.Serializers.FastJsonSerializer, Serbench.Specimens" 139 | name="FastJson" 140 | order=130 141 | } 142 | 143 | serializer 144 | { 145 | type="Serbench.Specimens.Serializers.JilSerializer, Serbench.Specimens" 146 | name="Jil" 147 | order=150 148 | _include { file="knowntypes.StockTypicalPerson.laconf"} //include file contents 149 | } 150 | 151 | serializer 152 | { 153 | type="Serbench.Specimens.Serializers.JsonFxSerializer, Serbench.Specimens" 154 | name="JsonFx" 155 | order=160 156 | _include { file="knowntypes.StockTypicalPerson.laconf"} //include file contents 157 | } 158 | 159 | serializer 160 | { 161 | type="Serbench.Specimens.Serializers.JsonNet, Serbench.Specimens" 162 | name="Json.Net" 163 | order=170 164 | _include { file="knowntypes.StockTypicalPerson.laconf"} //include file contents 165 | } 166 | 167 | serializer 168 | { 169 | type="Serbench.Specimens.Serializers.MessageSharkSerializer, Serbench.Specimens" 170 | name="MessageShark" 171 | order=180 172 | _include { file="knowntypes.StockTypicalPerson.laconf"} //include file contents 173 | } 174 | 175 | 176 | // TODO: hungs up the application. Ctrl-C works. 177 | serializer 178 | { 179 | type="Serbench.Specimens.Serializers.MsgPackSerializer, Serbench.Specimens" 180 | name="MsgPack" 181 | order=190 182 | } 183 | 184 | 185 | serializer 186 | { 187 | type="Serbench.Specimens.Serializers.NetJSONSerializer, Serbench.Specimens" 188 | name="NetJSONS" 189 | order=200 190 | } 191 | 192 | 193 | serializer 194 | { 195 | type="Serbench.Specimens.Serializers.NetSerializerSer, Serbench.Specimens" 196 | name="NetSerializer" 197 | order=210 198 | // _include { file="knowntypes.StockTypicalPerson.laconf"} //include file contents 199 | } 200 | 201 | 202 | serializer 203 | { 204 | type="Serbench.Specimens.Serializers.ProtoBufSerializer, Serbench.Specimens" 205 | name="ProtoBuf" 206 | order=220 207 | // _include { file="knowntypes.StockTypicalPerson.laconf"} //include file contents 208 | } 209 | 210 | serializer 211 | { 212 | type="Serbench.Specimens.Serializers.ServiceStackJsonSerializer, Serbench.Specimens" 213 | name="ServiceStack.JsonSerializer" 214 | order=230 215 | _include { file="knowntypes.StockTypicalPerson.laconf"} //include file contents 216 | } 217 | 218 | serializer 219 | { 220 | type="Serbench.Specimens.Serializers.ServiceStackTypeSerializer, Serbench.Specimens" 221 | name="ServiceStack.TypeSerializer" 222 | order=235 223 | _include { file="knowntypes.StockTypicalPerson.laconf"} //include file contents 224 | } 225 | 226 | 227 | serializer 228 | { 229 | type="Serbench.Specimens.Serializers.SharpSerializer, Serbench.Specimens" 230 | name="SharpSerializer" 231 | order=240 232 | } 233 | 234 | serializer 235 | { 236 | type="Serbench.Specimens.Serializers.WireSerializer, Serbench.Specimens" 237 | name="WireSerializer" 238 | order=250 239 | } 240 | } //serializers 241 | 242 | }//testing-system 243 | 244 | 245 | log 246 | { 247 | destination 248 | { 249 | type="NFX.Log.Destinations.ConsoleDestination, NFX" 250 | colored=true 251 | } 252 | 253 | destination 254 | { 255 | type="NFX.Log.Destinations.CSVFileDestination, NFX" 256 | name="SerbenchLog" 257 | path=$(/$output-root-path) 258 | name-time-format='yyyyMMdd' 259 | generate-failover-msg=false 260 | } 261 | } 262 | 263 | } -------------------------------------------------------------------------------- /Source/sb/telemetry.laconf: -------------------------------------------------------------------------------- 1 | nfx 2 | { 3 | application-name="Telemetry" 4 | 5 | //The output of this tool will be directed into the value of SERBENCH_OUTPUT_ROOT 6 | //OS environment variable. Please set it up via Windows/ControlPanel/System.... 7 | output-root-path=$(~SERBENCH_OUTPUT_ROOT) 8 | 9 | 10 | //Configure data store where the results will be saved 11 | data-store 12 | { 13 | type="Serbench.Data.DefaultDataStore, Serbench" 14 | root-path=$(/$output-root-path) 15 | output-web=true 16 | output-json=true 17 | output-csv=true 18 | } 19 | 20 | 21 | testing-system 22 | { 23 | //type="your custom type inject your testing system if you want, by default it will use the one supplied within SerBench " 24 | 25 | 26 | tests 27 | { 28 | test { type="Serbench.Specimens.Tests.Telemetry, Serbench.Specimens" name="Warmup Telemetry" order=000 runs=1 ser-iterations=1 deser-iterations=1} 29 | test { type="Serbench.Specimens.Tests.Telemetry, Serbench.Specimens" name="Telemetry" order=010 runs=1 ser-iterations=2500 deser-iterations=2500} 30 | }//tests 31 | 32 | 33 | serializers 34 | { 35 | // Stock serializers: they use only Microsoft .NET libraries 36 | 37 | serializer 38 | { 39 | type="Serbench.StockSerializers.MSBinaryFormatter, Serbench" 40 | name="MS.BinaryFormatter" 41 | order=10 42 | } 43 | 44 | serializer 45 | { 46 | type="Serbench.StockSerializers.MSDataContractJsonSerializer, Serbench" 47 | name="MS.DataContractJsonSerializer" 48 | order=20 49 | _include { file="knowntypes.Telemetry.laconf"} //include file contents 50 | } 51 | 52 | 53 | serializer 54 | { 55 | type="Serbench.StockSerializers.MSDataContractSerializer, Serbench" 56 | name="MS.DataContractSerializer" 57 | order=30 58 | _include { file="knowntypes.Telemetry.laconf"} //include file contents 59 | } 60 | 61 | serializer 62 | { 63 | type="Serbench.StockSerializers.MSJavaScriptSerializer, Serbench" 64 | name="MS.JavaScriptSerializer" 65 | order=40 66 | } 67 | 68 | serializer 69 | { 70 | type="Serbench.StockSerializers.MSXmlSerializer, Serbench" 71 | name="MS.XmlSerializer" 72 | _include { file="knowntypes.Telemetry.laconf"} //include file contents 73 | order=50 74 | } 75 | 76 | serializer 77 | { 78 | type="Serbench.StockSerializers.NFXJson, Serbench" 79 | name="NFX.Json Default" 80 | order=60 81 | } 82 | 83 | serializer 84 | { 85 | type="Serbench.StockSerializers.NFXJson, Serbench" 86 | name="NFX.Json Pretty Print" 87 | order=65 88 | options 89 | { 90 | IndentWidth = 2 91 | ObjectLineBreak = true 92 | MemberLineBreak = true 93 | SpaceSymbols = true 94 | ASCIITarget = false 95 | } 96 | } 97 | 98 | serializer 99 | { 100 | type="Serbench.StockSerializers.NFXSlim, Serbench" 101 | name="NFX.Slim Default" 102 | order=70 103 | } 104 | 105 | /* 106 | serializer 107 | { 108 | type="Serbench.StockSerializers.NFXSlim, Serbench" 109 | name="NFX.Slim Batching" 110 | order=75 111 | batching=true 112 | } 113 | */ 114 | serializer 115 | { 116 | type="Serbench.StockSerializers.NFXSlim, Serbench" 117 | name="NFX.Slim Known Types" 118 | order=78 119 | _include { file="knowntypes.Telemetry.laconf"} //include file contents 120 | } 121 | 122 | 123 | // Specimens serializers: they require additional libraries 124 | //------------------------------------------------------------------------------------------ 125 | serializer 126 | { 127 | type="Serbench.Specimens.Serializers.ApJsonSerializer, Serbench.Specimens" 128 | name="Apolyton.FastJson" 129 | order=110 130 | } 131 | 132 | serializer 133 | { 134 | type="Serbench.Specimens.Serializers.FastJsonSerializer, Serbench.Specimens" 135 | name="FastJson" 136 | order=130 137 | } 138 | 139 | serializer 140 | { 141 | type="Serbench.Specimens.Serializers.JilSerializer, Serbench.Specimens" 142 | name="Jil" 143 | order=150 144 | _include { file="knowntypes.Telemetry.laconf"} //include file contents 145 | } 146 | 147 | serializer 148 | { 149 | type="Serbench.Specimens.Serializers.JsonFxSerializer, Serbench.Specimens" 150 | name="JsonFx" 151 | order=160 152 | _include { file="knowntypes.Telemetry.laconf"} //include file contents 153 | } 154 | 155 | serializer 156 | { 157 | type="Serbench.Specimens.Serializers.JsonNet, Serbench.Specimens" 158 | name="Json.Net" 159 | order=170 160 | _include { file="knowntypes.Telemetry.laconf"} //include file contents 161 | } 162 | 163 | serializer 164 | { 165 | type="Serbench.Specimens.Serializers.MessageSharkSerializer, Serbench.Specimens" 166 | name="MessageShark" 167 | order=180 168 | _include { file="knowntypes.Telemetry.laconf"} //include file contents 169 | } 170 | 171 | 172 | // TODO: hungs up the application. Ctrl-C works. 173 | serializer 174 | { 175 | type="Serbench.Specimens.Serializers.MsgPackSerializer, Serbench.Specimens" 176 | name="MsgPack" 177 | order=190 178 | } 179 | 180 | 181 | serializer 182 | { 183 | type="Serbench.Specimens.Serializers.NetJSONSerializer, Serbench.Specimens" 184 | name="NetJSONS" 185 | order=200 186 | } 187 | 188 | 189 | serializer 190 | { 191 | type="Serbench.Specimens.Serializers.NetSerializerSer, Serbench.Specimens" 192 | name="NetSerializer" 193 | order=210 194 | // _include { file="knowntypes.Telemetry.laconf"} //include file contents 195 | } 196 | 197 | 198 | serializer 199 | { 200 | type="Serbench.Specimens.Serializers.ProtoBufSerializer, Serbench.Specimens" 201 | name="ProtoBuf" 202 | order=220 203 | // _include { file="knowntypes.Telemetry.laconf"} //include file contents 204 | } 205 | 206 | serializer 207 | { 208 | type="Serbench.Specimens.Serializers.ServiceStackJsonSerializer, Serbench.Specimens" 209 | name="ServiceStack.JsonSerializer" 210 | order=230 211 | _include { file="knowntypes.Telemetry.laconf"} //include file contents 212 | } 213 | 214 | serializer 215 | { 216 | type="Serbench.Specimens.Serializers.ServiceStackTypeSerializer, Serbench.Specimens" 217 | name="ServiceStack.TypeSerializer" 218 | order=235 219 | _include { file="knowntypes.Telemetry.laconf"} //include file contents 220 | } 221 | 222 | serializer 223 | { 224 | type="Serbench.Specimens.Serializers.SharpSerializer, Serbench.Specimens" 225 | name="SharpSerializer" 226 | order=240 227 | } 228 | 229 | serializer 230 | { 231 | type="Serbench.Specimens.Serializers.BondSerializer, Serbench.Specimens" 232 | name="MS.Bond" 233 | _include { file="knowntypes.Telemetry.laconf"} //include file contents 234 | order=245 235 | } 236 | 237 | serializer 238 | { 239 | type="Serbench.Specimens.Serializers.WireSerializer, Serbench.Specimens" 240 | name="WireSerializer" 241 | order=250 242 | } 243 | } //serializers 244 | 245 | }//testing-system 246 | 247 | 248 | log 249 | { 250 | destination 251 | { 252 | type="NFX.Log.Destinations.ConsoleDestination, NFX" 253 | colored=true 254 | } 255 | 256 | destination 257 | { 258 | type="NFX.Log.Destinations.CSVFileDestination, NFX" 259 | name="SerbenchLog" 260 | path=$(/$output-root-path) 261 | name-time-format='yyyyMMdd' 262 | generate-failover-msg=false 263 | } 264 | } 265 | 266 | } --------------------------------------------------------------------------------