mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-02 00:34:13 +08:00
mdbx-test: add resource usage (CPU time).
Change-Id: I96b9bc9e748186ef122c809386ec3f52259d3b33
This commit is contained in:
parent
2c48f295b0
commit
5233a3cdb4
25
test/main.cc
25
test/main.cc
@ -14,6 +14,11 @@
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#if !(defined(_WIN32) || defined(_WIN64))
|
||||
#include <sys/resource.h>
|
||||
#include <sys/time.h>
|
||||
#endif /* !Windows */
|
||||
|
||||
void __noreturn usage(void) {
|
||||
printf("usage:\n"
|
||||
"\tFIXME\n");
|
||||
@ -494,5 +499,25 @@ int main(int argc, char *const argv[]) {
|
||||
else
|
||||
cleanup();
|
||||
}
|
||||
|
||||
#if !(defined(_WIN32) || defined(_WIN64))
|
||||
struct rusage spent;
|
||||
if (getrusage(RUSAGE_CHILDREN, &spent) == 0) {
|
||||
log_notice("%6s: user %f, system %f", "CPU",
|
||||
spent.ru_utime.tv_sec + spent.ru_utime.tv_usec * 1e-6,
|
||||
spent.ru_stime.tv_sec + spent.ru_stime.tv_usec * 1e-6);
|
||||
#if defined(__linux__) || defined(__gnu_linux__) || defined(__FreeBSD__) || \
|
||||
defined(__NetBSD__) || defined(__OpenBSD__) || defined(__BSD__) || \
|
||||
defined(__NETBSD__) || defined(__bsdi__) || defined(__DragonFly__) || \
|
||||
defined(__APPLE__) || defined(__MACH__)
|
||||
log_notice("%6s: read %ld, write %ld", "IOPs", spent.ru_inblock,
|
||||
spent.ru_oublock);
|
||||
log_notice("%6s: %ld Kb", "RAM", spent.ru_maxrss);
|
||||
log_notice("%6s: reclaims %ld, faults %ld, swaps %ld", "Paging",
|
||||
spent.ru_minflt, spent.ru_majflt, spent.ru_nswap);
|
||||
#endif /* Linux */
|
||||
}
|
||||
#endif /* !Windows */
|
||||
|
||||
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user