Benchmarking

C

Carlo Razzeto

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++. Here's the
question, I have a piece of code I would like to benchmark down to less than
a second
resolution. 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,



Carlo Razzeto
 
V

Victor Bazarov

Carlo said:
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++.

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).
Here's the
question, I have a piece of code I would like to benchmark down to less than
a second
resolution.

This is not guaranteed by the language. 'clock' resolution can be 1 tick
per second, for all we know.
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,

Use a profiler, 'gprof'. Post to comp.os.linux.development.apps.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top