Just a quick app to test and demonstrate how to get run times from a specific thread on FreeBSD.
26 lines
765 B
C++
26 lines
765 B
C++
/*
|
|
* SPDX-FileCopyrightText: 2025 Eilertsens Kodeknekkeri
|
|
* SPDX-FileCopyrightText: 2025 The FreeBSD Foundation
|
|
* SPDX-FileContributor: Harald Eilertsen <haraldei@anduin.net>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#ifndef __FAST_CPU_TIME_HPP
|
|
#define __FAST_CPU_TIME_HPP
|
|
|
|
#include <pthread.h>
|
|
|
|
/**
|
|
* Return the combined (sys+user) runtime of the given thread.
|
|
*
|
|
* This uses the clock_gettime(2) system call with the clock id obtained from
|
|
* the given thread via pthread_getcpuclockid(2).
|
|
*
|
|
* It gives the total runtime of the thread in nanoseconds. This is presumably
|
|
* the faster way to get the runtime of a specific thread, but we do not get
|
|
* the user and sys times separate.
|
|
*/
|
|
unsigned long fast_thread_cpu_time(pthread_t thread);
|
|
|
|
#endif
|