+ 1

fstream performance

I have a object of std::fstream and trying to write a file using same. I am doing below operations: fstream file.open(fileName); float a,b,c; file << a; file << " "; file << b; file << " "; file << c; Is this good option to do? What if I do as below: string s = to_string(a) + " " + to_string(b) + " " to_string(c); file << s; Will second version improve performance or not?

8th Nov 2022, 6:17 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
1 Resposta
+ 2
You can use this to Benchmark ... https://code.sololearn.com/cDpd9e27N7XC/?ref=app you would use it like this { // put the part which you need to benchmark in block Timer timer{"name of benchmark"}; // perform the task }
9th Nov 2022, 3:45 AM
Prashanth Kumar
Prashanth Kumar - avatar