mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-06 17:13:59 -05:00
Fixed bug causing incorrect time for run all
This commit is contained in:
@@ -147,14 +147,13 @@ void runAll(){
|
||||
//Run through all valid problem numbers, skipping a few that are in the tooLong vector
|
||||
for(unsigned int cnt = 1;cnt < PROBLEM_NUMBERS.size();++cnt){
|
||||
unsigned int problemNumber = PROBLEM_NUMBERS[cnt];
|
||||
double totalTime = 0;
|
||||
|
||||
//Get the problem
|
||||
Problem* problem = getProblem(problemNumber);
|
||||
|
||||
//Run the problem the specified number of times
|
||||
std::cout << problemNumber << ". " << problem->getDescription() << '\n';
|
||||
runProblem(problem, timesToRun);
|
||||
double totalTime = runProblem(problem, timesToRun);
|
||||
|
||||
//Print the results
|
||||
std::cout << getBenchmarkResults(problem, totalTime, timesToRun);
|
||||
@@ -194,14 +193,14 @@ double runProblem(Problem* problem, unsigned int timesToRun){
|
||||
}
|
||||
|
||||
//Prints the benchmark results of a problem
|
||||
std::string getBenchmarkResults(Problem* problem, double totalTime, unsigned int timesRan){
|
||||
std::string getBenchmarkResults(Problem* problem, double totalTime, unsigned int timesRun){
|
||||
//Calculate the average run time of the problem
|
||||
totalTime /= timesRan;
|
||||
totalTime /= timesRun;
|
||||
std::string timeResults = mee::Stopwatch::getStr(totalTime);
|
||||
//Tally the results
|
||||
std::stringstream results;
|
||||
results << "\n\n" << problem->getString();
|
||||
results << "\nIt took an average of " << timeResults << " to run this problem over " << timesRan << " iterations\n\n" << std::endl;
|
||||
results << "\nIt took an average of " << timeResults << " to run this problem over " << timesRun << " iterations\n\n" << std::endl;
|
||||
return results.str();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user