KVM: selftests: Time guest demand paging

In order to quantify demand paging performance, time guest execution
during demand paging.

Signed-off-by: Ben Gardon <bgardon@google.com>
[Move timespec-diff to test_util.h]
Signed-off-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Ben Gardon
2020-01-23 10:04:34 -08:00
committed by Paolo Bonzini
parent 018494e6d8
commit f09205b998
3 changed files with 72 additions and 1 deletions
@@ -49,3 +49,23 @@ size_t parse_size(const char *size)
return base << shift;
}
int64_t timespec_to_ns(struct timespec ts)
{
return (int64_t)ts.tv_nsec + 1000000000LL * (int64_t)ts.tv_sec;
}
struct timespec timespec_diff(struct timespec start, struct timespec end)
{
struct timespec temp;
if ((end.tv_nsec - start.tv_nsec) < 0) {
temp.tv_sec = end.tv_sec - start.tv_sec - 1;
temp.tv_nsec = 1000000000LL + end.tv_nsec - start.tv_nsec;
} else {
temp.tv_sec = end.tv_sec - start.tv_sec;
temp.tv_nsec = end.tv_nsec - start.tv_nsec;
}
return temp;
}