How to measure program execution time in ARM Cortex-A8 processor?

Accessing the performance counters isn’t difficult, but you have to enable them from kernel-mode. By default the counters are disabled. In a nutshell you have to execute the following two lines inside the kernel. Either as a loadable module or just adding the two lines somewhere in the board-init will do: /* enable user-mode access … Read more

Performance Counter by Process ID instead of name?

This answer to a related question might work: private static string GetProcessInstanceName(int pid) { PerformanceCounterCategory cat = new PerformanceCounterCategory(“Process”); string[] instances = cat.GetInstanceNames(); foreach (string instance in instances) { using (PerformanceCounter cnt = new PerformanceCounter(“Process”, “ID Process”, instance, true)) { int val = (int) cnt.RawValue; if (val == pid) { return instance; } } } … Read more

How to detect SqlServer connection leaks in a ASP.net applications?

Found this thread researching a similar problem. I came up with the following sql as a good way to debug leaky connections in SQL Server: SELECT S.spid, login_time, last_batch, status, hostname, program_name, cmd, ( select text from sys.dm_exec_sql_text(S.sql_handle) ) as last_sql FROM sys.sysprocesses S where dbid > 0 and DB_NAME(dbid) = ‘<my_database_name>’ and loginame=”<my_application_login>” order … Read more

Why the cpu performance counter kept reporting 0% cpu usage?

The first iteration of the counter will always be 0, because it has nothing to compare to the last value. Try this: var cpuload = new PerformanceCounter(“Processor”, “% Processor Time”, “_Total”); Console.WriteLine(cpuload.NextValue() + “%”); Console.WriteLine(cpuload.NextValue() + “%”); Console.WriteLine(cpuload.NextValue() + “%”); Console.WriteLine(cpuload.NextValue() + “%”); Console.WriteLine(cpuload.NextValue() + “%”); Then you should see some data coming out. It’s … Read more

Using PerformanceCounter to track memory and CPU usage per process?

For per process data: Process p = /*get the desired process here*/; PerformanceCounter ramCounter = new PerformanceCounter(“Process”, “Working Set”, p.ProcessName); PerformanceCounter cpuCounter = new PerformanceCounter(“Process”, “% Processor Time”, p.ProcessName); while (true) { Thread.Sleep(500); double ram = ramCounter.NextValue(); double cpu = cpuCounter.NextValue(); Console.WriteLine(“RAM: “+(ram/1024/1024)+” MB; CPU: “+(cpu)+” %”); } Performance counter also has other counters than … Read more

The requested Performance Counter is not a custom counter, it has to be initialized as ReadOnly

This is due to the performance counter (or category) not existing, but with a horrible error message. Take a look in perfmon for the counter, it should be missing on the relevant machines. I find this happens to the .Net perf counters sometimes (no idea why) but using lodctr1 gets them back. If you indicate … Read more

What is the performance hit of Performance Counters

The overhead of setting up the performance counters is generally not high enough to worry about (setting up a shared memory region and some .NET objects, along with CLR overhead because the CLR actually does the management for you). Here I’m referring to classes like PerformanceCounter. The overhead of registering the perfromance counters can be … Read more

tech