![]() I may end up just looking through the microsoft documentation, but I think we all know how painful that can be.įor Narue: This is the latest code for the efficiency test, and you will find the results to be quite identical. But my question is if there are any functions in the ctime library that would reset the clock() variable. And sorry, replace iX and iY with iY and iX in the first loop and you will find that they are indeed identical results.Īnd as for the above solution to my problem, that is indeed the 'fix' i used. My argument is based entirely on efficiency - the number of calculations required to get the same end result. This is using the same logic as the fastest runner is the best runner in the race, which I hope you can draw a logical connection with. I'm sorry if a 1300% increase in speed isn't considered better in your opinion, you may be thinking in terms of robustness and end user usability. ![]() I'm curious how you think that this: iX = i % ROW It's a very amusing test, seeing as how an accurate comparison of a feature and it's alternative should produce the same results for both when hoisted out of the timing loop. >You're all welcome to show your instructors this =) I find it humorous that you seem to think "fastest" and "best" are synonymous. >I'm trying to prove to my teacher that Div and Mod isn't always the best way to solve things. Although mod/div is occassionally neccessary. You're all welcome to show your instructors this =). Mod/Div method : 1492 clock ticks or about 1500 millisecondsīasic Iteration : 160 clock ticks or about 165 milliseconds ![]() Does anyone know a reset clock() method?įor anyone who's interested, here's the results from this program (in terms of efficiency): My only issue is that i'm not sure how to reset the clock(), so it has to be run in 2 different instances - one with mod/div commented out, one with it commented in. The div/mod code and the basic iteration both do essentially the same thing (in the program we had to make) which is to plot squares appropriately on a grid. Descrip: This was made to prove that mod/div operations are often quite inefficient compared to their more basicĬout << "\n\nClock ticks for calculation: " << clock() Ĭout << " << CLOCKS_PER_SEC << " For Duration: " << clock() / (CLOCKS_PER_SEC / 1000) << " milliseconds" So i created this tiny program, held entirely in main.cpp : //Project: Mod_Efficiency Ok, so I'm trying to prove to my teacher that Div and Mod isn't always the best way to solve things.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |