I want to call it in a tight loop thousands of times per second . Is it an expensive call? I am using Windows Visual C++ .
This is an old question, but I will answer anyway, in case there will be other people looking for an answer.
So we have a logging library, which uses streams and tellp for determining the size of the file. It did call tellp for every log being made.
So with tellp 1 log line would take aprox 20 microseconds depending on the machine. Without it the log takes about 1 microsecond.
So yes depending on your domain it might be very expensive or it might not matter at all.
p.s. first rule of optimisation - don't optimise..
C++ doesn't mandate the performance (in seconds) of any particular parts of that standard library (although many containers and algorithms have complexity requirements).
This means that you are at the mercy of your implementation. The only reliable thing to do is to measure it and see if it is acceptable in your application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With