Stopwatch sw = new Stopwatch();
sw.Start();
//fill your code in here to do stuff
sw.Stop();
Last post I mentioned Stopwatch in the title. Well, I didn’t mention it anywhere else. I was going to explain that I found a stopwatch method for my math game I’m working on. The Stopwatch starts at Start(), and then you fill in the code to run while the Stopwatch method is running. After your code is complete, you then call Stop(). From what I understand, it’s precision is based off of your computers CPU, and if you are like most modern computers, you have multi-core CPU’s. So theoretically, if I’m understanding correct, the Stopwatch() will choose a core to run on, which could change the count and make it off by some milliseconds or something. From what I understand, this isn’t much of a deal as nothing I’m going to make is mission critical regarding counting time to the millisecond.
This post is going to be short, as I start my work weekend. I haven’t done much on the math game save for refactoring and reducing the codebase down some 500 lines. I realized I was not practicing DRY very well. Currently thinking of a way to save old score from the game so a user can see past games. This will be only on the instance they are playing, as I’m not saving files or databases at this moment. I don’t know how to do that yet.