Posts Tagged ‘C#’

SpeedTrace Pro 4.0 – Tracing unmanaged code – VBA, unmanaged C++ …

One of the great new features in SpeedTrace Pro 4.0.9 is the user trace option to provide tracing method for non-.Net code.

Now SpeedTrace 4.0 provides a COM object in order to enable you to trace your non- dotNet – platforms such as VBA, JavaScript, unmanaged C++ etc. For your convenience you can even add data to identity some kind of context during the performance reading.

Example VBA: In order to use the COM object, you need to instantiate it by the help of the type library (TLB-file). In office applications (Excel, Word etc.), add the type library (TLB) to the project references (Tools – References).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Sub Macro1()
 
    Dim tracer As ipcas_SpeedTrace_UserTrace.Trace
    Set tracer = New ipcas_SpeedTrace_UserTrace.Trace
 
        For i = 1 To 1000
 
     tracer.StartTransaction "FillAndReplace"
         tracer.StartTransactionEx "Fill", "0"
 
             ActiveCell.FormulaR1C1 = "0"
             Range("A1").Select
             Selection.AutoFill Destination:=Range("A1:E1"), Type:=xlFillDefault
             Range("A1:E1").Select
             Selection.AutoFill Destination:=Range("A1:E2"), Type:=xlFillDefault
             Range("A1:E2").Select
             Range("E1:E2").Select
             Selection.AutoFill Destination:=Range("E1:E11"), Type:=xlFillDefault
             Range("E1:E11").Select
             Range("E11").Select
             Selection.AutoFill Destination:=Range("E11:J11"), Type:=xlFillDefault
             Range("E11:J11").Select
             Range("J11").Select
             Selection.AutoFill Destination:=Range("J11:J20"), Type:=xlFillDefault
             Range("J11:J20").Select
             Range("L15").Select
 
         tracer.EndTransactionEx "Fill", "done"
 
 
         tracer.StartTransactionEx "Replace", "0->1"
 
            Selection.Replace What:="0", Replacement:="1", LookAt:=xlPart, _
             SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
             ReplaceFormat:=False
 
         tracer.EndTransactionEx "Replace", "done"
 
     tracer.EndTransaction "FillAndReplace"
 
        Next
End Sub

Recorded trace:

Recorded trace

Calculated profile / Call Stacks, Call History:

Calculated profile / Call Stacks, Call History:

More about SpeedTrace >>

Test Your .NET Profiler/Tracer Application

With our ThreadSuspendTester application (see C# source code and downlaod) you can get an idea of the abilities of your .NET testing tool.

Performance analysis with extremely multi threading - ThreadSuspendTest

ThreadSuspendTester is a small test program which records the overhead of .NET profilers or .NET tracers, especially at high concurrency.
The test program starts 100 threads, which in turn make allocations and garbage collections.

If you use SpeedTrace Pro as tracing/profiling tool, you will not detect much difference by the presence of the profiler. In contrast to other tools on the market, the overhead is very small.

Get an idea of your Profiler/Tracer. Compare the result with SpeedTrace Pro – You will be amazed.

Download ThreadSuspendTester.zip (Program.cs) Download ThreadSuspendTester.zip (Program.cs)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Collections;
using System.Diagnostics;
 
namespace ConsoleApplication1
{
    class Program
    {
        static bool terminated = false;
 
        static void Main(string[] args)
        {
            for (int i = 0; i < 15; i++)
            {
                Console.Write(string.Format("Test {0}...", i+1));
                ExecuteTest();
            }
 
            Console.WriteLine("DONE - Press ENTER to exit");
            Console.ReadLine();
        }
 
        private static void ExecuteTest()
        {
            var sw = new Stopwatch();
            sw.Start();
 
            System.Threading.Thread.CurrentThread.Priority = ThreadPriority.Normal;
            GC.Collect();
 
            for (int i = 0; i < 50; i++)
            {
                var threads = StartThreads();
 
                foreach (Thread t in threads)
                {
                    t.Abort();
                    GC.Collect();
                }
                terminated = true;
 
                foreach (Thread t in threads)
                {
                    t.Join();
                }
            }
 
            Console.WriteLine("Done..{0} ms", sw.ElapsedMilliseconds);
        }
 
        private static List<Thread> StartThreads()
        {
            var result = new List<Thread>();
            for (int i = 0; i < 1; i++)
            {
                var thread = new Thread(doNothingTest);
                thread.Priority = ThreadPriority.Lowest;
                thread.Start();
                result.Add(thread);
            }
 
            var thread2 = new Thread(allocTest);
            thread2.Priority = ThreadPriority.Lowest;
            thread2.Start();
            result.Add(thread2);
 
            for (int i = 0; i < 100; i++)
            {
                var thread = new Thread(allocTest);
                thread.Priority = ThreadPriority.Lowest;
                thread.Start();
                result.Add(thread);
            }
            return result;
        }
 
        static void allocTest()
        {
            int j=0;
            while (!terminated)
            {
                ArrayList list = new ArrayList();
                for (int i = 0; i < 1000; i++)
                {
                    list.Add(new Program());
                }
                list.Clear();
                if (j % 1 == 0)
                {
                    GC.Collect();
                }
 
                System.Threading.Thread.Sleep(1);
            }
        }
 
        static void doNothingTest()
        {
            while (!terminated)
            {
            }
        }   
    }
}

More about SpeedTrace >>
Download Now (free evaluation) >>