tags:

views:

54

answers:

1

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

+5  A: 

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.

Charles Bailey
How about the Visual C++ implementation ?
bugspy.net
@bugspy: Just get your code working first in an easy to read and maintain manner. Profile *when you're done* so you're not guessing what's slow, and can actually see what's slow. It doesn't matter until then, write what you need. If you *have* to call it, it doesn't really matter, does it?
GMan
@bugspy.net: I've never measured tellp() on any version of Visual C++ because I've never needed to. Even if I were to go away and measure it now it's not going to help you because I wouldn't be running on your environment (hardware, installed software options, etc.). I don't believe it's a very expensive call but why take any note of my total guess?
Charles Bailey
@GMan Right, but if it turns out to be a really expensive call, I could do some compromises. For example by calling it just few hundreds times a second instead of thousands (on the expense of accuracy)
bugspy.net
@bugspy.net: If it turns out to be really expensive, worry about it then. You're going to paralyze yourself if you try to find only the ultimate solution to every problem before you even start coding.
cHao