How to determine how variables change in Visual Studio

Does anyone know how to determine how an observed variable changes over time in Visual Studio 2010? That is, if you have the following code

double someVariable; for ( int i = 0; i < 20; i++) { someVariable = Math.Pi() * i; } 

and you looked at "someVariable" in the idea, you could go through the code and see how it grows with each step. I would like to be able to run the loop and draw what this variable did, because of the need to manually go through it. I do a lot of math and sometimes watch how change is changing, really useful and insightful.

Additional Information: I have several slightly different solvers, and depending on the problem I was looking for, I would like to look at different variables to see where the problems arise. I am currently placing these variables in a log file, but this slows down the solution significantly, and I have to spend a decent amount of time changing the debugging code to identify problems. I am looking for a way to use slicker which is IDE oriented. Type of visualizer on steroids.

+7
source share
6 answers

How to use trace points? In VS 2008 (this is slightly different in VS 2010), you simply add a normal breakpoint, then right-click it, then select "When Hit ...".

In the next dialog box, check the box next to "Print a message" and enter something like

 someVariable = {someVariable} 

This will simply output its value to the output window in the IDE.

Screenshot:

tracepoint dialog

+7
source

Easy way? Are absent.

But you can program it yourself ..

  • Use property.
  • In setter, put the code that will be registered in some collection. It may also save time.
  • Use some kind of charting mechanism to create this collection.

Edit: If you do not want to create a property, you can create some general class that will have this property and have some kind of internal logging logic.

+1
source

Use Perfmon and post this value to the counter that perfmon can read. Perfmon does all the conspiracy, etc. You just need to publish for perfmon. Unfortunately, it is not very well documented and is not trivial. (well, at least that wasn't trivial for unmanaged C ++ when I was learning it)

I did this a while ago and used some of the classes published in an old MSJ article. (circa 1998)

I will try to find some online docs.

See this question for some links.

It may also be useful.

If you find a solution or it works for you, let us know.

+1
source

Hope someone comes up with a better answer, but here is what I did in a similar situation ...

I output values ​​in CSV format to the console. From there I would copy and paste into Excel, and Excel made the graphics for me. It worked well enough, but was a complete hassle during a caffeine development session.

0
source

Can't you just define and massage and write someVariable to array [i] inside the loop? You can then refer to it after you are done.

 double[] x = new double[20]; double someVariable; for ( int i = 0; i < 20; i++) { someVariable = Math.Pi() * i; x[i] = someVariable; } 
0
source

I found SpPerfChart very easy to use and useful. Just add a user control and enter your changing data. You will get a graph of any number you enter in real time.

0
source

All Articles