From 9e4d76d8408ebd39704c96e11ae8b64de754d98d Mon Sep 17 00:00:00 2001 From: guanglei Date: Tue, 29 Aug 2006 04:57:10 +0000 Subject: add another two kinds of timing mechanisms for LKET, i.e. get_cycles() and sched_clock() --- runtime/lket/b2a/lket_b2a.c | 84 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 78 insertions(+), 6 deletions(-) (limited to 'runtime/lket/b2a/lket_b2a.c') diff --git a/runtime/lket/b2a/lket_b2a.c b/runtime/lket/b2a/lket_b2a.c index 98c0b9de..352880f5 100644 --- a/runtime/lket/b2a/lket_b2a.c +++ b/runtime/lket/b2a/lket_b2a.c @@ -18,6 +18,21 @@ #include #include "lket_b2a.h" +#define TIMING_GETCYCLES 0x01 +#define TIMING_GETTIMEOFDAY 0x02 +#define TIMING_SCHEDCLOCK 0x03 + +typedef struct _cpufreq_info { + long timebase; + long long last_cycles; + long long last_time; +} cpufreq_info; + +#define MAX_CPUS 256 +cpufreq_info cpufreq[MAX_CPUS]; + +static long timing_method = TIMING_GETTIMEOFDAY; + static long long start_timestamp; /* Balanced binary search tree to store the @@ -98,17 +113,23 @@ int main(int argc, char *argv[]) } } + // initialize the start cycles + if(timing_method == TIMING_GETCYCLES) { + for(i=0; imicrosecond - start_timestamp; - int sec = usecs/1000000; - int usec = usecs%1000000; + + if(timing_method == TIMING_GETCYCLES) + usecs = (phdr->microsecond - cpufreq[HDR_CpuID(phdr)].last_cycles) + / cpufreq[HDR_CpuID(phdr)].timebase + cpufreq[HDR_CpuID(phdr)].last_time; + else if(timing_method == TIMING_SCHEDCLOCK) + usecs = (phdr->microsecond - start_timestamp) / 1000; + else + usecs = phdr->microsecond - start_timestamp; + + sec = usecs/1000000; + usec = usecs%1000000; fprintf(fp, "\n%d.%d APPNAME: %s PID:%d CPU:%d HOOKGRP:%d HOOKID:%d -- ", sec, usec, -- cgit