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:

  1. loop through each , every file , fill file details(path) in database(sqlite3).
  2. while each file encountered,keep counter , print same via std::cout. time taken execute program:30mins

scenario 2:

  1. 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

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -