Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // endl: 5035 ms
- // '\n' : 695 ms
- // Использование endl может приводить к снижению скорости вывода в файл, cerr или cout
- #include <iostream>
- #include <vector>
- #include <fstream>
- #include "log_duration.h"
- using namespace std;
- int main()
- {
- {
- LOG_DURATION("endl");
- ofstream out("output.txt");
- for (int i = 0; i < 150'000; ++i)
- {
- out << "London is the capital of GreatBritain. "
- << "I am travellong down the river"
- << endl;
- }
- }
- {
- LOG_DURATION("'\\n'");
- ofstream out("output2.txt");
- for (int i = 0; i < 150'000; ++i)
- {
- out << "London is the capital of GreatBritain. "
- << "I am travellong down the river"
- << '\n';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment