瀏覽代碼

Build performance optimisations

ArnoldZokas 15 年之前
父節點
當前提交
ed0b7140fa
共有 3 個文件被更改,包括 51 次插入27 次删除
  1. 5 5
      cfg/Common.targets
  2. 22 0
      cfg/benchmark.ps1
  3. 24 22
      cfg/build.csproj

+ 5 - 5
cfg/Common.targets

@@ -8,7 +8,7 @@
 
 	<Target Name="_Compile">
 		<MSBuild Projects="%(Solution.Identity)" Properties="Configuration=%(Solution.Configuration);Platform=%(Solution.Platform)"
-				 Targets="%(Solution.BuildTarget)" BuildInParallel="true" Condition="%(Solution.CompileGroup) == $(CompileGroup)" ToolsVersion="4.0" />
+				 Targets="%(Solution.BuildTarget)" BuildInParallel="true" Condition="%(Solution.CompileGroup) == 'Build'" />
 	</Target>
 
 	<Target Name="_EnsureEnvironment">
@@ -16,7 +16,7 @@
 		<Error Text="Tool &quot;Protogen&quot; could not be found at path $(ProtogenExePath)" Condition="!Exists($(ProtogenExePath))" />
 	</Target>
 
-	<Target Name="_GenerateSource" DependsOnTargets="_Clean;_Compile;_Compile">
+	<Target Name="_GenerateSource" DependsOnTargets="_Clean;_Compile;_EnsureEnvironment">
 		<PropertyGroup>
 			<ProtosList>@(Protos)</ProtosList>
 			<Args>$(ProtosList.Replace(`;`,` `))</Args>
@@ -35,8 +35,8 @@
 				 Targets="%(Solution.BuildTarget)" BuildInParallel="true" Condition="%(Solution.CompileGroup) == $(CompileGroup)" />
 	</Target>
 
-	<Target Name="_Test" DependsOnTargets="_CompileGeneratedSource">		
-		<Exec Command="&quot;$(NUnitExePath)&quot; %(NUnitTests.Identity) /xml=%(NUnitTests.Filename)%(NUnitTests.Extension).xml" WorkingDirectory="$(BuildTempDirectory)" />
+	<Target Name="_Test" DependsOnTargets="_CompileGeneratedSource">
+		<Exec Command="&quot;$(NUnitExePath)&quot; %(NUnitTests.Identity) /xml=%(NUnitTests.Filename)%(NUnitTests.Extension).txt" WorkingDirectory="$(BuildTempDirectory)" />
 	</Target>
 
 	<Target Name="_Package" DependsOnTargets="_CopyGeneratedSource">
@@ -46,7 +46,7 @@
 	<!--
 		BENCHMARK - this needs optimising
 	-->
-	<Target Name="_GenerateBenchmarkSource">
+	<Target Name="_GenerateBenchmarkSource" DependsOnTargets="_Clean">
 		<PropertyGroup>
 			<Args>$(BenchmarkProtosDirectory)\google_size.proto $(BenchmarkProtosDirectory)\google_speed.proto</Args>
 		</PropertyGroup>

+ 22 - 0
cfg/benchmark.ps1

@@ -0,0 +1,22 @@
+write-host `nRunning build. Please wait...
+
+$iterations = 10
+
+for ($i=1; $i -le $iterations; $i++)
+{
+	$sw = [System.Diagnostics.StopWatch]::StartNew()
+	#& $env:windir\Microsoft.NET\Framework\v4.0.30319\msbuild.exe build.csproj /m /nologo /v:q
+	& $env:windir\Microsoft.NET\Framework\v4.0.30319\msbuild.exe build.csproj /m /nologo /v:q /t:BuildAll /p:CompileGroup=BuildAll
+	$sw.Stop()
+	$msbuildTotalRunTime += $sw.ElapsedMilliseconds
+
+	$sw = [System.Diagnostics.StopWatch]::StartNew()
+	#& "..\nant-0.91-alpha2\bin\NAnt.exe" -buildfile:"..\ProtocolBuffers.build" -nologo -q clean-build
+	& "..\nant-0.91-alpha2\bin\NAnt.exe" -buildfile:"..\ProtocolBuffers.build" -nologo -q clean-build-all
+	$sw.Stop()
+	$nantTotalRunTime += $sw.ElapsedMilliseconds
+}
+
+write-host `nMSBuild average speed over $iterations iterations: ($msbuildTotalRunTime/$iterations) milliseconds
+write-host NAnt average speed over $iterations iterations: ($nantTotalRunTime/$iterations) milliseconds`n
+write-host MSBuild execution speed: ([Math]::Round($(100/$nantTotalRunTime*$msbuildTotalRunTime), 2))% "(as a percentage of NAnt execution speed)"`n

+ 24 - 22
cfg/build.csproj

@@ -4,8 +4,7 @@
 	<PropertyGroup>
 		<ProjectName>Protocol Buffers</ProjectName>
 		<BuildConfiguration>Debug</BuildConfiguration>
-		<CompileGroup>Build</CompileGroup>
-		<VSHostExcludeWildcard>$(SourceDirectory)\**\*.vshost.exe*</VSHostExcludeWildcard>
+		<CompileGroup>BuildAll</CompileGroup>
 
 		<!--Directory Paths-->
 		<ProjectDirectory>$(MSBuildProjectDirectory)\..</ProjectDirectory>
@@ -50,7 +49,7 @@
 			<Platform>Any CPU</Platform>
 			<BuildTarget>Build</BuildTarget>
 			<CompileGroup>BuildAll</CompileGroup>
-	</Solution>
+		</Solution>
 		<Solution Include="$(SolutionFile)">
 			<Configuration>Silverlight2</Configuration>
 			<Platform>Any CPU</Platform>
@@ -63,7 +62,7 @@
 			<BuildTarget>Build</BuildTarget>
 			<CompileGroup>BuildAll</CompileGroup>
 		</Solution>-->
-
+		
 		<Protos Include="$(ProtosDirectory)\google\protobuf\descriptor.proto" />
 		<Protos Include="$(ProtosDirectory)\google\protobuf\csharp_options.proto" />
 		<Protos Include="$(ProtosDirectory)\google\protobuf\unittest.proto" />
@@ -105,7 +104,7 @@
 		<GeneratedSource Include="$(BuildTempDirectory)\UnitTestImportProtoFile.cs">
 			<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory>
 		</GeneratedSource>
-
+		
 		<NUnitTests Include="$(SourceDirectory)\ProtocolBuffers.Test\bin\$(BuildConfiguration)\Google.ProtocolBuffers.Test.dll" />
 		<NUnitTests Include="$(SourceDirectory)\Protogen.Test\bin\$(BuildConfiguration)\Google.ProtocolBuffers.ProtoGen.Test.dll" />
 
@@ -114,47 +113,50 @@
 		<PackageContents Include="$(ProjectDirectory)\protos\**\*.*">
 			<TargetDirectory>\protos</TargetDirectory>
 		</PackageContents>
-		<PackageContents Include="$(SourceDirectory)\ProtocolBuffers\bin\Debug\Google.ProtocolBuffers.*" Exclude="$(VSHostExcludeWildcard)">
+		<PackageContents Include="$(SourceDirectory)\ProtocolBuffers\bin\Debug\Google.ProtocolBuffers.*">
 			<TargetDirectory>\Debug</TargetDirectory>
 		</PackageContents>
-		<PackageContents Include="$(SourceDirectory)\ProtoGen\bin\Debug\ProtoGen.*" Exclude="$(VSHostExcludeWildcard)">
+		<PackageContents Include="$(SourceDirectory)\ProtoGen\bin\Debug\ProtoGen.*">
 			<TargetDirectory>\Debug</TargetDirectory>
 		</PackageContents>
-		<PackageContents Include="$(SourceDirectory)\ProtoMunge\bin\Debug\ProtoMunge.*" Exclude="$(VSHostExcludeWildcard)">
+		<PackageContents Include="$(SourceDirectory)\ProtoMunge\bin\Debug\ProtoMunge.*">
 			<TargetDirectory>\Debug</TargetDirectory>
 		</PackageContents>
-		<PackageContents Include="$(SourceDirectory)\ProtoDump\bin\Debug\ProtoDump.*" Exclude="$(VSHostExcludeWildcard)">
+		<PackageContents Include="$(SourceDirectory)\ProtoDump\bin\Debug\ProtoDump.*">
 			<TargetDirectory>\Debug</TargetDirectory>
 		</PackageContents>
-		<PackageContents Include="$(SourceDirectory)\ProtoBench\bin\Debug\ProtoBench.*" Exclude="$(VSHostExcludeWildcard)">
+		<PackageContents Include="$(SourceDirectory)\ProtoBench\bin\Debug\ProtoBench.*">
 			<TargetDirectory>\Debug</TargetDirectory>
 		</PackageContents>
-		<PackageContents Include="$(SourceDirectory)\ProtocolBuffers\bin\Release\Google.ProtocolBuffers.*" Exclude="$(VSHostExcludeWildcard)">
+		<PackageContents Include="$(SourceDirectory)\ProtocolBuffers\bin\Release\Google.ProtocolBuffers.*">
 			<TargetDirectory>\Release</TargetDirectory>
 		</PackageContents>
-		<PackageContents Include="$(SourceDirectory)\ProtoGen\bin\Release\ProtoGen.*" Exclude="$(VSHostExcludeWildcard)">
+		<PackageContents Include="$(SourceDirectory)\ProtoGen\bin\Release\ProtoGen.*">
 			<TargetDirectory>\Release</TargetDirectory>
 		</PackageContents>
-		<PackageContents Include="$(SourceDirectory)\ProtoMunge\bin\Release\ProtoMunge.*" Exclude="$(VSHostExcludeWildcard)">
+		<PackageContents Include="$(SourceDirectory)\ProtoMunge\bin\Release\ProtoMunge.*">
 			<TargetDirectory>\Release</TargetDirectory>
 		</PackageContents>
-		<PackageContents Include="$(SourceDirectory)\ProtoDump\bin\Release\ProtoDump.*" Exclude="$(VSHostExcludeWildcard)">
+		<PackageContents Include="$(SourceDirectory)\ProtoDump\bin\Release\ProtoDump.*">
 			<TargetDirectory>\Release</TargetDirectory>
 		</PackageContents>
-		<PackageContents Include="$(SourceDirectory)\ProtoBench\bin\Release\ProtoBench.*" Exclude="$(VSHostExcludeWildcard)">
+		<PackageContents Include="$(SourceDirectory)\ProtoBench\bin\Release\ProtoBench.*">
 			<TargetDirectory>\Release</TargetDirectory>
 		</PackageContents>
-		<PackageContents Include="$(SourceDirectory)\ProtocolBuffers\bin\Silverlight2\Google.ProtocolBuffers.*" Exclude="$(VSHostExcludeWildcard)">
+		<PackageContents Include="$(SourceDirectory)\ProtocolBuffers\bin\Silverlight2\Google.ProtocolBuffers.*">
 			<TargetDirectory>\Silverlight2</TargetDirectory>
 		</PackageContents>
-		<!--<PackageContents Include="$(SourceDirectory)\ProtocolBuffers\bin\ReleaseCF\Google.ProtocolBuffers.*" Exclude="$(VSHostExcludeWildcard)">
-				<TargetDirectory>\CompactFramework35</TargetDirectory>
-			</PackageContents>-->
+		<!--<PackageContents Include="$(SourceDirectory)\ProtocolBuffers\bin\ReleaseCF\Google.ProtocolBuffers.*">
+			<TargetDirectory>\CompactFramework35</TargetDirectory>
+		</PackageContents>-->
+		<PackageContents Include="$(LibDirectory)\Protoc*">
+			<TargetDirectory>\Protoc</TargetDirectory>
+		</PackageContents>
 	</ItemGroup>
 
 	<!--target groups-->
-	<Target Name="Build" DependsOnTargets="_Clean;_Compile;_EnsureEnvironment;_GenerateSource;_CopyGeneratedSource;_CompileGeneratedSource;_Test" />
-	<Target Name="BuildAll" DependsOnTargets="_Clean;_Compile;_EnsureEnvironment;_GenerateSource;_CopyGeneratedSource;_CompileGeneratedSource;_Test;_Package" />
-	<Target Name="Benchmark" DependsOnTargets="_Clean;_GenerateBenchmarkSource;_CompileBenchmarkAssembly;_PrepareBenchmarkEnvironment;_RunBenchmark" />
+	<Target Name="Build"	 DependsOnTargets="_GenerateSource;_CopyGeneratedSource;_CompileGeneratedSource;_Test;_Package" />
+	<Target Name="BuildAll"  DependsOnTargets="_GenerateSource;_CopyGeneratedSource;_CompileGeneratedSource;_Test;_Package" />
+	<Target Name="Benchmark" DependsOnTargets="_GenerateBenchmarkSource;_CompileBenchmarkAssembly;_PrepareBenchmarkEnvironment;_RunBenchmark" />
 
 </Project>