##// END OF EJS Templates
working on diagnostics
cin -
r194:d45bdf510514 v2
parent child
Show More
@@ -132,7 +132,7 namespace Implab.Test {
132 132 ShouldThrow(() => p.Join(1000));
133 133 Assert.AreEqual(ExecutionState.Failed, comp.State);
134 134
135 Assert.IsInstanceOfType(comp.LastError, typeof(OperationCanceledException));
135 Assert.IsTrue(comp.LastError is OperationCanceledException);
136 136
137 137 comp.Dispose();
138 138 }
@@ -185,7 +185,7 namespace Implab.Test {
185 185 p.Cancel();
186 186 ShouldThrow(() => p.Join(1000));
187 187 Assert.AreEqual(ExecutionState.Failed, comp.State);
188 Assert.IsInstanceOfType(comp.LastError, typeof(OperationCanceledException));
188 Assert.IsTrue(comp.LastError is OperationCanceledException);
189 189
190 190 comp.Dispose();
191 191 }
@@ -59,8 +59,8 namespace Implab.Diagnostics {
59 59
60 60 public void UnsubscribeAll() {
61 61 lock (m_subscriptions) {
62 foreach (var subscription in m_subscriptions.Values)
63 subscription();
62 foreach (var remove in m_subscriptions.Values)
63 remove();
64 64 m_subscriptions.Clear();
65 65 }
66 66 }
@@ -69,7 +69,7 namespace Implab.Diagnostics {
69 69 this,
70 70 new LogEventArgs<TEvent>(
71 71 data,
72 Name,
72 this,
73 73 traceContext.ThreadId,
74 74 traceContext.CurrentOperation,
75 75 traceContext.CurrentOperation.Duration
@@ -77,5 +77,9 namespace Implab.Diagnostics {
77 77 );
78 78 }
79 79 }
80
81 public override string ToString() {
82 return Name;
80 83 }
81 84 }
85 }
@@ -2,7 +2,7
2 2
3 3 namespace Implab.Diagnostics {
4 4 public class LogEventArgs : EventArgs {
5 public string ChannelName {
5 public object Channel {
6 6 get;
7 7 private set;
8 8 }
@@ -18,8 +18,8 namespace Implab.Diagnostics {
18 18 get;
19 19 private set;
20 20 }
21 public LogEventArgs(string channelName, int threadId, LogicalOperation operation, int timeOffset) {
22 ChannelName = channelName;
21 public LogEventArgs(object channel, int threadId, LogicalOperation operation, int timeOffset) {
22 Channel = channel;
23 23 ThreadId = threadId;
24 24 Operation = operation;
25 25 OperationTimeOffset = timeOffset;
@@ -5,7 +5,7
5 5 private set;
6 6 }
7 7
8 public LogEventArgs(TEvent value,string channelName, int threadId, LogicalOperation operation, int timeOffset) : base(channelName, threadId, operation, timeOffset) {
8 public LogEventArgs(TEvent value,object channel, int threadId, LogicalOperation operation, int timeOffset) : base(channel, threadId, operation, timeOffset) {
9 9 Value = value;
10 10 }
11 11 }
@@ -18,7 +18,7 namespace Implab.Diagnostics {
18 18 var msg = new StringBuilder();
19 19 for (int i = 0; i < args.Operation.Level; i++)
20 20 msg.Append(" ");
21 msg.AppendFormat("[{0}]:{1}: {2}", args.ThreadId, args.ChannelName, entry);
21 msg.AppendFormat("[{0}]:{1}: {2}", args.ThreadId, args.Channel, entry);
22 22
23 23 lock (m_textWriter) {
24 24 if (!IsDisposed) {
@@ -77,7 +77,6
77 77 <ItemGroup>
78 78 <Compile Include="CustomEqualityComparer.cs" />
79 79 <Compile Include="Diagnostics\ConsoleTraceListener.cs" />
80 <Compile Include="Diagnostics\EventText.cs" />
81 80 <Compile Include="Diagnostics\LogChannel.cs" />
82 81 <Compile Include="Diagnostics\LogicalOperation.cs" />
83 82 <Compile Include="Diagnostics\TextFileListener.cs" />
@@ -4,39 +4,42 using System.Threading.Tasks;
4 4 using Implab.Formats.JSON;
5 5 using System.IO;
6 6 using System.Text.Json;
7 using System.Diagnostics;
8 using Implab.Parallels;
9 using System.Threading;
7 10
8 11 namespace MonoPlay {
9 12 class MainClass {
10 13
11 14
12 15 public static void Main(string[] args) {
13 if (args == null)
14 throw new ArgumentNullException("args");
15 int t1, t2;
16 var pool = new WorkerPool(10);
16 17
17 for (int i = 0; i < 2; i++) {
18 t1 = Environment.TickCount;
19 int elements =0;
20 using (var reader = new JSONParser(File.OpenText("/home/sergey/temp/citylots.json"))) {
21 while (reader.Read())
22 elements++;
23 }
18 var listerner = new ConsoleTraceListener();
19 listerner.TraceOutputOptions = TraceOptions.LogicalOperationStack;
20 Trace.Listeners.Add(listerner);
21
22 Trace.CorrelationManager.StartLogicalOperation("Main");
24 23
25 t2 = Environment.TickCount;
26 Console.WriteLine("attempt {0} done: {1} ms, {2:.00} Mb, {3} GC, Elements: {4}",i+1, t2 - t1, GC.GetTotalMemory(false) / (1024*1024), GC.CollectionCount(0), elements );
27 }
24 var d = pool.Invoke(() => {
25 Trace.CorrelationManager.StartLogicalOperation("Worker");
26 Thread.Sleep(100);
27 Trace.TraceInformation("worker done");
28 Trace.CorrelationManager.StopLogicalOperation();
29 });
28 30
29 Console.WriteLine("Syste.Text.Json");
30 var paraser = new JsonParser();
31 for (int i = 0; i < 2; i++) {
32 t1 = Environment.TickCount;
33 using (var reader = File.OpenText("/home/sergey/temp/citylots.json")) {
34 paraser.Parse(reader);
35 }
31 ThreadPool.QueueUserWorkItem((o) => {
32 Trace.CorrelationManager.StartLogicalOperation("Thread");
33 Thread.Sleep(100);
34 Trace.TraceInformation("thread done");
35 Trace.CorrelationManager.StopLogicalOperation();
36 });
36 37
37 t2 = Environment.TickCount;
38 Console.WriteLine("attempt {0} done: {1} ms, {2:.00} Mb, {3} GC, ",i+1, t2 - t1, GC.GetTotalMemory(false) / (1024*1024), GC.CollectionCount(0));
39 }
38 Trace.TraceInformation("main done");
39 Trace.CorrelationManager.StopLogicalOperation();
40
41 d.Join();
42
40 43
41 44
42 45 }
1 NO CONTENT: file was removed
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