Only have cost centres etc if @PROFILING@ defined \begin{code} #include "rtsdefs.h" #if defined (PROFILING) || defined(PAR) \end{code} %************************************************************************ %* * \subsection[timer-interrupts]{Processing of Profiling Timer Signals} %* * %************************************************************************ Problem: If we set @HpLim = Hp@ in handler neither can be in registers! Rather add test for flag to Hp check macros. \begin{code} I_ time_profiling = 0; /* Flag to indicate timer/serial profiling */ I_ interval_expired = 0; /* Flag tested by HP_CHK routines */ I_ current_interval = 1; /* Current interval number -- stored in AGE */ I_ interval_ticks = DEFAULT_INTERVAL; /* No of ticks in an interval */ I_ previous_ticks = 0; /* ticks in previous intervals */ I_ current_ticks = 0; /* ticks in current interval */ void set_profile_timer(I_ ms) { if (initialize_virtual_timer(ms)) { fflush(stdout); fprintf(stderr, "Can't initialize virtual timer.\n"); EXIT(EXIT_FAILURE); } } void handle_tick_serial(STG_NO_ARGS) { CC_TICK(CCC); /* fprintf(stderr,"tick for %s\n", CCC->label); */ #if defined(PROFILING) && defined(DEBUG) /* Why is this here? --JSM Debugging --WDP */ if (CCC == STATIC_CC_REF(CC_OVERHEAD)) abort(); #endif #if 0 /* Experimental - don't tick if we're in the middle of reporting a cc_profile. Untested. */ if (interval_expired) return; #endif if (++current_ticks >= interval_ticks && CCC != STATIC_CC_REF(CC_GC)) { #if defined(PROFILING) interval_expired = 1; /* stop to process interval */ #else report_cc_profiling(0 /*partial*/); restart_time_profiler(); #endif } return; } void handle_tick_noserial(STG_NO_ARGS) { CC_TICK(CCC); ++current_ticks; return; } void stop_time_profiler() { /* Stops time profile */ if (time_profiling) { set_profile_timer(0); } } void restart_time_profiler() { /* Restarts time profile */ #if defined(PROFILING) if (interval_expired) #endif { current_interval++; previous_ticks += current_ticks; current_ticks = 0; interval_expired = 0; } } void start_time_profiler() { /* Starts time profile */ if (time_profiling) { #ifdef PAR set_profile_timer(RTSflags.CcFlags.msecsPerTick); #else set_profile_timer(TICK_MILLISECS); #endif } } \end{code} \begin{code} #endif /* PROFILING || PAR */ \end{code}