| re: Benchmarking
Carlo Razzeto wrote:[color=blue]
> Hey there, I have a question about benchmarking. I'm hoping you can help but
> I'm not sure if this group is dedicated to just standard C++.[/color]
Take a habit of checking the newsgroup's FAQ and reading it a bit before
posting to it, and you will never have to make such statements.
To dimiss your doubts, yes, this newsgroup is dedicated to just standard
C++ language (and library).
[color=blue]
> Here's the
> question, I have a piece of code I would like to benchmark down to less than
> a second
> resolution.[/color]
This is not guaranteed by the language. 'clock' resolution can be 1 tick
per second, for all we know.
[color=blue]
> Previously, when I wanted to do this for a merge sort function I
> was able to just include time.h declare a couple of clock_t's and do the
> path. However for my current project that doesn't seem to be working out.
>
>
>
> Specifically what I'm trying to benchmark right now is how much time I'm
> waiting to complete a read and write operation over a network socket. My
> program encodes some data in XML and pushes it out to a server over a raw
> socket to be processes. Currently it takes about one second to push out 5
> messages which to me seems pretty darned slow. My problem is when I do the
> following:
>
>
>
> clock_t start = 0;
>
> clock_t end = 0;
>
>
>
> start = clock();
>
> .....
>
> Perform read/write operation
>
> .....
>
> end = clock();
>
>
>
> I will get the same value for start and end, thus as far as my program is
> concerned it took no time at all to process the request (something I'm
> having a hard time believing). A co-worker of mine looked up the clock in
> one of his MS chm files and according to that clock() will only return the
> number of clocks while your program was running, there for if I'm spending
> all my time in I/O wait it wouldn't work out. I'm not sure if that's
> universally true, and my project runs runs on linux and not windows. If
> anyone can help that would be great. Thanks,[/color]
Use a profiler, 'gprof'. Post to comp.os.linux.development.apps.
V |