Home Help Center

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

yongshengyongsheng Member Yongsheng MaOrganization: Dawning Supercomputing Co.Project: cluster
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

  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    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.
  • yongshengyongsheng Member Yongsheng MaOrganization: Dawning Supercomputing Co.Project: cluster
    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
  • yongshengyongsheng Member Yongsheng MaOrganization: Dawning Supercomputing Co.Project: cluster
    OK. I have confirmed that it is in seconds by default.
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    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.
Sign In or Register to comment.