From c81b2cb24dde2a81cc455a0874158811b98d17ef Mon Sep 17 00:00:00 2001 From: Couriersud Date: Wed, 6 Aug 2008 19:31:39 +0000 Subject: [PATCH] Added module profiling to discrete sound core * added DISCRETE_PROFILING macro to discrete.h * Upon discrete_stop, the worst performing modules will be listed --- src/emu/sound/discrete.c | 35 ++++++++++++++++++++++++++++++++++- src/emu/sound/discrete.h | 11 +++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/emu/sound/discrete.c b/src/emu/sound/discrete.c index 07dfb18dfd4..94c70c1387d 100644 --- a/src/emu/sound/discrete.c +++ b/src/emu/sound/discrete.c @@ -51,7 +51,6 @@ #define DISCRETE_DEBUGLOG (0) - /************************************* * * Global variables @@ -374,6 +373,34 @@ static void discrete_stop(void *chip) discrete_info *info = chip; int log_num; +#if (DISCRETE_PROFILING) + { + int nodenum; + osd_ticks_t total = 0; + osd_ticks_t tresh; + + /* calculate total time */ + for (nodenum = 0; nodenum < info->node_count; nodenum++) + { + node_description *node = info->running_order[nodenum]; + + /* Now step the node */ + total += node->run_time; + } + /* print statistics */ + tresh = total / info->node_count; + for (nodenum = 0; nodenum < info->node_count; nodenum++) + { + node_description *node = info->running_order[nodenum]; + + if (node->run_time > tresh) + printf("%3d: %20s %8.2f\n", NODE_INDEX(node->node), node->module.name, (float) node->run_time / (float) total * 100.0); + /* Now step the node */ + total += node->run_time; + } + } +#endif + /* close any csv files */ for (log_num = 0; log_num < info->num_csvlogs; log_num++) if (info->disc_csv_file[log_num]) @@ -459,8 +486,14 @@ static void discrete_stream_update(void *param, stream_sample_t **inputs, stream node_description *node = info->running_order[nodenum]; /* Now step the node */ +#if (DISCRETE_PROFILING) + node->run_time -= osd_profiling_ticks(); +#endif if (node->module.step) (*node->module.step)(node); +#if (DISCRETE_PROFILING) + node->run_time += osd_profiling_ticks(); +#endif } /* Add gain to the output and put into the buffers */ diff --git a/src/emu/sound/discrete.h b/src/emu/sound/discrete.h index cb58c95e570..625b3cab51d 100644 --- a/src/emu/sound/discrete.h +++ b/src/emu/sound/discrete.h @@ -3150,6 +3150,14 @@ ************************************************************************/ +/************************************* + * + * Profiling Nodes + * + *************************************/ + +#define DISCRETE_PROFILING (0) + /************************************* * * Core constants @@ -3421,6 +3429,9 @@ struct _node_description void * context; /* Contextual information specific to this node type */ const char * name; /* Text name string for identification/debug */ const void * custom; /* Custom function specific initialisation data */ +#if (DISCRETE_PROFILING) + osd_ticks_t run_time; +#endif };