From 6eee9f878a34f4b3ea4b3b3435a1f9b5beae6210 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Sun, 23 Nov 2008 15:21:27 +0000 Subject: [PATCH] Add a --machine-readable RTS flag Currently it only affects the -t flag output --- includes/RtsFlags.h | 1 + rts/RtsFlags.c | 5 +++++ rts/Stats.c | 24 ++++++++++++++++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/includes/RtsFlags.h b/includes/RtsFlags.h index e14c940..db196a9 100644 --- a/includes/RtsFlags.h +++ b/includes/RtsFlags.h @@ -121,6 +121,7 @@ struct CONCURRENT_FLAGS { struct MISC_FLAGS { int tickInterval; /* in milliseconds */ rtsBool install_signal_handlers; + rtsBool machineReadable; StgWord linkerMemBase; /* address to ask the OS for memory * for the linker, NULL ==> off */ }; diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c index cce2b28..14f4fb0 100644 --- a/rts/RtsFlags.c +++ b/rts/RtsFlags.c @@ -208,6 +208,7 @@ void initRtsFlagsDefaults(void) RtsFlags.ConcFlags.ctxtSwitchTime = 20; /* In milliseconds */ RtsFlags.MiscFlags.install_signal_handlers = rtsTrue; + RtsFlags.MiscFlags.machineReadable = rtsFalse; RtsFlags.MiscFlags.linkerMemBase = 0; #ifdef THREADED_RTS @@ -696,6 +697,10 @@ error = rtsTrue; &rts_argv[arg][2])) { RtsFlags.MiscFlags.install_signal_handlers = rtsFalse; } + else if (strequal("machine-readable", + &rts_argv[arg][2])) { + RtsFlags.MiscFlags.machineReadable = rtsTrue; + } else if (strequal("info", &rts_argv[arg][2])) { printRtsInfo(); diff --git a/rts/Stats.c b/rts/Stats.c index 9c17856..3ec5794 100644 --- a/rts/Stats.c +++ b/rts/Stats.c @@ -726,9 +726,29 @@ stat_exit(int alloc) } if (RtsFlags.GcFlags.giveStats == ONELINE_GC_STATS) { + char *fmt1, *fmt2; + if (RtsFlags.MiscFlags.machineReadable) { + fmt1 = " [(\"bytes allocated\", \"%llu\")\n"; + fmt2 = " ,(\"num_GCs\", \"%d\")\n" + " ,(\"average_bytes_used\", \"%ld\")\n" + " ,(\"max_bytes_used\", \"%ld\")\n" + " ,(\"num_byte_usage_samples\", \"%ld\")\n" + " ,(\"peak_megabytes_allocated\", \"%lu\")\n" + " ,(\"init_cpu_seconds\", \"%.2f\")\n" + " ,(\"init_wall_seconds\", \"%.2f\")\n" + " ,(\"mutator_cpu_seconds\", \"%.2f\")\n" + " ,(\"mutator_wall_seconds\", \"%.2f\")\n" + " ,(\"GC_cpu_seconds\", \"%.2f\")\n" + " ,(\"GC_wall_seconds\", \"%.2f\")\n" + " ]\n"; + } + else { + fmt1 = "<>\n", + statsPrintf(fmt1, GC_tot_alloc*(ullong)sizeof(W_)); + statsPrintf(fmt2, total_collections, ResidencySamples == 0 ? 0 : AvgResidency*sizeof(W_)/ResidencySamples, -- 1.7.10.4