Benchmarking

Discussion in 'C++' started by Carlo Razzeto, Nov 19, 2004.

  1. 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
     
    Carlo Razzeto, Nov 19, 2004
    #1
    1. Advertising

  2. 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
     
    Victor Bazarov, Nov 19, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Martin Schoeberl

    Benchmarking embedded Java

    Martin Schoeberl, Sep 24, 2004, in forum: Java
    Replies:
    1
    Views:
    499
    Martin Schoeberl
    Sep 25, 2004
  2. Andy Dingley
    Replies:
    3
    Views:
    895
    Andy Dingley
    Feb 11, 2004
  3. Jerry Coffin

    Benchmarking

    Jerry Coffin, Jun 20, 2004, in forum: C++
    Replies:
    0
    Views:
    406
    Jerry Coffin
    Jun 20, 2004
  4. Jerry Coffin

    Benchmarking, part 2

    Jerry Coffin, Jun 21, 2004, in forum: C++
    Replies:
    8
    Views:
    413
    David Harmon
    Jun 26, 2004
  5. Project2501
    Replies:
    1
    Views:
    392
Loading...

Share This Page