Very surprising perfs of fprintf vs std::ofstream (fprintf is very slow)
问题 I was running some benchmarks to find the most efficient way to write a huge array to a file in C++ (more than 1Go in ASCII). So I compared std::ofstream with fprintf (see the switch I used below) case 0: { std::ofstream out(title, std::ios::out | std::ios::trunc); if (out) { ok = true; for (i=0; i<M; i++) { for (j=0; j<N; j++) { out<<A[i][j]<<" "; } out<<"\n"; } out.close(); } else { std::cout<<"Error with file : "<<title<<"\n"; } break; } case 1: { FILE *out = fopen(title.c_str(), "w"); if