For some reason I'm unable to get my output stream to run any faster with the line
std::ios_base::sync_with_stdio(false);
included at the beginning of my program. I'm testing this with these two programs:
#include <iostream>
int main() {
for (int i = 0; i < 500000; i++)
std::cout << "Hello World\n";
}
and
#include <iostream>
int main() {
std::ios_base::sync_with_stdio(false);
for (int i = 0; i < 500000; i++)
std::cout << "Hello World\n";
}
The run time for each program is as follows
first_test (synced)
real 0m1.095s
user 0m0.472s
sys 0m0.299s
second_test (with synced turned off)
real 0m1.091s
user 0m0.471s
sys 0m0.299s
I'm compiling with g++ -O3 main.cpp. I'm on a mac running 10.11.1.
Is there any way to get the output stream to perform faster by turning sync_with_stdio off?