From 1ed11971aebed2cf6c9b9f212adb36c50487266f Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Thu, 26 Nov 2009 15:57:03 -0500 Subject: [PATCH] Use a common function to print stats of all modules Removes code duplication. Signed-off-by: Benjamin Poirier --- lttv/lttv/sync/sync_chain.c | 23 +++++++++++++++++++++++ lttv/lttv/sync/sync_chain.h | 1 + lttv/lttv/sync/sync_chain_lttv.c | 19 ++++--------------- lttv/modules/text/sync_chain_batch.c | 14 ++------------ 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/lttv/lttv/sync/sync_chain.c b/lttv/lttv/sync/sync_chain.c index 0d9773fa..c32f341b 100644 --- a/lttv/lttv/sync/sync_chain.c +++ b/lttv/lttv/sync/sync_chain.c @@ -33,6 +33,29 @@ GQueue analysisModules= G_QUEUE_INIT; GQueue moduleOptions= G_QUEUE_INIT; +/* + * Calculate the elapsed time between two timeval values + * + * Args: + * syncState: Container for synchronization data + */ +void printStats(SyncState* const syncState) +{ + if (syncState->processingModule->printProcessingStats != NULL) + { + syncState->processingModule->printProcessingStats(syncState); + } + if (syncState->matchingModule->printMatchingStats != NULL) + { + syncState->matchingModule->printMatchingStats(syncState); + } + if (syncState->analysisModule->printAnalysisStats != NULL) + { + syncState->analysisModule->printAnalysisStats(syncState); + } +} + + /* * Calculate the elapsed time between two timeval values * diff --git a/lttv/lttv/sync/sync_chain.h b/lttv/lttv/sync/sync_chain.h index d187b304..d999c9ce 100644 --- a/lttv/lttv/sync/sync_chain.h +++ b/lttv/lttv/sync/sync_chain.h @@ -65,6 +65,7 @@ extern GQueue matchingModules; extern GQueue analysisModules; extern GQueue moduleOptions; +void printStats(SyncState* const syncState); void timeDiff(struct timeval* const end, const struct timeval* const start); diff --git a/lttv/lttv/sync/sync_chain_lttv.c b/lttv/lttv/sync/sync_chain_lttv.c index f2389bd8..640042d1 100644 --- a/lttv/lttv/sync/sync_chain_lttv.c +++ b/lttv/lttv/sync/sync_chain_lttv.c @@ -181,7 +181,7 @@ void syncTraceset(LttvTracesetContext* const traceSetContext) syncState->stats= false; } - if (optionSyncGraphs.present) + if (!optionSyncNull.present && optionSyncGraphs.present) { // Create the graph directory right away in case the module initialization // functions have something to write in it. @@ -242,7 +242,7 @@ void syncTraceset(LttvTracesetContext* const traceSetContext) syncState->processingModule->finalizeProcessing(syncState); // Write graphs file - if (optionSyncGraphs.present) + if (!optionSyncNull.present && optionSyncGraphs.present) { writeGraphsScript(syncState); @@ -252,21 +252,10 @@ void syncTraceset(LttvTracesetContext* const traceSetContext) } } - if (syncState->processingModule->printProcessingStats != NULL) + if (!optionSyncNull.present && optionSyncStats.present) { - syncState->processingModule->printProcessingStats(syncState); - } - if (syncState->matchingModule->printMatchingStats != NULL) - { - syncState->matchingModule->printMatchingStats(syncState); - } - if (syncState->analysisModule->printAnalysisStats != NULL) - { - syncState->analysisModule->printAnalysisStats(syncState); - } + printStats(syncState); - if (optionSyncStats.present) - { printf("Resulting synchronization factors:\n"); for (i= 0; i < syncState->traceNb; i++) { diff --git a/lttv/modules/text/sync_chain_batch.c b/lttv/modules/text/sync_chain_batch.c index c88b13c5..55abb676 100644 --- a/lttv/modules/text/sync_chain_batch.c +++ b/lttv/modules/text/sync_chain_batch.c @@ -291,6 +291,7 @@ void setupSyncChain(LttvTracesetContext* const traceSetContext) tracesetChainState->syncState= syncState; syncState->traceNb= lttv_traceset_number(traceSetContext->ts); + // Statistics are always on with eval syncState->stats= true; if (optionEvalGraphs) @@ -357,18 +358,7 @@ void teardownSyncChain(LttvTracesetContext* const traceSetContext) } } - if (syncState->processingModule->printProcessingStats != NULL) - { - syncState->processingModule->printProcessingStats(syncState); - } - if (syncState->matchingModule->printMatchingStats != NULL) - { - syncState->matchingModule->printMatchingStats(syncState); - } - if (syncState->analysisModule->printAnalysisStats != NULL) - { - syncState->analysisModule->printAnalysisStats(syncState); - } + printStats(syncState); printf("Resulting synchronization factors:\n"); for (i= 0; i < syncState->traceNb; i++) -- 2.39.5