Boost logo

Boost :

Subject: Re: [boost] [chrono] Thread clock compatibility problems on Android
From: Libor Bus (libor.bus_at_[hidden])
Date: 2011-05-14 15:30:40


Vicente Botet wrote:
>
>
> Libor Bus wrote:
>>
>>
>> Vicente Botet wrote:
>>>
>>>
>>>
>>>> Regarding process_cpu_clock, I have experienced that following code
>>>> provided on Linux wrong text output, while on Windows was ok:
>>>> {
>>>> boost::stopwatches::stopclock<> timer;
>>>> ... some work
>>>> }
>>>>
>>>
>>> Could you give me output on both cases?
>>>
>>
>> Consider following code snippet:
>> {
>> boost::stopwatches::stopclock<> boost_timer;
>> for( int i = 0; i < 10000000; i++)
>> sqrt( 123.456L);
>> sleep( 1); // sleep 1s
>> }
>>
>> Text output on windows is:
>> real 1.031s, cpu 0.031s (3.0%), user 0.031s, system 0.000s
>> while thread clock measures: wall=1031ms, cpu=31ms
>>
>> Text output on Android (on Linux was similar) is:
>> real 0.001s, cpu 0.000s (23.2%), user 0.000s, system 0.000s
>> while thread clock measures: wall=1377ms, cpu=312ms
>>
>> Test on Android was around 10x slower because I run it on Android
>> emulator (can not test Linux right now). Behaviour on Linux I saw couple
>> of days ago was same as on Android, i.e., stopclock provided wrong text
>> output, just test was similar fast as on Windows.
>>
>> Hope this helps.
>>
>
> On which linux dis you tried?
>
> It seems that the posix process_cpu_clocks is not working on this
> platform. This clock uses
>
> tms tm;
> clock_t c = ::times( &tm );
>
> Could you dump the values of c and tm.tms_stime + tm.tms_cstime,
> tm.tms_utime + tm.tms_cutime, before and after the sleep?
>
> Thanks,
> Vicente
>

Log outputs from Android emulator are:
times()-begin: c1=13829 tm1.tms_stime + tm1.tms_cstime=18, tm1.tms_utime +
tm1.tms_cutime=638
times()-end: c2=13966 tm2.tms_stime + tm2.tms_cstime=18, tm2.tms_utime +
tm2.tms_cutime=670
real 0.001s, cpu 0.000s (23.9%), user 0.000s, system 0.000s
thread_clock: wall=1376ms, cpu=318ms

Libor

--
View this message in context: http://boost.2283326.n4.nabble.com/chrono-Thread-clock-compatibility-problems-on-Android-tp3520310p3522983.html
Sent from the Boost - Dev mailing list archive at Nabble.com.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk