diff --git a/src/interpret.c b/src/interpret.c index 23c77a1fb5d816abc046e788c3d941b1c85aadb4..8f004f53799640b3ab6d9c2b673c087ccc12b7c1 100644 --- a/src/interpret.c +++ b/src/interpret.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: interpret.c,v 1.99 1998/11/16 22:14:50 hubbe Exp $"); +RCSID("$Id: interpret.c,v 1.100 1998/11/20 01:57:21 hubbe Exp $"); #include "interpret.h" #include "object.h" #include "program.h" @@ -68,6 +68,13 @@ struct svalue **mark_sp; /* Current position */ struct svalue **mark_stack; /* Start of stack */ int mark_stack_malloced = 0; +#ifdef PROFILING +#ifdef HAVE_GETHRTIME +long long accounted_time =0; +long long time_base =0; +#endif +#endif + void push_sp_mark(void) { if(mark_sp == mark_stack + stack_size) @@ -1792,7 +1799,6 @@ void mega_apply(enum apply_type type, INT32 args, void *arg1, void *arg2) struct svalue *save_sp=sp-args; #ifdef PROFILING #ifdef HAVE_GETHRTIME - static long long accounted_time =0; long long children_base = accounted_time; long long start_time = gethrtime(); unsigned INT32 self_time_base; diff --git a/src/interpret.h b/src/interpret.h index 5823f9c34ec2af0f489f0c841caec7eff245bba0..6bc393f5b58af9d0d4a853b94434912cc048bbc8 100644 --- a/src/interpret.h +++ b/src/interpret.h @@ -5,7 +5,7 @@ \*/ /* - * $Id: interpret.h,v 1.22 1998/08/10 23:33:29 hubbe Exp $ + * $Id: interpret.h,v 1.23 1998/11/20 01:57:23 hubbe Exp $ */ #ifndef INTERPRET_H #define INTERPRET_H @@ -161,5 +161,13 @@ extern int evaluator_stack_malloced, mark_stack_malloced; struct callback; extern struct callback_list evaluator_callbacks; extern void call_callback(struct callback_list *, void *); + +#ifdef PROFILING +#ifdef HAVE_GETHRTIME +extern long long accounted_time; +extern long long time_base; +#endif +#endif + #endif diff --git a/src/threads.h b/src/threads.h index 8238938d17e4cd96ce3632b56e768c190e2f771f..c622fedc6de9a0274d3f85896fd18502dbad37a9 100644 --- a/src/threads.h +++ b/src/threads.h @@ -1,5 +1,5 @@ /* - * $Id: threads.h,v 1.53 1998/09/05 20:08:27 grubba Exp $ + * $Id: threads.h,v 1.54 1998/11/20 01:57:24 hubbe Exp $ */ #ifndef THREADS_H #define THREADS_H @@ -295,6 +295,14 @@ struct thread_state { JMP_BUF *recoveries; struct object * thread_id; char *stack_top; + +#ifdef PROFILING +#ifdef HAVE_GETHRTIME + long long accounted_time; + long long time_base; +#endif +#endif + #ifdef THREAD_TRACE int t_flag; #endif /* THREAD_TRACE */ @@ -336,6 +344,12 @@ struct thread_state { #define SWAP_IN_TRACE(_tmp) #endif /* THREAD_TRACE */ +#if defined(PROFILING) && defined(HAVE_GETHRTIME) +#define DO_IF_PROFILING(X) +#else +#define DO_IF_PROFILING(X) +#endif + #define SWAP_OUT_THREAD(_tmp) do { \ (_tmp)->swapped=1; \ (_tmp)->evaluator_stack=evaluator_stack;\ @@ -348,6 +362,8 @@ struct thread_state { (_tmp)->sp=sp; \ (_tmp)->stack_top=stack_top; \ (_tmp)->thread_id=thread_id;\ + DO_IF_PROFILING( (_tmp)->accounted_time=accounted_time; ) \ + DO_IF_PROFILING( (_tmp)->time_base = gethrvtime() - time_base; ) \ SWAP_OUT_TRACE(_tmp); \ } while(0) @@ -363,6 +379,8 @@ struct thread_state { sp=(_tmp)->sp;\ stack_top=(_tmp)->stack_top;\ thread_id=(_tmp)->thread_id;\ + DO_IF_PROFILING( accounted_time=(_tmp)->accounted_time; ) \ + DO_IF_PROFILING( time_base = (_tmp)->time_base + gethrvtime(); ) \ SWAP_IN_TRACE(_tmp); \ } while(0)