public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] measure the execution time of each thread
@ 2011-04-15 17:11 moktar_bouain
  2011-04-18 17:03 ` Michael Bergandi
  2011-04-19  6:06 ` Yurij Grechishhev
  0 siblings, 2 replies; 14+ messages in thread
From: moktar_bouain @ 2011-04-15 17:11 UTC (permalink / raw)
  To: ecos-discuss


Hello,

I create an application with eCos containing 3 threads,i like to measure the
execution time of each thread ??
-- 
View this message in context: http://old.nabble.com/measure-the-execution-time-of-each-thread-tp31407684p31407684.html
Sent from the Sourceware - ecos-discuss mailing list archive at Nabble.com.


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ECOS] measure the execution time of each thread
  2011-04-15 17:11 [ECOS] measure the execution time of each thread moktar_bouain
@ 2011-04-18 17:03 ` Michael Bergandi
  2011-04-18 22:01   ` moktar_bouain
  2011-04-19  6:06 ` Yurij Grechishhev
  1 sibling, 1 reply; 14+ messages in thread
From: Michael Bergandi @ 2011-04-18 17:03 UTC (permalink / raw)
  To: moktar_bouain; +Cc: ecos-discuss

> I create an application with eCos containing 3 threads,i like to measure the
> execution time of each thread ??

http://ecos.sourceware.org/docs-latest/ref/kernel-clocks.html

static cyg_tick_count_t run_time;
cyg_tick_count_t start, end, run_time;

while (1) {
   start = cyg_current_time();

   <processing ...>

   end = cyg_current_time();
   run_time = end - start;
}

Then you just need to convert ticks to time, based on the tick rate
for your platform.

--
Mike

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ECOS] measure the execution time of each thread
  2011-04-18 17:03 ` Michael Bergandi
@ 2011-04-18 22:01   ` moktar_bouain
  2011-04-18 22:50     ` Gary Thomas
  0 siblings, 1 reply; 14+ messages in thread
From: moktar_bouain @ 2011-04-18 22:01 UTC (permalink / raw)
  To: ecos-discuss


>http://ecos.sourceware.org/docs-latest/ref/kernel-clocks.html

>static cyg_tick_count_t run_time;
>cyg_tick_count_t start, end, run_time;

>while (1) {
  > start = cyg_current_time();

   ><processing ...>

   >end = cyg_current_time();
   >run_time = end - start;
>}

>Then you just need to convert ticks to time, based on the tick rate
>for your platform.

Hi Mike,
Thank you for your  reply.
I tried with your solution,but the value of run_time is always
constant.(run_time =1)



-- 
View this message in context: http://old.nabble.com/measure-the-execution-time-of-each-thread-tp31407684p31428080.html
Sent from the Sourceware - ecos-discuss mailing list archive at Nabble.com.


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ECOS] measure the execution time of each thread
  2011-04-18 22:01   ` moktar_bouain
@ 2011-04-18 22:50     ` Gary Thomas
  2011-04-18 23:32       ` moktar_bouain
  0 siblings, 1 reply; 14+ messages in thread
From: Gary Thomas @ 2011-04-18 22:50 UTC (permalink / raw)
  To: moktar_bouain; +Cc: ecos-discuss

On 04/18/2011 04:00 PM, moktar_bouain wrote:
>
>> http://ecos.sourceware.org/docs-latest/ref/kernel-clocks.html
>
>> static cyg_tick_count_t run_time;
>> cyg_tick_count_t start, end, run_time;
>
>> while (1) {
>    >  start = cyg_current_time();
>
>     ><processing ...>
>
>     >end = cyg_current_time();
>     >run_time = end - start;
>> }
>
>> Then you just need to convert ticks to time, based on the tick rate
>> for your platform.
>
> Hi Mike,
> Thank you for your  reply.
> I tried with your solution,but the value of run_time is always
> constant.(run_time =1)

Note that this technique is only accurate to the system tick time
which is normally 10ms.  If your thread runs for less time than this,
you won't know.

Look at the test program tm_basic.cxx for details on how to measure
at a finer grain (without the overhead of decreasing the tick time).

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ECOS] measure the execution time of each thread
  2011-04-18 22:50     ` Gary Thomas
@ 2011-04-18 23:32       ` moktar_bouain
  2011-04-19 11:07         ` Gary Thomas
  0 siblings, 1 reply; 14+ messages in thread
From: moktar_bouain @ 2011-04-18 23:32 UTC (permalink / raw)
  To: ecos-discuss



>Note that this technique is only accurate to the system tick time
>which is normally 10ms.  If your thread runs for less time than this,
>you won't know.

>Look at the test program tm_basic.cxx for details on how to measure
>at a finer grain (without the overhead of decreasing the tick time).

I use eCos for Sparc (Leon3 processor) with a 66 MHz.
Means that the clock tick  corresponds to 1.5×10-5ms(15ns).
is it possible  to measure the execution time of a thread??
-- 
View this message in context: http://old.nabble.com/measure-the-execution-time-of-each-thread-tp31407684p31428511.html
Sent from the Sourceware - ecos-discuss mailing list archive at Nabble.com.


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ECOS] measure the execution time of each thread
  2011-04-15 17:11 [ECOS] measure the execution time of each thread moktar_bouain
  2011-04-18 17:03 ` Michael Bergandi
@ 2011-04-19  6:06 ` Yurij Grechishhev
  1 sibling, 0 replies; 14+ messages in thread
From: Yurij Grechishhev @ 2011-04-19  6:06 UTC (permalink / raw)
  To: moktar_bouain; +Cc: ecos-discuss

2011/4/15 moktar_bouain <moktarbouain@yahoo.fr>:
>

>
> I create an application with eCos containing 3 threads,i like to measure the
> execution time of each thread ??


You can try to use gprof profiling tool:
http://ecoscentric.com/ecospro/doc.cgi/html/ref/gprof.html



--
With best regards!
____________________________

Yurij Grechishhev
Bauman State Technical University,
Department of Computer Systems and Networks

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ECOS] measure the execution time of each thread
  2011-04-18 23:32       ` moktar_bouain
@ 2011-04-19 11:07         ` Gary Thomas
  2011-04-22 23:00           ` moktar_bouain
  0 siblings, 1 reply; 14+ messages in thread
From: Gary Thomas @ 2011-04-19 11:07 UTC (permalink / raw)
  To: moktar_bouain; +Cc: ecos-discuss

On 04/18/2011 05:32 PM, moktar_bouain wrote:
>
>
>> Note that this technique is only accurate to the system tick time
>> which is normally 10ms.  If your thread runs for less time than this,
>> you won't know.
>
>> Look at the test program tm_basic.cxx for details on how to measure
>> at a finer grain (without the overhead of decreasing the tick time).
>
> I use eCos for Sparc (Leon3 processor) with a 66 MHz.
> Means that the clock tick  corresponds to 1.5×10-5ms(15ns).
> is it possible  to measure the execution time of a thread??

That's not the "clock tick" that those functions are using, but the
hardware instruction clock.  The system clock is a periodic timer,
used to measure time, that normally runs at 100Hz

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ECOS] measure the execution time of each thread
  2011-04-19 11:07         ` Gary Thomas
@ 2011-04-22 23:00           ` moktar_bouain
  2011-04-23 14:33             ` Gary Thomas
  0 siblings, 1 reply; 14+ messages in thread
From: moktar_bouain @ 2011-04-22 23:00 UTC (permalink / raw)
  To: ecos-discuss


>That's not the "clock tick" that those functions are using, but the
>hardware instruction clock.  The system clock is a periodic timer,
>used to measure time, that normally runs at 100Hz

Hi Gary,
The problem is that eCos can not measure the time that is less than
millisecond.
How can i change the resolution for the µs or ns?



-- 
View this message in context: http://old.nabble.com/measure-the-execution-time-of-each-thread-tp31407684p31459410.html
Sent from the Sourceware - ecos-discuss mailing list archive at Nabble.com.


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ECOS] measure the execution time of each thread
  2011-04-22 23:00           ` moktar_bouain
@ 2011-04-23 14:33             ` Gary Thomas
  2011-04-23 15:07               ` moktar_bouain
  0 siblings, 1 reply; 14+ messages in thread
From: Gary Thomas @ 2011-04-23 14:33 UTC (permalink / raw)
  To: moktar_bouain; +Cc: ecos-discuss

On 04/22/2011 05:00 PM, moktar_bouain wrote:
>
>> That's not the "clock tick" that those functions are using, but the
>> hardware instruction clock.  The system clock is a periodic timer,
>> used to measure time, that normally runs at 100Hz
>
> Hi Gary,
> The problem is that eCos can not measure the time that is less than
> millisecond.
> How can i change the resolution for the µs or ns?

As I said before, look at how it's done in tm_basic.cxx

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ECOS] measure the execution time of each thread
  2011-04-23 14:33             ` Gary Thomas
@ 2011-04-23 15:07               ` moktar_bouain
  2011-04-23 17:11                 ` Gary Thomas
  0 siblings, 1 reply; 14+ messages in thread
From: moktar_bouain @ 2011-04-23 15:07 UTC (permalink / raw)
  To: ecos-discuss


>As I said before, look at how it's done in tm_basic.cxx

I did, but I do not understand how to modify.
Can you give me some details?



-- 
View this message in context: http://old.nabble.com/measure-the-execution-time-of-each-thread-tp31407684p31461897.html
Sent from the Sourceware - ecos-discuss mailing list archive at Nabble.com.


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ECOS] measure the execution time of each thread
  2011-04-23 15:07               ` moktar_bouain
@ 2011-04-23 17:11                 ` Gary Thomas
  2011-04-24 22:22                   ` moktar_bouain
  0 siblings, 1 reply; 14+ messages in thread
From: Gary Thomas @ 2011-04-23 17:11 UTC (permalink / raw)
  To: moktar_bouain; +Cc: ecos-discuss

On 04/23/2011 09:07 AM, moktar_bouain wrote:
>
>> As I said before, look at how it's done in tm_basic.cxx
>
> I did, but I do not understand how to modify.
> Can you give me some details?

You don't want to modify that code, just look at how it computes time
at a nanosecond scale.

Look at the function show_time_in_us() which uses time values
based on the function HAL_CLOCK_READ() that reads the system timer
(whatever that may be) and calculates time to the most accurate
value available in the system.  This is based on the raw clock
(often the hardware system clock) that's used to run the system
'tick' timer.  On most systems, this value is accurate to micro-seconds,
sometimes even nano-seconds.

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ECOS] measure the execution time of each thread
  2011-04-23 17:11                 ` Gary Thomas
@ 2011-04-24 22:22                   ` moktar_bouain
  2011-04-25 12:36                     ` Gary Thomas
  0 siblings, 1 reply; 14+ messages in thread
From: moktar_bouain @ 2011-04-24 22:22 UTC (permalink / raw)
  To: ecos-discuss


>You don't want to modify that code, just look at how it computes time
>at a nanosecond scale.
>Look at the function show_time_in_us() which uses time values
>based on the function HAL_CLOCK_READ() that reads the system timer
>(whatever that may be) and calculates time to the most accurate
>value available in the system.  This is based on the raw clock
>(often the hardware system clock) that's used to run the system
>'tick' timer.  On most systems, this value is accurate to micro-seconds,
>sometimes even nano-seconds.

Hi Gary,
I found the function gettimeofday() which returns the time  in  us.
I create a simple application with eCos containing 1 thread,i like to
measure the
execution time(us) of the thread.

void taska(cyg_addrword_t data)
{
struct timeval tv1,tv2;
long long diff;

while(1)
{
gettimeofday (&tv1, NULL);

cyg_mutex_lock(&cliblock);
printf("TASKA \n");
cyg_mutex_unlock(&cliblock);

cyg_thread_delay(2);

gettimeofday (&tv2, NULL);
diff=(tv2.tv_sec-tv1.tv_sec) * 1000000 + (tv2.tv_usec-tv1.tv_usec);

printf("Time tv1 is %d\n",tv1.tv_usec);
printf("Time tv2 is %d\n",tv2.tv_usec);
printf("The diff is =%d usec\n",diff);
};
}

when i run this application in Tsim(simulator of Leon3):
Time tv1 is 286326803
Time tv2 is 286326801
The diff is -1 usec
Can you tell me what the fault in my program?



-- 
View this message in context: http://old.nabble.com/measure-the-execution-time-of-each-thread-tp31407684p31468181.html
Sent from the Sourceware - ecos-discuss mailing list archive at Nabble.com.


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ECOS] measure the execution time of each thread
  2011-04-24 22:22                   ` moktar_bouain
@ 2011-04-25 12:36                     ` Gary Thomas
  2011-04-28  2:39                       ` moktar_bouain
  0 siblings, 1 reply; 14+ messages in thread
From: Gary Thomas @ 2011-04-25 12:36 UTC (permalink / raw)
  To: moktar_bouain; +Cc: ecos-discuss

On 04/24/2011 04:22 PM, moktar_bouain wrote:
>
>> You don't want to modify that code, just look at how it computes time
>> at a nanosecond scale.
>> Look at the function show_time_in_us() which uses time values
>> based on the function HAL_CLOCK_READ() that reads the system timer
>> (whatever that may be) and calculates time to the most accurate
>> value available in the system.  This is based on the raw clock
>> (often the hardware system clock) that's used to run the system
>> 'tick' timer.  On most systems, this value is accurate to micro-seconds,
>> sometimes even nano-seconds.
>
> Hi Gary,
> I found the function gettimeofday() which returns the time  in  us.
> I create a simple application with eCos containing 1 thread,i like to
> measure the
> execution time(us) of the thread.
>
> void taska(cyg_addrword_t data)
> {
> struct timeval tv1,tv2;
> long long diff;
>
> while(1)
> {
> gettimeofday (&tv1, NULL);
>
> cyg_mutex_lock(&cliblock);
> printf("TASKA \n");
> cyg_mutex_unlock(&cliblock);
>
> cyg_thread_delay(2);
>
> gettimeofday (&tv2, NULL);
> diff=(tv2.tv_sec-tv1.tv_sec) * 1000000 + (tv2.tv_usec-tv1.tv_usec);
>
> printf("Time tv1 is %d\n",tv1.tv_usec);
> printf("Time tv2 is %d\n",tv2.tv_usec);
> printf("The diff is =%d usec\n",diff);
> };
> }
>
> when i run this application in Tsim(simulator of Leon3):
> Time tv1 is 286326803
> Time tv2 is 286326801
> The diff is -1 usec
> Can you tell me what the fault in my program?

Looks like HAL_CLOCK_READ() isn't working on your hardware.
What's your target hardware?  Is it part of the public eCos tree?

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [ECOS] measure the execution time of each thread
  2011-04-25 12:36                     ` Gary Thomas
@ 2011-04-28  2:39                       ` moktar_bouain
  0 siblings, 0 replies; 14+ messages in thread
From: moktar_bouain @ 2011-04-28  2:39 UTC (permalink / raw)
  To: ecos-discuss


>Looks like HAL_CLOCK_READ() isn't working on your hardware.
>What's your target hardware?  Is it part of the public eCos tree?
Hi Gary,
I used the  processor leon3 (SPARC) with the platform Digilent-XUP.
I tried with HAL_CLOCK_READ(), and i added the following lines:
HAL_CLOCK_READ(&t1);
HAL_CLOCK_READ(&t2);
printf("t1 is: %lu \n",t1);
printf("t2 is: %lu \n",t2);
printf("t2-t1 is: %d\n",t2-t1);

The result is:
t1 is:333
t2 is:294
t2-t1 is:-39


-- 
View this message in context: http://old.nabble.com/measure-the-execution-time-of-each-thread-tp31407684p31493032.html
Sent from the Sourceware - ecos-discuss mailing list archive at Nabble.com.


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-04-28  2:39 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-15 17:11 [ECOS] measure the execution time of each thread moktar_bouain
2011-04-18 17:03 ` Michael Bergandi
2011-04-18 22:01   ` moktar_bouain
2011-04-18 22:50     ` Gary Thomas
2011-04-18 23:32       ` moktar_bouain
2011-04-19 11:07         ` Gary Thomas
2011-04-22 23:00           ` moktar_bouain
2011-04-23 14:33             ` Gary Thomas
2011-04-23 15:07               ` moktar_bouain
2011-04-23 17:11                 ` Gary Thomas
2011-04-24 22:22                   ` moktar_bouain
2011-04-25 12:36                     ` Gary Thomas
2011-04-28  2:39                       ` moktar_bouain
2011-04-19  6:06 ` Yurij Grechishhev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).