Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Get time using multiple threads in C++

    Posted 04/25/12 07:52 PM

    Originally posted by: Trino


    Hi, I'm running my model in a PC with a processor of 4 cores and I tried to use the function clock(), as usual, to get the elapsed time, but when cplex run with more than 1 thread the time calculated using clock() is not right. I imagine the cause is that clock() returns the number of clocks that the program have used, but it consider the clocks of all 4 cores, so I end up with a value which I can't properly be used to calculate the time.

    Is there a way to get the real elapsed time, or at least an approximation like cplex do in its log even if when there is more than 1 thread?

    Thanks,
    Bruno.
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Get time using multiple threads in C++

    Posted 04/26/12 01:26 AM

    Originally posted by: SystemAdmin


    IloCplex::getCplexTime() gets a timestamp in the time for which the IloCplex instance is configured (see parameter IloCplex::ClockTime). The difference between two such timestamps gives you the elapsed time. Set this parameter to wallclock time if you want to have get the elapsed wallclock time.
    You can also use POSIX function gettimeofday() for wallclock time and [times()|
    http://pubs.opengroup.org/onlinepubs/009604599/functions/times.html] for CPU time. A third option is clock_gettime().
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Get time using multiple threads in C++

    Posted 04/26/12 09:45 AM

    Originally posted by: Trino


    Thanks, that was exactly what I needed.
    #CPLEXOptimizers
    #DecisionOptimization