forked from xapi-project/xen-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d135a9
commit ee54d17
Showing
7 changed files
with
207 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
(library | ||
(name xapi_aux) | ||
(foreign_stubs | ||
(language c) | ||
(names rusage_thread_stubs) | ||
) | ||
(libraries | ||
astring | ||
cstruct | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rusage_thread.mli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
(* | ||
* Copyright (C) 2024 Cloud Software Group | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation; version 2.1 only. with the special | ||
* exception on linking described in file LICENSE. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
*) | ||
|
||
(* similar to [gettimeofday]: doesn't allocate, and can return a float directly without boxing it. | ||
This avoids introducing extra overhead in a function used to measure overhead. | ||
*) | ||
|
||
(** [getrusage_thread_utime] returns the [ru_utime] field of [struct rusage] for the calling thread. | ||
This call is Linux specific. | ||
*) | ||
external getrusage_thread_utime : unit -> (float [@unboxed]) = | ||
"caml_getrusage_thread_utime" "caml_getrusage_thread_utime_unboxed" [@@noalloc] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* must be first according to getrusage(2) */ | ||
#define _GNU_SOURCE | ||
#include <sys/resource.h> | ||
|
||
#include <caml/alloc.h> | ||
#include <caml/mlvalues.h> | ||
#include <caml/unixsupport.h> | ||
|
||
/* declared as noalloc and returns unboxed float, | ||
must not call any CAMLparam/CAMLreturn here! | ||
*/ | ||
|
||
double caml_getrusage_thread_utime_unboxed(value unit) | ||
{ | ||
struct rusage rusage; | ||
const struct timeval *tv; | ||
|
||
if (getrusage(RUSAGE_THREAD, &rusage) < 0) | ||
uerror("getrusage", Nothing); | ||
tv = &rusage.ru_utime; | ||
return (tv->tv_sec + tv->tv_usec / 1e6); | ||
} | ||
|
||
CAMLprim value caml_getrusage_thread_utime(value unit) | ||
{ | ||
return caml_copy_double(caml_getrusage_thread_utime_unboxed(unit)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters