Archived

This forum has been archived. Please start a new discussion on GitHub.

returned value of IceUtil::Time::now()

Hey-

I hope to verify the unit of the returned value of IceUtil::Time::now(). From P.753 of manual "Ice-3.1.1.pdf", the returned value is a double, I think.

My question: Which unit is this value for, seconds or milliseconds or else?

Thanks!
Yongsheng

Comments

  • marc
    marc Florida
    IceUtil::Time::now() returns an instance of the IceUtil::Time class. You can then use the various toXXX methods to get the time as 64-bit integer or as double. For example, toSecondsDouble() gives you the time as a double in seconds.
  • Hi Marc,

    Here are a few lines in the file Ice-3.1.1/demo/Ice/throughput/Client.cpp :

    tm = IceUtil::Time::now() - tm;
    cout << "time for " << repetitions << " sequences: " << tm * 1000 << "ms" << endl;
    cout << "time per sequence: " << tm * 1000 / repetitions << "ms" << endl;


    The .toXXX wasn't used in the lline "tm = IceUtil::Time::now() - tm;" so I wonder whether tm is in seconds.

    But from tm * 1000 << "ms" in next line, I suppose tm was in seconds. Just want to make sure because I am quoting these lines in my coding work.

    Thanks!
    Yongsheng
  • OK. I have confirmed that it is in seconds by default.
  • benoit
    benoit Rennes, France
    Hi,

    The tm variable is an IceUtil::Time which can be converted to any units you like with the toXXX methods. As you discovered, the output of an IceUtil::Time on a [noparse]std::ostream[/noparse] is in seconds, that's why the tm variable is multiplied by 1000 first before printing it on cout in the throughput demo.

    Cheers,
    Benoit.