I am currently working on a school project that requires me to test algorithms multiple times and calculate average times. I would like to dump all of my data into a CSV file and make a graph of the average runtimes after everything is said and done. My problem is that I'm not entirely sure about the syntax of it all. Here is what I have so far:
//test number
for (int a = 1; a <= 40; ++a)
{
//run function 41 times per test and take data
for (int i = 0; i <= 200; i += 5)
{
int vector_size;
if (i == 0)
vector_size = 10;
else
vector_size = 10 * i;
std::vector<int> medians_vector = make_vector(vector_size);
auto time_before_function = std::chrono::high_resolution_clock::now();
//function call
auto time_after_function = std::chrono::high_resolution_clock::now();
execution_time = std::chrono::duration_cast<std::chrono::microseconds>(time_after_function - time_before_function).count();
if (a == 1)
{
csv_files.open("vector.size-time.csv", std::ios::app);
csv_files << vector_size << ", " << execution_time << std::endl;
csv_files.close();
csv_files.clear();
}
else
{
csv_files.open("vector.size-time.csv", std::ios::app | std::ios::end);
csv_files << vector_size << ", " << execution_time << std::endl;
csv_files.close();
csv_files.clear();
}
total_time += execution_time;
++iterations;
}
}
average_time = total_time / iterations;
std::cout << "Merge_select took a total time of ";
print_time(total_time);
print_average_time(average_time, iterations);
As you can see, I have most of the logic down. All I need is the loop or logic to get me onto the next column. Something has to be done here:
else
{
csv_files.open("vector.size-time.csv", std::ios::app | std::ios::end);
csv_files << vector_size << ", " << execution_time << std::endl;
csv_files.close();
csv_files.clear();
}
That's all I know. I was hoping there was an ios::start function or something like that, but there is not.
With all of this being said, how do I make a proper CSV table with all test times in their respective columns?
Thank you,
--Matt
Aucun commentaire:
Enregistrer un commentaire