Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WPF - how to time an activity?

Status
Not open for further replies.

BenBroadway1501

Programmer
Apr 6, 2011
2
US
I would like to find out how long (in milliseconds) it takes an activity to occur in WPF. For example, if I click a button to display a jpeg on the screen, I'd like to find out how many milliseconds it takes from my click of the mouse to the end of the screen update. Another example: if I have a datagrid and want to refresh the data, how long does that refresh take?

Having a precise number of milliseconds for the activity, I could then try different strategies to optimize the program.

I've looked at WPF Performance Suite, which is very nice for graphical analysis, but I haven't yet found a number output.

Any suggestions are great appreciated!

Thanks,
Ben
 
Note that adding performance tracking inhibits the performance of the app.
The easiest way is by adding a variable at the beginning which logs the start time, then the next to last thing is a trace/debug.print with the difference.
If you need long term or aggregating tracking, then you should create a data structure and do all the writes AFTER the logic in the function has completed.


Sidebar: There was a great anecdote about a game company increasing the FPS rate of the game by optimizing the FPS counter function.

Lodlaiden

If [blue]you have problems[/blue], I want [green]source code[/green] AND [green]error messages[/green], none of this [red]"there was an error crap"[/red]
 
JetBrains dotTrace and Ants Profiler are the tools you would want to use to profile the code.

typically remote calls (IO and database) are your bottlenecks. how many calls and the quantity of data returned from each call.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top