I have written a program which would fetch file details and place them in the SQLite database. In this process i have observed two scenarios:
Scenario 1:
Scenario 2:
Time taken to execute this program:7mins
I am very unclear as of why just because of std::cout
,the time taken is 5 times more than that of not printing it?
Any pointers on this scenario is highly appreciated.Thanks a lot.
Regards, Ravi
尝试使用std::ios_base::sync_with_stdio(false)
,默认情况下std :: cout与stdio同步
Printing to console is costly. Usually more time-consuming than writing to a file.
I bet your code could run in less than a minute. Make sure you surround some inserts in a transaction . You can also use multiple inserts in one statement, like explained in answers to this question .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.