##// END OF EJS Templates
sync
cin -
r103:b3f5bc613905 v2
parent child
Show More
@@ -1,46 +1,46
1 1 <?xml version="1.0" encoding="utf-8"?>
2 2 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 3 <PropertyGroup>
4 4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5 5 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6 6 <ProductVersion>8.0.30703</ProductVersion>
7 7 <SchemaVersion>2.0</SchemaVersion>
8 8 <ProjectGuid>{15DD7123-D504-4627-8B4F-D00C7F04D033}</ProjectGuid>
9 9 <OutputType>Exe</OutputType>
10 10 <RootNamespace>MonoPlay</RootNamespace>
11 11 <AssemblyName>MonoPlay</AssemblyName>
12 12 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13 13 </PropertyGroup>
14 14 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
15 15 <DebugSymbols>true</DebugSymbols>
16 16 <DebugType>full</DebugType>
17 17 <Optimize>false</Optimize>
18 18 <OutputPath>bin\Debug</OutputPath>
19 19 <DefineConstants>DEBUG;TRACE;</DefineConstants>
20 20 <ErrorReport>prompt</ErrorReport>
21 21 <WarningLevel>4</WarningLevel>
22 22 <ConsolePause>false</ConsolePause>
23 23 </PropertyGroup>
24 24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25 25 <DebugType>full</DebugType>
26 26 <Optimize>true</Optimize>
27 27 <OutputPath>bin\Release</OutputPath>
28 28 <ErrorReport>prompt</ErrorReport>
29 29 <WarningLevel>4</WarningLevel>
30 <Externalconsole>true</Externalconsole>
30 <ConsolePause>false</ConsolePause>
31 31 </PropertyGroup>
32 32 <ItemGroup>
33 33 <Reference Include="System" />
34 34 </ItemGroup>
35 35 <ItemGroup>
36 36 <Compile Include="Program.cs" />
37 37 <Compile Include="Properties\AssemblyInfo.cs" />
38 38 </ItemGroup>
39 39 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
40 40 <ItemGroup>
41 41 <ProjectReference Include="..\Implab\Implab.csproj">
42 42 <Project>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</Project>
43 43 <Name>Implab</Name>
44 44 </ProjectReference>
45 45 </ItemGroup>
46 46 </Project> No newline at end of file
@@ -1,32 +1,48
1 1 using System;
2 2 using Implab.Diagnostics;
3 3 using Implab.Parallels;
4 4 using Implab;
5 using System.Collections.Generic;
6 using System.Collections.Concurrent;
5 7
6 8 namespace MonoPlay {
7 9 class MainClass {
8 10 public static void Main(string[] args) {
9 11 if (args == null)
10 12 throw new ArgumentNullException("args");
11 13
12 var listener = new ConsoleTraceListener(true);
13 listener.Subscribe<TraceEvent>();
14 var q1 = new MTQueue<int>();
15 var q2 = new ConcurrentQueue<int>();
16
17 const int count = 10000000;
18
19 var t1 = Environment.TickCount;
14 20
15 MTComponentContainer.AppContainer.Add(listener);
21 for (var i = 0; i < count; i++)
22 q1.Enqueue(i);
16 23
17 TraceLog.StartLogicalOperation("program");
24 var t2 = Environment.TickCount;
25 Console.WriteLine("MTQueue: {0} ms", t2 - t1);
26
27 t1 = Environment.TickCount;
18 28
19 TraceLog.StartLogicalOperation("async");
20 AsyncPool.Invoke(() => {
21 TraceLog.TraceInformation("Hello async");
22 TraceLog.StartLogicalOperation("foo");
23 return 0;
24 })
25 .EndLogicalOperation()
26 .Join();
29 for (var i = 0; i < count; i++)
30 q2.Enqueue(i);
31
32 t2 = Environment.TickCount;
33 Console.WriteLine("LinkedList: {0} ms", t2 - t1);
34
35 q2 = new ConcurrentQueue<int>();
27 36
28 TraceLog.EndLogicalOperation();
37 t1 = Environment.TickCount;
38
39 for (var i = 0; i < count; i++)
40 lock (q2)
41 q2.Enqueue(i);
42
43 t2 = Environment.TickCount;
44 Console.WriteLine("LinkedList+Lock: {0} ms", t2 - t1);
29 45
30 46 }
31 47 }
32 48 }
General Comments 0
You need to be logged in to leave comments. Login now