Added instructions and info on the getStr function

This commit is contained in:
2019-03-29 12:50:27 -04:00
parent f2f4782b06
commit 89245b00f5

View File

@@ -40,7 +40,8 @@ It is so simple that I currently just include it in files rather than using it a
start() creates the first time stamp that will later be used to calculate the amount of time that has passed. This function should be called before stop is called. start() creates the first time stamp that will later be used to calculate the amount of time that has passed. This function should be called before stop is called.
stop() creates the second time stamp that will later be used to calculate the amount of time that has passed. This function should not be called before start has been called. stop() creates the second time stamp that will later be used to calculate the amount of time that has passed. This function should not be called before start has been called.
getTime() acts slightly differently based on what functions have been called. If neither start() nor stop() has been called then it will return -1. If start() has been called, but not stop() it will return the difference in time between when start was called and now. If both start and stop were called it will return the differenct in time between the time those two functions were called. Time will be returned in the default resolution of std::chrono::high_resolution_clock (currently nanoseconds). getTime() acts slightly differently based on what functions have been called. If neither start() nor stop() has been called then it will return -1. If start() has been called, but not stop() it will return the difference in time between when start was called and now. If both start and stop were called it will return the differenct in time between the time those two functions were called. Time will be returned in the default resolution of std::chrono::high_resolution_clock (currently nanoseconds).
getNano(), getMicro(), getMilli(), getSeconds(), getMinutes(), getHours(). All of these function work in the same way as getTIme, but returns the time in a specific resolution. (nanoseconds, microseconds, milliseconds, seconds, minutes, hours) getNano(), getMicro(), getMilli(), getSeconds(), getMinutes(), getHours(). All of these function work in the same way as getTime, but returns the time in a specific resolution. (nanoseconds, microseconds, milliseconds, seconds, minutes, hours)
getStr() returns a string with the "best" time resolution. It looks for a XXX.XXX <TimeResolution> format. It switches to minutes after 120 seconds and hours after 120 minutes
reset() resets all variables in the class back to their defaults. This function is meant to be called if you want to use the same timer multiple times in a program. It shouldn't be necessary to call, but it is still safer and you are less likely to run in to any kind of bugs. reset() resets all variables in the class back to their defaults. This function is meant to be called if you want to use the same timer multiple times in a program. It shouldn't be necessary to call, but it is still safer and you are less likely to run in to any kind of bugs.
Usage exampe: Usage exampe:
mee::Stopwatch timer; mee::Stopwatch timer;
@@ -48,6 +49,8 @@ Usage exampe:
//Your timed code here //Your timed code here
timer.stop(); timer.stop();
std::cout << "It took " << timer.getMilli() << " milliseconds to run this algorithm"; std::cout << "It took " << timer.getMilli() << " milliseconds to run this algorithm";
//Or more simply if you don't know the run time or are afraid there might be different run times on different machines
std::cout << "It took " << timer.getStr() << " to run this algorithm";
#TermColors #TermColors