I currently have the following method for writing vector<int> objects to a binary file.
void save_config(std::string fname, std::vector<int> config) {
std::ofstream out(fname);
for (auto&& item : config)
out << item;
}
The data I need to save, however, is on the order of 60 MB and takes about 5 seconds to write with this function. Furthermore, I have to write a binary file for each iteration of an algorithm I am running, and a single iteration for an input size which generates data on this order of magnitude is probably about 500 milliseconds.
I can mask the write time behind the algorithm's execution time but, with this difference in runtime, it won't really matter. Is there any way to improve my save_config function? Also, I'm using a binary file because I've ready that it is the fastest format to write to; but the specific format does not matter so, if someone has an alternate suggestion, I would be happy to hear it.