All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Giulio Moro <giulio@bela.io>
Cc: xenomai@xenomai.org
Subject: Re: Thread's CPU time
Date: Fri, 29 Apr 2022 17:29:28 +0200	[thread overview]
Message-ID: <87fslvzyxa.fsf@xenomai.org> (raw)
In-Reply-To: <6a50f4cf-4f2a-542a-c332-4d98975e36a6@bela.io>


Giulio Moro via Xenomai <xenomai@xenomai.org> writes:

> Hi everyone,
> From /proc/xenomai/sched/stat I infer there must be an internal struct
> somewhere keeping track of how much CPU time is actually used by each
> thread. Is there any way to access this kind of statistics from a
> running Xenomai user space program without leaving primary mode and
> without attempting to read this file? I am implementing an
> infrastructure to measure the CPU time of a given block of
> code. Currently I am using Cobalt's clock_gettime(), but this only
> works reliably if the task does not get preempted or otherwise
> rescheduled between the two calls.
>
> I have run this kind of tests offline before and that's all nice and good, but I am looking for a lightweight and non invasive way of benchmarking particular sections of large-ish programs with minimal modifications.
>
> Thanks,
> Giulio

For xenomai3, you may want to have a look at cobalt_thread_stat() from
the internal API (sys/cobalt.h). The field of interest returned in
struct cobalt_threadstat would be 'xtime' (nsecs).

-- 
Philippe.


  reply	other threads:[~2022-04-29 15:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-29 15:20 Thread's CPU time Giulio Moro
2022-04-29 15:29 ` Philippe Gerum [this message]
2022-05-02  9:42   ` Giulio Moro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fslvzyxa.fsf@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=giulio@bela.io \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.