-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Performance optimizations and support nullable types and honor NullIm…
…plication specification
- Loading branch information
1 parent
d765aea
commit 47e13a9
Showing
16 changed files
with
424 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>10.0.0</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{F9E4A0A8-0657-461D-AAD7-E78B97EBE22E}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>PerfTest</RootNamespace> | ||
<AssemblyName>PerfTest</AssemblyName> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug</OutputPath> | ||
<DefineConstants>DEBUG;COEXIST_CLI</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<Externalconsole>true</Externalconsole> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release</OutputPath> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<Externalconsole>true</Externalconsole> | ||
<DefineConstants>COEXIST_CLI</DefineConstants> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="MsgPack"> | ||
<HintPath>..\lib\MsgPack.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="..\msgpack-sharp-tests\AnimalMessage.cs"> | ||
<Link>AnimalMessage.cs</Link> | ||
</Compile> | ||
<Compile Include="..\msgpack-sharp-tests\AnimalColor.cs"> | ||
<Link>AnimalColor.cs</Link> | ||
</Compile> | ||
<Compile Include="..\msgpack-sharp-tests\Habitat.cs"> | ||
<Link>Habitat.cs</Link> | ||
</Compile> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | ||
<ItemGroup> | ||
<ProjectReference Include="..\msgpack-sharp\msgpack-sharp.csproj"> | ||
<Project>{765753B8-A9EB-4DD1-B0F0-D478E54E9ACB}</Project> | ||
<Name>msgpack-sharp</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using System; | ||
using scopely.msgpacksharp.tests; | ||
using scopely.msgpacksharp; | ||
using System.IO; | ||
|
||
namespace PerfTest | ||
{ | ||
class MainClass | ||
{ | ||
private const int numMessagesToTest = 10000; | ||
private static AnimalMessage testMsg; | ||
|
||
public static void Main(string[] args) | ||
{ | ||
testMsg = AnimalMessage.CreateTestMessage(); | ||
|
||
// Warm-up for both | ||
//TestCli(); | ||
//TestMsgPackSharp(); | ||
|
||
// Actual tests... | ||
TimeTest(TestCli, "Serialize and Deserialize with Official CLI"); | ||
TimeTest(TestMsgPackSharp, "Serialize and Deserialize with MsgPack-Sharp"); | ||
} | ||
|
||
private static void TimeTest(Action test, string testName) | ||
{ | ||
DateTime start = DateTime.Now; | ||
test(); | ||
DateTime end = DateTime.Now; | ||
TimeSpan diff = end.Subtract(start); | ||
double numPerSecond = (double)numMessagesToTest / diff.TotalSeconds; | ||
Console.Out.WriteLine(testName + ":\n\t{0:n0} messages per second", numPerSecond); | ||
} | ||
|
||
private static void TestMsgPackSharp() | ||
{ | ||
for (int i = 0; i < numMessagesToTest; i++) | ||
{ | ||
byte[] buffer = MsgPackSerializer.SerializeObject(testMsg); | ||
#pragma warning disable 0219 | ||
var deserialized = MsgPackSerializer.Deserialize<AnimalMessage>(buffer); | ||
#pragma warning restore 0219 | ||
} | ||
} | ||
|
||
private static void TestCli() | ||
{ | ||
var serializer = MsgPack.Serialization.MessagePackSerializer.Create<AnimalMessage>(); | ||
for (int i = 0; i < numMessagesToTest; i++) | ||
{ | ||
byte[] buffer = null; | ||
using (MemoryStream outStream = new MemoryStream()) | ||
{ | ||
serializer.Pack(outStream, testMsg); | ||
buffer = outStream.ToArray(); | ||
} | ||
using (MemoryStream stream = new MemoryStream(buffer)) | ||
{ | ||
#pragma warning disable 0219 | ||
var deserialized = serializer.Unpack(stream); | ||
#pragma warning restore 0219 | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
|
||
// Information about this assembly is defined by the following attributes. | ||
// Change them to the values specific to your project. | ||
[assembly: AssemblyTitle("PerfTest")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("")] | ||
[assembly: AssemblyCopyright("Clay")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". | ||
// The form "{Major}.{Minor}.*" will automatically update the build and revision, | ||
// and "{Major}.{Minor}.{Build}.*" will update just the revision. | ||
[assembly: AssemblyVersion("1.0.*")] | ||
// The following attributes are used to specify the signing key for the assembly, | ||
// if desired. See the Mono documentation for more information about signing. | ||
//[assembly: AssemblyDelaySign(false)] | ||
//[assembly: AssemblyKeyFile("")] | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.