-
September 18th, 2015, 03:42 PM
#1
Alternative to cout logging in Windows Environment.
I find out that Java println and many fold faster than cout in C++.
I am currently using cout as a quick visual logging tool.
I wonder how I can make the same lightning fast text output in C++?
Thanks
Jack
-
September 18th, 2015, 05:25 PM
#2
Re: Alternative to cout logging in Windows Environment.
-
September 18th, 2015, 05:36 PM
#3
Re: Alternative to cout logging in Windows Environment.
How can I output to a separate standalone console pane just for debugging instead of interweaving other debug outputs to the same pane?
Thanks
Jack
-
September 19th, 2015, 05:43 PM
#4
Re: Alternative to cout logging in Windows Environment.
What I usually prefer is using plain text logging to disk file (lightning fast ) along with a tool that autodetects file update and dispalys the file tail (in my case it's always FAR Manager viewer). The most beatiful thing about this approach is that the log remains available for offline analysis, e.g. grepping.
Oh, one more thing: I never use cout, but always do use printf. Lightning fast
Last edited by Igor Vartanov; September 19th, 2015 at 05:51 PM.
Best regards,
Igor
-
September 20th, 2015, 04:57 AM
#5
Re: Alternative to cout logging in Windows Environment.
Oh, one more thing: I never use cout, but always do use printf. Lightning fast
It has been shown in these forums previously that i/o using the c library functions is faster than using the c++ i/o streams (for MS).
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
September 21st, 2015, 11:05 AM
#6
Re: Alternative to cout logging in Windows Environment.
things like this Always end up being about programmer convenience vs performance.
if speed is really your concern. Then low level file IO with your own formatting is going to beat the pants out of anything.
C FILE io offers buffered and formatted IO at a cost.
C++ io offers buffered, formatted, and typed IO (and easy changing to other stream types) at an even larger cost.
Part of the problem of cout in particular is that output is constantly being flushed, which negates part of buffering features.
file stream io can be made faster by increasing the internal buffer.
-
September 21st, 2015, 02:54 PM
#7
Re: Alternative to cout logging in Windows Environment.
Why not use a logging library that allows you to configure the outputs (log to file, log to console, log to the debugger, log to the event viewer (windows), etc.)?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|