Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Benchmarking (http://www.velocityreviews.com/forums/t287039-benchmarking.html)

Carlo Razzeto 11-19-2004 04:13 PM

Benchmarking
 
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



Victor Bazarov 11-19-2004 04:37 PM

Re: Benchmarking
 
Carlo Razzeto wrote:
> 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


All times are GMT. The time now is 07:14 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.