From a701a6d9dd272be961149477170384c7c591eb2d Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Thu, 24 Jul 2014 03:23:41 -0700 Subject: [PATCH] Benchmark option to disable video rendering fully --- src/platform/perf-main.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/platform/perf-main.c b/src/platform/perf-main.c index 0873b26b9..3216bf187 100644 --- a/src/platform/perf-main.c +++ b/src/platform/perf-main.c @@ -7,18 +7,20 @@ #include #include -#define PERF_OPTIONS "S:" +#define PERF_OPTIONS "NS:" #define PERF_USAGE \ "\nBenchmark options:\n" \ + " -N Disable video rendering entirely" \ " -S SEC Run for SEC in-game seconds before exiting" struct PerfOpts { + bool noVideo; int duration; }; static void _GBAPerfRunloop(struct GBAThread* context, int* frames); static void _GBAPerfShutdown(int signal); -static int _parsePerfOpts(struct SubParser* parser, int option, const char* arg); +static bool _parsePerfOpts(struct SubParser* parser, int option, const char* arg); static struct GBAThread* _thread; @@ -28,7 +30,7 @@ int main(int argc, char** argv) { struct GBAVideoSoftwareRenderer renderer; GBAVideoSoftwareRendererCreate(&renderer); - struct PerfOpts perfOpts = { 0 }; + struct PerfOpts perfOpts = { false, 0 }; struct SubParser subparser = { .usage = PERF_USAGE, .parse = _parsePerfOpts, @@ -46,12 +48,15 @@ int main(int argc, char** argv) { renderer.outputBufferStride = 256; struct GBAThread context = { - .renderer = &renderer.d, .sync.videoFrameWait = 0, .sync.audioWait = 0 }; _thread = &context; + if (!perfOpts.noVideo) { + context.renderer = &renderer.d; + } + context.debugger = createDebugger(&opts); GBAMapOptionsToContext(&opts, &context); @@ -113,13 +118,16 @@ static void _GBAPerfShutdown(int signal) { pthread_mutex_unlock(&_thread->stateMutex); } -static int _parsePerfOpts(struct SubParser* parser, int option, const char* arg) { +static bool _parsePerfOpts(struct SubParser* parser, int option, const char* arg) { struct PerfOpts* opts = parser->opts; switch (option) { + case 'N': + opts->noVideo = true; + return true; case 'S': opts->duration = strtol(arg, 0, 10); return !errno; default: - return 0; + return false; } }