aboutsummaryrefslogtreecommitdiff
path: root/kvm
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2009-09-17 11:06:49 +0300
committerAvi Kivity <avi@redhat.com>2009-09-22 11:57:14 +0300
commitf819ec7a576e58a2e29ff0cbb7bf84ee01d26edc (patch)
tree89a9d8baca2fe6cbacebc7628618e1e044854047 /kvm
parenttest: Add ipi_halt benchmark (diff)
downloadqemu-kvm-f819ec7a576e58a2e29ff0cbb7bf84ee01d26edc.tar.gz
qemu-kvm-f819ec7a576e58a2e29ff0cbb7bf84ee01d26edc.tar.bz2
qemu-kvm-f819ec7a576e58a2e29ff0cbb7bf84ee01d26edc.zip
test: Auto-tune vmexit test
Scale up iterations until we measure at least 1G cycles. Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'kvm')
-rw-r--r--kvm/user/test/x86/vmexit.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/kvm/user/test/x86/vmexit.c b/kvm/user/test/x86/vmexit.c
index 5088dc92d..e7cb5efe0 100644
--- a/kvm/user/test/x86/vmexit.c
+++ b/kvm/user/test/x86/vmexit.c
@@ -17,7 +17,7 @@ static inline unsigned long long rdtsc()
return r;
}
-#define N (1 << 22)
+#define GOAL (1ull << 30)
#ifdef __x86_64__
# define R "r"
@@ -93,6 +93,7 @@ static void do_test(struct test *test)
{
int i;
unsigned long long t1, t2;
+ unsigned iterations = 32;
void (*func)(void) = test->func;
if (test->valid && !test->valid()) {
@@ -100,11 +101,14 @@ static void do_test(struct test *test)
return;
}
- t1 = rdtsc();
- for (i = 0; i < N; ++i)
- func();
- t2 = rdtsc();
- printf("%s %d\n", test->name, (int)((t2 - t1) / N));
+ do {
+ iterations *= 2;
+ t1 = rdtsc();
+ for (i = 0; i < iterations; ++i)
+ func();
+ t2 = rdtsc();
+ } while ((t2 - t1) < GOAL);
+ printf("%s %d\n", test->name, (int)((t2 - t1) / iterations));
}
#define ARRAY_SIZE(_x) (sizeof(_x) / sizeof((_x)[0]))