Measuring CPU Time

I have a task that runs every millisecond:

while (1)
{
Receive(…); // Waiting for a timer proxy/pulse
[task]; // Do something
}

What is the best way to measure how much CPU time [task] consumes each
cycle? I’m interested in QNX4 and Neutrino solutions, latter preferred.

Thanks
Markus

Check out ClockCycles() which will be from the processors internal
counter (pentuim and above)

Bill

On Tue, 31 Oct 2000 15:05:52 -0500, “Markus Loffler”
<loffler@ces.clemson.edu> wrote:

I have a task that runs every millisecond:

while (1)
{
Receive(…); // Waiting for a timer proxy/pulse
[task]; // Do something
}

What is the best way to measure how much CPU time [task] consumes each
cycle? I’m interested in QNX4 and Neutrino solutions, latter preferred.

Thanks
Markus

Thanks Bill,
I know about ClockCycles(). However, if I do

while (1)
{
Receive(…); // Waiting for a timer proxy/pulse
start = ClockCycles();
[task]; // Do something
stop = ClockCycles();
}

and a higher priority process interrupts my process (which can be the case),
wouldn’t the result be inaccurate?
Thanks
Markus


“William M. Derby Jr.” <derbyw@derbtronics.com> wrote in message
news:3a017185.1065964@inn.qnx.com

Check out ClockCycles() which will be from the processors internal
counter (pentuim and above)

Bill

On Tue, 31 Oct 2000 15:05:52 -0500, “Markus Loffler”
loffler@ces.clemson.edu> > wrote:

I have a task that runs every millisecond:

while (1)
{
Receive(…); // Waiting for a timer proxy/pulse
[task]; // Do something
}

What is the best way to measure how much CPU time [task] consumes each
cycle? I’m interested in QNX4 and Neutrino solutions, latter preferred.

Thanks
Markus
\

Markus Loffler <loffler@ces.clemson.edu> wrote:

Thanks Bill,
I know about ClockCycles(). However, if I do

while (1)
{
Receive(…); // Waiting for a timer proxy/pulse
start = ClockCycles();
[task]; // Do something
stop = ClockCycles();
}

and a higher priority process interrupts my process (which can be the case),
wouldn’t the result be inaccurate?

on -p63 ./test_program

Nothing will stop you then! :slight_smile:

chris

cdm@qnx.com > “The faster I go, the behinder I get.”

Chris McKillop – Lewis Carroll –
Software Engineer, QSSL
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Maybe you could make use of the getrusage() function.

Previously, Chris McKillop wrote in comp.os.qnx:

Markus Loffler <> loffler@ces.clemson.edu> > wrote:
Thanks Bill,
I know about ClockCycles(). However, if I do

while (1)
{
Receive(…); // Waiting for a timer proxy/pulse
start = ClockCycles();
[task]; // Do something
stop = ClockCycles();
}

and a higher priority process interrupts my process (which can be the case),
wouldn’t the result be inaccurate?

on -p63 ./test_program

Nothing will stop you then! > :slight_smile:

chris

cdm@qnx.com > “The faster I go, the behinder I get.”
Chris McKillop – Lewis Carroll –
Software Engineer, QSSL

Checkout the ClockId and ClockTime functions…

uint64_t start, stop, time_in_nanoseconds_spent_executing_in_this_process;

my_clock_id = ClockId( 0, this_tid );

ClockTime( my_clock_id, NULL, &start );
[…]
ClockTime( my_clock_id, NULL, &stop );

time_in_nanoseconds_spent_executing_in_this_process = stop - start;

Markus Loffler <loffler@ces.clemson.edu> wrote:

Thanks Bill,
I know about ClockCycles(). However, if I do

while (1)
{
Receive(…); // Waiting for a timer proxy/pulse
start = ClockCycles();
[task]; // Do something
stop = ClockCycles();
}

and a higher priority process interrupts my process (which can be the case),
wouldn’t the result be inaccurate?
Thanks
Markus



“William M. Derby Jr.” <> derbyw@derbtronics.com> > wrote in message
news:> 3a017185.1065964@inn.qnx.com> …

Check out ClockCycles() which will be from the processors internal
counter (pentuim and above)

Bill

On Tue, 31 Oct 2000 15:05:52 -0500, “Markus Loffler”
loffler@ces.clemson.edu> > wrote:

I have a task that runs every millisecond:

while (1)
{
Receive(…); // Waiting for a timer proxy/pulse
[task]; // Do something
}

What is the best way to measure how much CPU time [task] consumes each
cycle? I’m interested in QNX4 and Neutrino solutions, latter preferred.

Thanks
Markus

\


cburgess@qnx.com