# Process\_cputime, thread\_cputime

**URL:** <https://swi-prolog.discourse.group/t/process-cputime-thread-cputime/1819>\
**Category:** Help!\
**Created:** [February 1, 2020, 10:24pm UTC](https://swi-prolog.discourse.group/t/process-cputime-thread-cputime/1819 "2020-02-01T22:24:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [February 1, 2020, 10:24pm UTC](https://swi-prolog.discourse.group/t/process-cputime-thread-cputime/1819/1 "2020-02-01T22:24:29Z")

</div>

I put some measurements (using `statistics/2`) around a predicate that’s called by an http\_handler, and to my surprise, `thread_cputime` showed 0. Both `process_cputime` and `cputime` showed reasonable values.

Do I need to do something to activate thread cputime measurements?

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [February 2, 2020, 9:31am UTC](https://swi-prolog.discourse.group/t/process-cputime-thread-cputime/1819/2 "2020-02-02T09:31:18Z")

</div>

From the docs: \_“Seconds CPU time used by **finished** threads.”. **Bold** by me; should probably also be bold in the docs too.

`cputime` gives the CPU time of the calling thread (only). `process_cputime` of the entire process and using thread\_statistics/3 you can query the stats of other (running) threads.

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [February 2, 2020, 12:52pm UTC](https://swi-prolog.discourse.group/t/process-cputime-thread-cputime/1819/3 "2020-02-02T12:52:22Z")

</div>

> [@jan](#):
>
> Seconds CPU time used by **finished** threads

I saw that but thought it was a typo. I also missed the plural “thread **s** ”.

So, for a thread’s cputime, I should use `statistics(cputime, ...)` and for total cputime for all threads, I should use `statistics(process_cputime, ...)`?

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [February 2, 2020, 1:05pm UTC](https://swi-prolog.discourse.group/t/process-cputime-thread-cputime/1819/4 "2020-02-02T13:05:16Z")

</div>

That is correct
