c++ - Affect on std::cout on performance of the program -
i have written program fetch file details , place them in sqlite database. in process have observed 2 scenarios:
scenario 1:
- loop through each , every file , fill file details(path) in database(sqlite3).
- while each file encountered,keep counter , print same via std::cout. time taken execute program:30mins
scenario 2:
- loop through each , every file , fill file details(path) in database(sqlite3).
time taken execute program:7mins
i unclear of why because of std::cout
,the time taken 5 times more of not printing it?
any pointers on scenario highly appreciated.thanks lot.
regards, ravi
try use std::ios_base::sync_with_stdio(false)
, default std::cout sync stdio
Comments
Post a Comment