-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added Experiments.MeasuringTools library to repository
- Loading branch information
GunnarPeipman
committed
Sep 25, 2010
1 parent
8ffe2ef
commit ed9876a
Showing
8 changed files
with
195 additions
and
0 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,20 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 11.00 | ||
# Visual Studio 2010 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Experiments.MeasuringTools", "Experiments.MeasuringTools\Experiments.MeasuringTools.csproj", "{A3F83AA1-35F7-4161-A7DE-5024FBB670C7}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{A3F83AA1-35F7-4161-A7DE-5024FBB670C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{A3F83AA1-35F7-4161-A7DE-5024FBB670C7}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{A3F83AA1-35F7-4161-A7DE-5024FBB670C7}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{A3F83AA1-35F7-4161-A7DE-5024FBB670C7}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
56 changes: 56 additions & 0 deletions
56
Experiments.MeasuringTools/Experiments.MeasuringTools/Experiments.MeasuringTools.csproj
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,56 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{A3F83AA1-35F7-4161-A7DE-5024FBB670C7}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Experiments.MeasuringTools</RootNamespace> | ||
<AssemblyName>Experiments.MeasuringTools</AssemblyName> | ||
<TargetFrameworkVersion>v4.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" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="ICommand.cs" /> | ||
<Compile Include="IDatabaseCommand.cs" /> | ||
<Compile Include="IScenario.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="TimerBasedUnitOfWork.cs" /> | ||
<Compile Include="UnitOfWork.cs" /> | ||
</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> |
9 changes: 9 additions & 0 deletions
9
Experiments.MeasuringTools/Experiments.MeasuringTools/ICommand.cs
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,9 @@ | ||
namespace Experiments.MeasuringTools | ||
{ | ||
public interface ICommand | ||
{ | ||
string Title { get; set; } | ||
void Execute(); | ||
bool RequiresWarmupCall { get; } | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
Experiments.MeasuringTools/Experiments.MeasuringTools/IDatabaseCommand.cs
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,8 @@ | ||
namespace Experiments.MeasuringTools | ||
{ | ||
public interface IDatabaseCommand : ICommand | ||
{ | ||
long RowsReturned { get; } | ||
long RowsInUnpagedResult { get; } | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
Experiments.MeasuringTools/Experiments.MeasuringTools/IScenario.cs
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,7 @@ | ||
namespace Experiments.MeasuringTools | ||
{ | ||
public interface IScenario | ||
{ | ||
UnitOfWork Load(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
Experiments.MeasuringTools/Experiments.MeasuringTools/Properties/AssemblyInfo.cs
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,36 @@ | ||
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("Experiments.MeasuringTools")] | ||
[assembly: AssemblyDescription("My code speed measuring tools")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("Experiments.MeasuringTools")] | ||
[assembly: AssemblyCopyright("Copyright © 2010 Gunnar Peipman")] | ||
[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("b36bb83c-cff8-4feb-acc3-85a59a60dc07")] | ||
|
||
// 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")] |
33 changes: 33 additions & 0 deletions
33
Experiments.MeasuringTools/Experiments.MeasuringTools/TimerBasedUnitOfWork.cs
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,33 @@ | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
|
||
namespace Experiments.MeasuringTools | ||
{ | ||
public class TimerBasedUnitOfWork : UnitOfWork | ||
{ | ||
public override void Commit() | ||
{ | ||
var stopper = new Stopwatch(); | ||
|
||
Time = 0; | ||
TimeTable = new Dictionary<ICommand, long>(); | ||
|
||
foreach (var command in Commands) | ||
{ | ||
if (command.RequiresWarmupCall) | ||
command.Execute(); | ||
|
||
stopper.Reset(); | ||
stopper.Start(); | ||
command.Execute(); | ||
stopper.Stop(); | ||
|
||
TimeTable.Add(command, stopper.ElapsedMilliseconds); | ||
Time += stopper.ElapsedMilliseconds; | ||
} | ||
} | ||
|
||
public long Time { get; private set; } | ||
public Dictionary<ICommand, long> TimeTable { get; private set; } | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
Experiments.MeasuringTools/Experiments.MeasuringTools/UnitOfWork.cs
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,26 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Experiments.MeasuringTools | ||
{ | ||
public class UnitOfWork | ||
{ | ||
private readonly List<ICommand> _commands = new List<ICommand>(); | ||
|
||
public virtual void Commit() | ||
{ | ||
foreach (var command in Commands) | ||
command.Execute(); | ||
} | ||
|
||
public IList<ICommand> Commands | ||
{ | ||
get { return _commands; } | ||
} | ||
|
||
public void Merge(UnitOfWork uow) | ||
{ | ||
foreach (var command in uow.Commands) | ||
Commands.Add(command); | ||
} | ||
} | ||
} |