summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/profiler.h
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2009-01-02 10:52:40 +0000
committer Aaron Giles <aaron@aarongiles.com>2009-01-02 10:52:40 +0000
commit0b2c86bb027be56f7e5eb7ea490d995e847b290b (patch)
treeadefbc1327b149e91039f39da5fc8a012f39fe1d /src/emu/profiler.h
parentba92f06dd71242b62ecc27363b9b14fc6d42063d (diff)
Cleaned up the profiler. Reduced its runtime overhead significantly by
inlining the check to see if it is running. Removed obsolete entries and updated the text to more accurately describe each one. Added CPU tags to the CPU names. Switched to using an astring for building the final string. Unfortunately, still a bit too much overhead to leave it on in all builds.
Diffstat (limited to 'src/emu/profiler.h')
-rw-r--r--src/emu/profiler.h113
1 files changed, 87 insertions, 26 deletions
diff --git a/src/emu/profiler.h b/src/emu/profiler.h
index cc61fb96934..6f22e181c7a 100644
--- a/src/emu/profiler.h
+++ b/src/emu/profiler.h
@@ -7,6 +7,16 @@
Copyright Nicola Salmoria and the MAME Team.
Visit http://mamedev.org for licensing and usage restrictions.
+****************************************************************************
+
+ To start profiling a certain section, e.g. video:
+ profiler_mark(PROFILER_VIDEO);
+
+ to end profiling the current section:
+ profiler_mark(PROFILER_END);
+
+ the profiler handles a FILO list so calls may be nested.
+
***************************************************************************/
#pragma once
@@ -14,18 +24,19 @@
#ifndef __PROFILER_H__
#define __PROFILER_H__
+#include "astring.h"
+
+
+/***************************************************************************
+ CONSTANTS
+***************************************************************************/
+
/* profiling */
enum
{
PROFILER_END = -1,
- PROFILER_CPU1 = 0,
- PROFILER_CPU2,
- PROFILER_CPU3,
- PROFILER_CPU4,
- PROFILER_CPU5,
- PROFILER_CPU6,
- PROFILER_CPU7,
- PROFILER_CPU8,
+ PROFILER_CPU_FIRST = 0,
+ PROFILER_CPU_MAX = PROFILER_CPU_FIRST + 32,
PROFILER_MEMREAD,
PROFILER_MEMWRITE,
PROFILER_VIDEO,
@@ -34,10 +45,8 @@ enum
PROFILER_TILEMAP_DRAW,
PROFILER_TILEMAP_DRAW_ROZ,
PROFILER_TILEMAP_UPDATE,
- PROFILER_ARTWORK,
PROFILER_BLIT,
PROFILER_SOUND,
- PROFILER_MIXER,
PROFILER_TIMER_CALLBACK,
PROFILER_INPUT, /* input.c and inptport.c */
PROFILER_MOVIE_REC, /* movie recording */
@@ -57,30 +66,82 @@ enum
};
-/*
-To start profiling a certain section, e.g. video:
-profiler_mark(PROFILER_VIDEO);
-to end profiling the current section:
-profiler_mark(PROFILER_END);
+/***************************************************************************
+ TYPE DEFINITIONS
+***************************************************************************/
+
+typedef struct _profiler_filo_entry profiler_filo_entry;
+struct _profiler_filo_entry
+{
+ int type; /* type of entry */
+ osd_ticks_t start; /* start time */
+};
+
+
+typedef struct _profiler_data profiler_data;
+struct _profiler_data
+{
+ UINT32 context_switches; /* number of context switches seen */
+ osd_ticks_t duration[PROFILER_TOTAL]; /* duration spent in each entry */
+};
+
+
+typedef struct _profiler_state profiler_state;
+struct _profiler_state
+{
+ UINT8 enabled; /* are we enabled? */
+ UINT8 filoindex; /* current FILO index */
+ UINT8 dataindex; /* current data index */
+ UINT8 dataready; /* are we to display the data yet? */
+ profiler_filo_entry filo[16]; /* array of FILO entries */
+ profiler_data data[16]; /* array of data */
+};
+
+
+
+/***************************************************************************
+ GLOBAL VARIABLES
+***************************************************************************/
+
+extern profiler_state global_profiler;
-the profiler handles a FILO list so calls may be nested.
-*/
+
+
+/***************************************************************************
+ MACROS
+***************************************************************************/
#ifdef MAME_PROFILER
-void profiler_mark(int type);
-/* functions called by usrintf.c */
-void profiler_start(void);
-void profiler_stop(void);
-const char *profiler_get_text(running_machine *machine);
+#define profiler_mark(x) do { if (global_profiler.enabled) _profiler_mark(x); } while (0)
+#define profiler_start() do { global_profiler.enabled = TRUE; global_profiler.filoindex = global_profiler.dataindex = global_profiler.dataready = 0; } while (0)
+#define profiler_stop() do { global_profiler.enabled = FALSE; } while (0)
+#define profiler_get_text(x,s) _profiler_get_text(x, s)
+
#else
-#define profiler_mark(type)
-#define profiler_start()
-#define profiler_stop()
-#define profiler_get_text(machine) ""
+#define profiler_mark(x) do { } while (0)
+#define profiler_start() do { } while (0)
+#define profiler_stop() do { } while (0)
+#define profiler_get_text(x,s) astring_reset(s)
+
#endif
+
+/***************************************************************************
+ FUNCTION PROTOTYPES
+***************************************************************************/
+
+
+/* ----- core functions (do not call directly; use macros) ----- */
+
+/* mark the beginning/end of a profiler entry */
+void _profiler_mark(int type);
+
+/* return the current text in an astring */
+astring *_profiler_get_text(running_machine *machine, astring *string);
+
+
#endif /* __PROFILER_H__ */