Commit 174ddaa5 authored by Jingyi Wang's avatar Jingyi Wang Committed by Paolo Bonzini
Browse files

arm64: microbench: Add time limit for each individual test



Besides using separate running times parameter, we add time limit
for loop_test to make sure each test should be done in a certain
time(5 sec here).

Signed-off-by: default avatarJingyi Wang <wangjingyi11@huawei.com>
Reviewed-by: default avatarEric Auger <eric.auger@redhat.com>
[ Initialize total_ns to zero. ]
Signed-off-by: Andrew Jones's avatarAndrew Jones <drjones@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent b8d5a5b0
......@@ -22,6 +22,7 @@
#include <asm/gic.h>
#include <asm/gic-v3-its.h>
#define NS_5_SECONDS (5 * 1000 * 1000 * 1000UL)
static u32 cntfrq;
static volatile bool irq_ready, irq_received;
......@@ -265,25 +266,28 @@ static void ticks_to_ns_time(uint64_t ticks, struct ns_time *ns_time)
static void loop_test(struct exit_test *test)
{
uint64_t start, end, total_ticks, ntimes = 0;
struct ns_time total_ns, avg_ns;
struct ns_time avg_ns, total_ns = {};
total_ticks = 0;
if (test->prep) {
if(!test->prep()) {
printf("%s test skipped\n", test->name);
return;
}
}
isb();
start = read_sysreg(cntpct_el0);
while (ntimes < test->times) {
while (ntimes < test->times && total_ns.ns < NS_5_SECONDS) {
isb();
start = read_sysreg(cntpct_el0);
test->exec();
isb();
end = read_sysreg(cntpct_el0);
ntimes++;
total_ticks += (end - start);
ticks_to_ns_time(total_ticks, &total_ns);
}
isb();
end = read_sysreg(cntpct_el0);
total_ticks = end - start;
ticks_to_ns_time(total_ticks, &total_ns);
avg_ns.ns = total_ns.ns / ntimes;
avg_ns.ns_frac = total_ns.ns_frac / ntimes;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment