Skip to content

Commit 109837b

Browse files
committed
feat: add batch logging commands for debugging and performance metrics
1 parent 8e99e97 commit 109837b

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

source/RevitDevTool.Test/BoundingBoxVisualization.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Diagnostics;
22
using Autodesk.Revit.Attributes;
3-
using Autodesk.Revit.UI;
43
using Autodesk.Revit.UI.Selection;
54
using Nice3point.Revit.Toolkit.External;
65

source/RevitDevTool.Test/Log.cs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
using System.Diagnostics;
2+
using Autodesk.Revit.Attributes;
3+
using Nice3point.Revit.Toolkit.External;
4+
namespace RevitDevTool.Test;
5+
6+
[UsedImplicitly]
7+
[Transaction(TransactionMode.Manual)]
8+
public class BatchDebugLogCmd : ExternalCommand
9+
{
10+
public override void Execute()
11+
{
12+
var stopwatch = Stopwatch.StartNew();
13+
stopwatch.Start();
14+
for (var stepNumber = 1; stepNumber <= 10000; stepNumber++)
15+
{
16+
Debug.WriteLine($"Processing batch item Step {stepNumber}");
17+
Debug.WriteLine($"Batch processing metrics for Step {stepNumber}");
18+
Debug.WriteLine($"Completed processing Step {stepNumber:000}");
19+
Debug.WriteLine($"Performance warning for Step {stepNumber:000}");
20+
Debug.WriteLine($"Failed to process Step {stepNumber:000}");
21+
Debug.WriteLine($"Critical failure in Step {stepNumber:000}");
22+
}
23+
stopwatch.Stop();
24+
Debug.WriteLine($"Total processing time: {stopwatch.ElapsedMilliseconds} ms");
25+
}
26+
}
27+
28+
[UsedImplicitly]
29+
[Transaction(TransactionMode.Manual)]
30+
public class BatchTraceLogCmd : ExternalCommand
31+
{
32+
public override void Execute()
33+
{
34+
var stopwatch = Stopwatch.StartNew();
35+
stopwatch.Start();
36+
for (var stepNumber = 1; stepNumber <= 10000; stepNumber++)
37+
{
38+
Trace.WriteLine($"Processing batch item Step {stepNumber}");
39+
Trace.WriteLine($"Batch processing metrics for Step {stepNumber}");
40+
Trace.WriteLine($"Completed processing Step {stepNumber:000}");
41+
Trace.WriteLine($"Performance warning for Step {stepNumber:000}");
42+
Trace.WriteLine($"Failed to process Step {stepNumber:000}");
43+
Trace.WriteLine($"Critical failure in Step {stepNumber:000}");
44+
}
45+
stopwatch.Stop();
46+
Trace.WriteLine($"Total processing time: {stopwatch.ElapsedMilliseconds} ms");
47+
}
48+
}
49+
50+
[UsedImplicitly]
51+
[Transaction(TransactionMode.Manual)]
52+
public class BatchConsoleLogCmd : ExternalCommand
53+
{
54+
public override void Execute()
55+
{
56+
var stopwatch = Stopwatch.StartNew();
57+
stopwatch.Start();
58+
for (var stepNumber = 1; stepNumber <= 10000; stepNumber++)
59+
{
60+
Console.WriteLine($"Processing batch item Step {stepNumber}");
61+
Console.WriteLine($"Batch processing metrics for Step {stepNumber}");
62+
Console.WriteLine($"Completed processing Step {stepNumber:000}");
63+
Console.WriteLine($"Performance warning for Step {stepNumber:000}");
64+
Console.WriteLine($"Failed to process Step {stepNumber:000}");
65+
Console.WriteLine($"Critical failure in Step {stepNumber:000}");
66+
}
67+
stopwatch.Stop();
68+
Console.WriteLine($"Total processing time: {stopwatch.ElapsedMilliseconds} ms");
69+
}
70+
}
71+
72+
[UsedImplicitly]
73+
[Transaction(TransactionMode.Manual)]
74+
public class TraceColoredCmd : ExternalCommand
75+
{
76+
public override void Execute()
77+
{
78+
Trace.TraceInformation("This is an informational message.");
79+
Trace.TraceWarning("This is a warning message.");
80+
Trace.TraceError("This is an error message.");
81+
}
82+
}

0 commit comments

Comments
 (0)