##// END OF EJS Templates
Adde workaround to the behaviour of the logical operations stack in conjuction...
cin -
r255:b00441e04738 v3
parent child
Show More
@@ -0,0 +1,37
1 
2 Microsoft Visual Studio Solution File, Format Version 12.00
3 # Visual Studio 15
4 VisualStudioVersion = 15.0.27428.2005
5 MinimumVisualStudioVersion = 10.0.40219.1
6 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Implab", "Implab\Implab.csproj", "{FF2052B6-9C8F-4022-A347-F07ABF635885}"
7 EndProject
8 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Implab.Test", "Implab.Test\Implab.Test.csproj", "{6CD0DA18-8D9B-4AA8-A3DC-17322E27335E}"
9 EndProject
10 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab.Playground", "Implab.Playground\Implab.Playground.csproj", "{100DFEB0-75BE-436F-ADDF-1F46EF433F46}"
11 EndProject
12 Global
13 GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 Debug|Any CPU = Debug|Any CPU
15 Release|Any CPU = Release|Any CPU
16 EndGlobalSection
17 GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 {FF2052B6-9C8F-4022-A347-F07ABF635885}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 {FF2052B6-9C8F-4022-A347-F07ABF635885}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 {FF2052B6-9C8F-4022-A347-F07ABF635885}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 {FF2052B6-9C8F-4022-A347-F07ABF635885}.Release|Any CPU.Build.0 = Release|Any CPU
22 {6CD0DA18-8D9B-4AA8-A3DC-17322E27335E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 {6CD0DA18-8D9B-4AA8-A3DC-17322E27335E}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 {6CD0DA18-8D9B-4AA8-A3DC-17322E27335E}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 {6CD0DA18-8D9B-4AA8-A3DC-17322E27335E}.Release|Any CPU.Build.0 = Release|Any CPU
26 {100DFEB0-75BE-436F-ADDF-1F46EF433F46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 {100DFEB0-75BE-436F-ADDF-1F46EF433F46}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 {100DFEB0-75BE-436F-ADDF-1F46EF433F46}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 {100DFEB0-75BE-436F-ADDF-1F46EF433F46}.Release|Any CPU.Build.0 = Release|Any CPU
30 EndGlobalSection
31 GlobalSection(SolutionProperties) = preSolution
32 HideSolutionNode = FALSE
33 EndGlobalSection
34 GlobalSection(ExtensibilityGlobals) = postSolution
35 SolutionGuid = {36D837FC-4CDD-4AEA-87BF-F130FEB22E02}
36 EndGlobalSection
37 EndGlobal
@@ -1,6 +1,6
1 1 <?xml version="1.0" encoding="utf-8"?>
2 2 <configuration>
3 3 <startup>
4 <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
4 <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
5 5 </startup>
6 6 </configuration>
@@ -9,7 +9,7
9 9 <AppDesignerFolder>Properties</AppDesignerFolder>
10 10 <RootNamespace>Implab.Playground</RootNamespace>
11 11 <AssemblyName>Implab.Playground</AssemblyName>
12 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12 <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
13 13 <FileAlignment>512</FileAlignment>
14 14 <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15 15 <TargetFrameworkProfile />
@@ -1,4 +1,5
1 using Implab.Formats.Json;
1 using Implab.Diagnostics;
2 using Implab.Formats.Json;
2 3 using Implab.Parallels;
3 4 using Implab.Xml;
4 5 using System;
@@ -13,80 +14,42 using System.Xml;
13 14 using System.Xml.Serialization;
14 15
15 16 namespace Implab.Playground {
17 using System.Diagnostics;
18 using System.Runtime.Remoting.Messaging;
19 using static Trace<Program>;
20
16 21 public class Program {
17 22
18 static void EnqueueRange<T>(ConcurrentQueue<T> q, T[] data, int offset, int len) {
19 for (var i = offset; i < offset + len; i++)
20 q.Enqueue(data[i]);
21 }
23 static void Main(string[] args) {
24 var listener = new SimpleTraceListener(Console.Out);
25
26 var source = Trace<Program>.TraceSource;
27 source.Switch.Level = SourceLevels.All;
22 28
23 static bool TryDequeueRange<T>(ConcurrentQueue<T> q,T[] buffer,int offset, int len, out int actual) {
24 actual = 0;
25 T res;
26 while(q.TryDequeue(out res)) {
27 buffer[offset + actual] = res;
28 actual++;
29 if (actual == len)
30 break;
31 }
32 return actual != 0;
33 }
29 source.Listeners.Add(listener);
30
31 var t = Environment.TickCount;
34 32
35 static void EnqueueRange<T>(SimpleAsyncQueue<T> q, T[] data, int offset, int len) {
36 for (var i = offset; i < offset + len; i++)
37 q.Enqueue(data[i]);
38 }
33 Main().Wait();
39 34
40 static bool TryDequeueRange<T>(SimpleAsyncQueue<T> q, T[] buffer, int offset, int len, out int actual) {
41 actual = 0;
42 T res;
43 while (q.TryDequeue(out res)) {
44 buffer[offset + actual] = res;
45 actual++;
46 if (actual == len)
47 break;
48 }
49 return actual != 0;
35 Console.WriteLine($"Done: {Environment.TickCount - t} ms");
36 Console.ReadKey();
50 37 }
51 38
52 static void EnqueueRange<T>(AsyncQueue<T> q, T[] data, int offset, int len) {
53 for (var i = offset; i < offset + len; i++)
54 q.Enqueue(data[i]);
39 static async Task Main() {
40 using (LogicalOperation(nameof(Main))) {
41 Log("Start");
42 await SomeAsync();
43 Log("End");
44 }
55 45 }
56 46
57 static bool TryDequeueRange<T>(AsyncQueue<T> q, T[] buffer, int offset, int len, out int actual) {
58 actual = 0;
59 T res;
60 while (q.TryDequeue(out res)) {
61 buffer[offset + actual] = res;
62 actual++;
63 if (actual == len)
64 break;
47 static async Task SomeAsync() {
48 using (LogicalOperation(nameof(SomeAsync))) {
49 Log("Do prepare");
50 await Task.Yield();
51 Log("Yield");
65 52 }
66 return actual != 0;
67 }
68
69
70 /*static void EnqueueRange<T>(AsyncQueue<T> q, T[] data, int offset, int len) {
71 q.EnqueueRange(data, offset, len);
72 }
73
74 static bool TryDequeueRange<T>(AsyncQueue<T> q, T[] buffer, int offset, int len, out int actual) {
75 return q.TryDequeueRange(buffer, offset, len, out actual);
76 }*/
77
78
79 static void Main(string[] args) {
80
81 var t = Environment.TickCount;
82 using (var reader = JsonReader.Create("e:\\citylots.json")) {
83 while (reader.Read()) {
84 }
85 }
86
87 Console.WriteLine($"JsonReader: {Environment.TickCount - t} ms");
88
89 Console.WriteLine("done");
90 53 }
91 54 }
92 55 }
@@ -1,12 +1,13
1 1 <Project Sdk="Microsoft.NET.Sdk">
2 2
3 3 <PropertyGroup>
4 <TargetFramework>netcoreapp2.0</TargetFramework>
4 <TargetFramework>net46</TargetFramework>
5 <FrameworkPathOverride Condition="'$(TargetFramework)'=='net45' and '$(OSTYPE)'=='linux'">/usr/lib/mono/4.5/</FrameworkPathOverride>
5 6
6 7 <IsPackable>false</IsPackable>
7 8 </PropertyGroup>
8 9 <ItemGroup>
9 <ProjectReference Include="../Implab/Implab.csproj"/>
10 <ProjectReference Include="../Implab/Implab.csproj" />
10 11 <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
11 12 <PackageReference Include="xunit" Version="2.3.1" />
12 13 <PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
@@ -3,21 +3,21 using System.Collections.Generic;
3 3 using System.Diagnostics;
4 4 using System.Linq;
5 5 using System.Text;
6 using System.Threading;
6 7 using System.Threading.Tasks;
7 8
8 9 namespace Implab.Diagnostics {
9 10 public static class Trace<T> {
10 11
11 readonly static TraceSource _traceSource = new TraceSource(typeof(T).Name);
12
13 public static TraceSource TraceSource {
14 get { return _traceSource; }
15 }
16
12 public static TraceSource TraceSource { get; } = new TraceSource(typeof(T).Name);
13
14 #if NETFX_TRACE_BUG
15 readonly static AsyncLocal<object> m_currentOperation = new AsyncLocal<object>();
16 #endif
17
17 18 /// <summary>
18 19 /// Starts the logical operation nested to the current operation nested to the current one.
19 20 /// </summary>
20 [Conditional("TRACE")]
21 21 public static void StartLogicalOperation() {
22 22 Trace.CorrelationManager.StartLogicalOperation();
23 23
@@ -27,15 +27,20 namespace Implab.Diagnostics {
27 27 /// Starts the logical operation with the specified name, this name is usefull in logs.
28 28 /// </summary>
29 29 /// <param name="name">Name.</param>
30 [Conditional("TRACE")]
31 public static void StartLogicalOperation(string name) {
30 #if NETFX_TRACE_BUG
31 public static void StartLogicalOperation(object name) {
32 m_currentOperation.Value = name;
32 33 Trace.CorrelationManager.StartLogicalOperation(name);
33 34 }
35 #else
36 public static void StartLogicalOperation(object name) {
37 Trace.CorrelationManager.StartLogicalOperation(name);
38 }
39 #endif
34 40
35 41 /// <summary>
36 42 /// Ends the logical operation and restores the previous one.
37 43 /// </summary>
38 [Conditional("TRACE")]
39 44 public static void StopLogicalOperation() {
40 45 Trace.CorrelationManager.StopLogicalOperation();
41 46 }
@@ -120,7 +125,7 namespace Implab.Diagnostics {
120 125 public static LogicalOperationScope LogicalOperation(string name) {
121 126 var operation = new LogicalOperation(name);
122 127 TraceSource.TraceData(TraceEventType.Information, TraceEventCodes.StartLogicalOperation, operation);
123 Trace.CorrelationManager.StartLogicalOperation(operation);
128 StartLogicalOperation(operation);
124 129 return new LogicalOperationScope(TraceSource, operation);
125 130 }
126 131 }
@@ -11,8 +11,9
11 11 <LicenseUrl>https://opensource.org/licenses/BSD-2-Clause</LicenseUrl>
12 12 <ProjectUrl>https://implab.org</ProjectUrl>
13 13 <RepositoryUrl>https://hg.implab.org/pub/ImplabNet/</RepositoryUrl>
14 <TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
15 <FrameworkPathOverride Condition="'$(TargetFramework)'=='net45' and '$(OSTYPE)'=='linux'">/usr/lib/mono/4.5/</FrameworkPathOverride>
14 <TargetFrameworks>netstandard2.0;net46</TargetFrameworks>
15 <FrameworkPathOverride Condition="'$(TargetFramework)'=='net46' and '$(OSTYPE)'=='linux'">/usr/lib/mono/4.5/</FrameworkPathOverride>
16 <DefineConstants Condition="'$(TargetFramework)'=='net46'">NETFX_TRACE_BUG;$(DefineConstants)</DefineConstants>
16 17 </PropertyGroup>
17 18
18 19 </Project>
General Comments 3
Under Review
author

Auto status change to "Under Review"

Approved
author

ok, latest stable version should be in default

You need to be logged in to leave comments. Login now