-
Notifications
You must be signed in to change notification settings - Fork 2
Debugging code
Debugging is a valuable tool to study code.
There were some questions in comments how to do that. Here are some notes and advises.
To run MCSimulator
in debug build debug version. Click right mouse button over MCSimulator
project in the Solution Explorer
and select Set as StartUp Project
.
MCSimulator
by default uses all CPU
cores. This will cause difficulties in stepping in the code due to jumping through different threads. You can switch to single thread by directly setting variable nThreads
to one in the main function. See fragment of MCSimulator.cpp
below.
int i;
//int nThreads = concurrency::GetProcessorCount();
int nThreads = 1;
The tricky part is providing program arguments and working directory. It should be done through the MCSimulator
project properties. One possible scenario for the GitHub version of folders structures is shown in the next figure. First time create folder MC\work
where you will run debug simulation.
Then start debugging.
Remember about the code execution performance. In the past the difference in speed between debug and release was of the order of 2. Modern compiler continuously improve and use hardware features including GPU even if programmer did not request that. Now the speed up can be up to an order or more depending on code.