.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Performance Tests: Precise Run Time Measurements with System.Diagnostics.Stopwatch

Posted By: Venkat     Posted Date: March 01, 2010    Points: 2   Category :.NET Framework
Everybody who does performance optimization stumbles sooner or later over the Stopwatch class in the System.Diagnostics namespace. And everybody has noticed that the measurements of the same function on the same computer can differ 25% -30% in run time. This article shows how single threaded test programs must be designed to get an accuracy of 0.1% - 0.2% out of the Stopwatch class. With this accuracy, algorithms can be tested and compared.

View Complete Post

More Related Resource Links

Thread Diagnostics: Performance Tuning with The Concurrency Visualizer in Visual Studio 2010


Understanding performance bottlenecks in multithreaded apps used to require significant instrumentation and analysis by expert developers. The Concurrency Visualizer in Visual Studio 2010 significantly reduces the burden of parallel performance analysis.

Hazim Shafi

MSDN Magazine March 2010

Advanced Basics: Monitor Your Apps with System.Diagnostics


It never fails. The application you just deployed ran great on your development machine-but stumbles in production. The problem might show up right away or maybe it creeps up over time. Now what?

Brad McCabe

MSDN Magazine July 2006

CLR Inside Out: Extending System.Diagnostics


The System. Diagnostics namespace in the Microsoft® . NET Framework contains powerful tracing capabilities. This includes the main tracing API: TraceSource. As you will see, the tracing APIs in System.

Krzysztof Cwalina

MSDN Magazine April 2006

Unit Testing Tips: Write Maintainable Unit Tests That Will Save You Time And Tears


Everybody's talking about unit testing and you want to get into the game too. But you don't want the tests to take up all your development time and energy. Fortunately Roy Osherove is here to dispel some testing myths and put you on the road to efficient unit testing.

Roy Osherove

MSDN Magazine January 2006

Team System - VS2008 -- Performance testing statistics


Dear all,


I am new to using performance testing in team system VS2008.

Could you tell me that What is the steps needed in VS2008 to create performance testing if I have the Web Application Source Code??

So that I can know where or which function need the most time. 

Very Slow Performance on 64 bit SQL System

Hello, we have a Windows Server 2008 64 bit and a SQL Server 2008 64 bit. The server work and the speed with a quad CPU and 8 GB RAM is nice. But, we use a SQL script with xml (we make a XML paket for replication) is the speed very slow. The script need 40 - 60 min to finish. But the same Database and the same script on a Server 2008 32 bit and SQL Server 2008 32 bit on the same hardware need 22 seconds. We have all updates installed. Have anywere a Idea? Thank

Issue on System.Diagnostics.Process output

I am getting the following error message System.InvalidOperationException: StandardOut has not been redirected or the process hasn't started yet. for the below code which has to displays the Output of the command prompt command: Process p = new Process(); string result = ""; p.StartInfo.WorkingDirectory = "C:\\WINDOWS\\system32"; p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.Arguments = "/C ipconfig"; StreamReader stdOut = p.StandardOutput; p.WaitForExit(); p.Start(); result = stdOut.ReadToEnd(); if (!p.HasExited) { p.Kill(); } stdOut.Close(); p.Close(); Response.Write(result); System.Threading.Thread.Sleep(5000); Please help guys. Is I am doing correct. 

System.Diagnostics.Process.Start not work with IIS, but on ASP.NET Development Server

System.Diagnostics.Process.Start not work with IIS, but on ASP.NET Development Server 

Exception in System.Diagnostics.EventLog.get_EntryCount()

Hello,I am having an really weird exception which seems to originate in the BCL since the call stack does not show any of my code.Application is an event log processing service which uses the EntryWritten event of the System.Diagnostics.Eventlog class.The exceptions call stack is as follows:[System]System.ComponentModel.Win32ExceptionInterface unknownat System.Diagnostics.EventLogget_EntryCount()at System.Diagnostics.EventLogCompletionCallback(Object context)at System.Diagnostics.EventLogStaticCompletionCallback(Object context, Boolean wasSignaled)at System.Threading._ThreadPoolWaitOrTimerCallbackWaitOrTimerCallback_Context(Object state, Boolean timedOut)at System.Threading._ThreadPoolWaitOrTimerCallbackWaitOrTimerCallback_Context_f(Object state)at System.Threading.ExecutionContextRun(ExecutionContext executionContext, ContextCallback callback, Object state)at System.Threading._ThreadPoolWaitOrTimerCallbackPerformWaitOrTimerCallback(Object state, Boolean timedOut)Thats it. No sign of my own code. Yet, this happens like once or twice a day only, and ONLY on a Windows Vista SP1 installation. Anybody has any ideas whats that where it comes from, etc?CheersAndreas

Process (System.Diagnostics.Process) invoked by aspx hangs on iis6 / win2003

Hello all, I've encountered a problem trying to run an external exe from an aspx page. My code works fine when running under visual studio and also when running under iis7 on windows server 2008 SP1. It does not work on iis6 on windows 2003 sp2: 1. The executable is loaded and uses 560k or so of memory 2. The executable does not use any cpu 3. The executable does not appear to enter Main()  4. The invoking code hangs at WaitForExit() I've tried using different executables including a dummy that simply returned and that did not make any difference. I'm pretty sure that the credentials being used for the executable are correct because if I fudge the password, the process reports a login failure. I'm pretty sure that output blocking to the standard out and standard error streams is not the issue as a) it works on iis7 and b) when I first suspected this as the cause, I re-wrote the aspx to launch threads to read the streams. I've tried invoking my exe directly and via cmd.exe and that makes no difference. Anyway, if anyone has any ideas on this, it would be greatly appreciated. I've included a snippet of my code below. Thanks in advance... ...Beau                     // Create a new process to invoke the console app                     usi

System.Diagnostics not working in IIS 6: Urgent

Hi All, I have developed a ASP.NET C# web page which connects to remote conmputer command prompt using PSEXEC.exe and executes some command where the output of the command will get copied to the page. It works fine in the VS 2005 IDE. If the page is accessed via IIS from IE, the task PSEXEC.EXE appears in task manager of the server with the system account privilege after the method is triggered but nothing happens. Please find my present settings in IIS and others: 1. APP Pool Identity to Local System (Predefined) and also to a configurable admin account. 2. <processModel userName="SYSTEM" password="AutoGenerate" /> in Machine.Config file Also I've tried impersonasation in web.config file to an admin account. I am not able to sort this problem, please help. I've tried a lot spending more time. Code Is:Process p = new Process(); string result = ""; p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.FileName = @"C:\psexec.exe"; p.StartInfo.Arguments = @"\\nawrkxp613 -u domain\usename -p Password1 cmd.exe /c ipconfig"; p.Start(); StreamReader stdOut = p.StandardOutput; p.WaitForExit(); result = stdOut.R

Best Approach for Time Entry System

 Hi folks, need to get some ideas on the best approach for writing a system to log employee and equipment hours, based on the database backend for Abra Timesheets.  This app will only be responsible for entering things like an intra-company group and division and will probably associate equipment hours with a particular person so it will log equipment hours along with the operator/user.  Of course, equipment hours will be able to be modified apart from an employee's hours.  The immediate requirement is that it be Web-based, but there may be a need for it to be disconnected as well.  Is this a job for a Silverlight interface with a dataform, with the potential that it be saved on the user's computer and use an XML data store temporarily when disconnected.  I suppose a smart client app executed from an intranet site could be possible as well?  Any better ideas of the right way to do this? TIA, Steve

CPU Performance over time

Hello trying to get a hold of my cpu useage at 15min intervals starting from 00:00 then 00:15 then 00:30 and so on until 23:45 Cribed this off the interveb which gives it every minute but this is too detailed! DECLARE @ts_now bigint = (SELECT cpu_ticks/(cpu_ticks/ms_ticks)FROM sys.dm_os_sys_info); SELECT TOP(30) SQLProcessUtilization AS [SQL Server Process CPU Utilization],                SystemIdle AS [System Idle Process],                100 - SystemIdle - SQLProcessUtilization AS [Other Process CPU Utilization],                DATEADD(ms, -1 * (@ts_now - [timestamp]), GETDATE()) AS [Event Time] FROM (       SELECT record.value('(./Record/@id)[1]', 'int') AS record_id,             record.value('(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int')             AS [SystemIdle],             record.value('(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]',             'int')

How to Javascript download one time not every Session speed performance

my Side when open every time javascript file download i want only one time download not every time for web site speed performanceHow to Javascript download one time not every Session speed performance

Performance - page is being loaded for the first time vs SubSequent Request

Hello, I have some serious performance Issues with  Windows controls loading first time on IE Browser then subsequent request's. When ever i open Browser first time , mywebsite takes 7 seconds to load, but on subsequent request  without closing browser it loads with-in 2 seconds.I Knew IIS on first time it re-compiles the process and for subsequent request's  it wont perform and it cahches .I'm looking for better  options to improve performance,  when ever  first time reqest's  comes to web server. On IIS 7  Server,I was using both Dynamic and Static compression enabled.Also,On application pool ,I set "ShutDown Time(Limit)" and "Startup Time(Limit") to 90 (seconds).Here is web.config i disable below to improve performance issues.   <trace enabled="false" pageOutput="false" />    <compilation debug="false"/>   Here is the Server Configuration Windows 2008 ServerIIS 7 64   bit Upto Date patches..Net Framework  2.0,3.0,3.5   Need   inputs to improve performance when user call website for  first time...

How do I populate a Textbox with the current system date and time?

Hello, all! First I am a complete newbie and I have a project that I need help with. I am building a Windows form application to keep track of servers and their last maintenence date. I have a simple one table SQL Express database (empty). One of my rows is set up to store the date and time. But first, I need to know how to auto populate the system date and time to a TextBox control everytime someone opens the application. I have tried using the System.DateTime method in the Textbox event properties as a string but I am doing something wrong. Thanks in advance for your help and guidence!
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend