Commit 81efcf25 authored by Jon Skeet's avatar Jon Skeet

Removed accidental addition of test directory.

parent 62b3d31f
namespace Google.ProtocolBuffers.Bcl {
public partial class Decimal {
public decimal ToDecimal() {
if (Lo == 0 && Hi == 0) return decimal.Zero;
int lo = (int)(Lo & 0xFFFFFFFFL),
mid = (int)((Lo >> 32) & 0xFFFFFFFFL),
hi = (int)Hi;
bool isNeg = (SignScale & 0x0001) == 0x0001;
byte scale = (byte)((SignScale & 0x01FE) >> 1);
return new decimal(lo, mid, hi, isNeg, scale);
}
}
}
This diff is collapsed.
This diff is collapsed.
using System;
using System.Diagnostics;
using System.IO;
namespace TestBed {
// Avoid using the .NET 3.5 System.Action delegate
delegate void Action();
class Program {
private static readonly TimeSpan TimeLimit = TimeSpan.FromMinutes(1);
private const int IterationsPerChunk = 50;
static void Main(string[] args) {
// Deserialize once to warm up the JIT and give us data use later
byte[] data = File.ReadAllBytes(args[0]);
Northwind.Database fast = Northwind.Database.ParseFrom(data);
SlowNorthwind.Database slow = SlowNorthwind.Database.ParseFrom(data);
Benchmark("Fast deserialize", () => Northwind.Database.ParseFrom(data));
Benchmark("Fast serialize", () => fast.ToByteArray());
Benchmark("Slow deserialize", () => SlowNorthwind.Database.ParseFrom(data));
Benchmark("Slow serialize", () => slow.ToByteArray());
//Console.ReadLine();
}
private static void Benchmark(string description, Action actionUnderTest) {
int totalIterations = 0;
Stopwatch sw = Stopwatch.StartNew();
while (sw.Elapsed < TimeLimit) {
for (int i = 0; i < IterationsPerChunk; i++) {
actionUnderTest();
}
totalIterations += IterationsPerChunk;
}
sw.Stop();
Console.WriteLine("{0}: {1} iterations in {2}ms; {3:f2}ms per iteration",
description, totalIterations, sw.ElapsedMilliseconds,
(double)sw.ElapsedMilliseconds / totalIterations);
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("TestBed")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TestBed")]
[assembly: AssemblyCopyright("Copyright © 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3ba08ae2-742f-4988-a9f9-5ff49cb701d5")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{BFA454A0-63F3-4850-BE9C-8CACD242EB50}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TestBed</RootNamespace>
<AssemblyName>TestBed</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="BclDecimal.cs" />
<Compile Include="BclProtoFile.cs" />
<Compile Include="NorthwindProtoFile.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SlowBclProtoFile.cs" />
<Compile Include="SlowNorthwindProtoFile.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ProtocolBuffers\ProtocolBuffers.csproj">
<Project>{6908BDCE-D925-43F3-94AC-A531E6DF2591}</Project>
<Name>ProtocolBuffers</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<StartWorkingDirectory>C:\Users\Jon\Documents\Visual Studio 2008\Projects\ProtocolBuffers\csharp\TestBed\</StartWorkingDirectory>
<StartArguments>nwind.proto.bin</StartArguments>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<StartWorkingDirectory>C:\Users\Jon\Documents\Visual Studio 2008\Projects\ProtocolBuffers\csharp\TestBed\</StartWorkingDirectory>
<StartArguments>nwind.proto.bin</StartArguments>
</PropertyGroup>
</Project>
\ No newline at end of file
package bcl;
option csharp_namespace = "Google.ProtocolBuffers.Bcl";
option csharp_file_classname = "BclProtoFile";
option optimize_for = SPEED;
message TimeSpan {
optional sint64 value = 1; // the size of the timespan (in units of the selected scale)
optional TimeSpanScale scale = 2 [default = DAYS]; // the scale of the timespan
enum TimeSpanScale {
DAYS = 0;
HOURS = 1;
MINUTES = 2;
SECONDS = 3;
MILLISECONDS = 4;
MINMAX = 15; // dubious
}
}
message DateTime {
optional sint64 value = 1; // the offset (in units of the selected scale) from 1970/01/01
optional TimeSpanScale scale = 2 [default = DAYS]; // the scale of the timespan
enum TimeSpanScale {
DAYS = 0;
HOURS = 1;
MINUTES = 2;
SECONDS = 3;
MILLISECONDS = 4;
MINMAX = 15; // dubious
}
}
message Guid {
optional fixed64 lo = 1; // the first 8 bytes of the guid
optional fixed64 hi = 2; // the second 8 bytes of the guid
}
message Decimal {
optional uint64 lo = 1; // the first 64 bits of the underlying value
optional uint32 hi = 2; // the last 32 bis of the underlying value
optional uint32 signScale = 3; // the number of decimal digits, and the sign
}
// this is prototype only!!!
package bcl;
message TimeSpan {
optional sint64 value = 1; // the size of the timespan (in units of the selected scale)
optional TimeSpanScale scale = 2 [default = DAYS]; // the scale of the timespan
enum TimeSpanScale {
DAYS = 0;
HOURS = 1;
MINUTES = 2;
SECONDS = 3;
MILLISECONDS = 4;
MINMAX = 15; // dubious
}
}
message DateTime {
optional sint64 value = 1; // the offset (in units of the selected scale) from 1970/01/01
optional TimeSpanScale scale = 2 [default = DAYS]; // the scale of the timespan
enum TimeSpanScale {
DAYS = 0;
HOURS = 1;
MINUTES = 2;
SECONDS = 3;
MILLISECONDS = 4;
MINMAX = 15; // dubious
}
}
message Guid {
optional fixed64 lo = 1; // the first 8 bytes of the guid
optional fixed64 hi = 2; // the second 8 bytes of the guid
}
message Decimal {
optional uint64 lo = 1; // the first 64 bits of the underlying value
optional uint32 hi = 2; // the last 32 bis of the underlying value
optional sint32 signScale = 3; // the number of decimal digits, and the sign
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
C:\Users\Jon\Documents\Visual Studio 2008\Projects\ProtocolBuffers\csharp\TestBed\bin\Debug\TestBed.exe
C:\Users\Jon\Documents\Visual Studio 2008\Projects\ProtocolBuffers\csharp\TestBed\bin\Debug\TestBed.pdb
C:\Users\Jon\Documents\Visual Studio 2008\Projects\ProtocolBuffers\csharp\TestBed\bin\Debug\Google.ProtocolBuffers.dll
C:\Users\Jon\Documents\Visual Studio 2008\Projects\ProtocolBuffers\csharp\TestBed\bin\Debug\Google.ProtocolBuffers.pdb
C:\Users\Jon\Documents\Visual Studio 2008\Projects\ProtocolBuffers\csharp\TestBed\obj\Debug\ResolveAssemblyReference.cache
C:\Users\Jon\Documents\Visual Studio 2008\Projects\ProtocolBuffers\csharp\TestBed\obj\Debug\TestBed.exe
C:\Users\Jon\Documents\Visual Studio 2008\Projects\ProtocolBuffers\csharp\TestBed\obj\Debug\TestBed.pdb
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment