From c2e88db89a8ba111efd0c1b61cc8dec400a007cb Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 10 Mar 2011 22:02:49 -0800 Subject: STORM-987 : Took Vadim's comment into account: check arguments consistency, make sure remaining perf data are flushed on exit. --- .../llimage_libtest/llimage_libtest.cpp | 31 ++++++++++++++++------ indra/llcommon/llmetricperformancetester.cpp | 13 ++++++++- indra/llcommon/llmetricperformancetester.h | 6 +++++ indra/llimage/llimagej2c.cpp | 1 + 4 files changed, 42 insertions(+), 9 deletions(-) (limited to 'indra') diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp index e4376dd745..2a1a2ae843 100644 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -49,16 +49,18 @@ static const char USAGE[] = "\n" " -h, --help\n" " Print this help\n" " -i, --input \n" -" List of image files to load and convert, patterns can be used\n" +" List of image files to load and convert. Patterns with wild cards can be used.\n" " -o, --output OR \n" " List of image files to create (assumes same order as for input files)\n" -" OR 3 letters file type extension to convert each input file into\n" +" OR 3 letters file type extension to convert each input file into.\n" " -log, --logmetrics \n" -" Log performance metric and data for \n" +" Log performance data for . Results in .slp\n" +" Note: so far, only ImageCompressionTester has been tested.\n" " -r, --analyzeperformance\n" -" Create report comparing baseline with current for provided in --logmetrics\n" +" Create a report comparing _baseline.slp with current .slp\n" +" Results in _report.csv" " -s, --image-stats\n" -" Output stats for each input and output image\n" +" Output stats for each input and output image.\n" "\n"; // true when all image loading is done. Used by metric logging thread to know when to stop the thread. @@ -259,6 +261,8 @@ public: os.flush(); ms_sleep(32); } + LLFastTimer::writeLog(os); + os.flush(); os.close(); } }; @@ -344,12 +348,18 @@ int main(int argc, char** argv) } } - // Analyze the list of (input,output) files + // Check arguments consistency. Exit with proper message if inconsistent. if (input_filenames.size() == 0) { std::cout << "No input file, nothing to do -> exit" << std::endl; return 0; } + if (analyze_performance && !LLFastTimer::sMetricLog) + { + std::cout << "Cannot create perf report if no perf gathered (i.e. use argument -log with -r) -> exit" << std::endl; + return 0; + } + // Create the logging thread if required if (LLFastTimer::sMetricLog) @@ -388,8 +398,13 @@ int main(int argc, char** argv) ++out_file; } } - - sAllDone = true; + + // Stop the perf gathering system if needed + if (LLFastTimer::sMetricLog) + { + LLMetricPerformanceTesterBasic::deleteTester(LLFastTimer::sLogName); + sAllDone = true; + } // Output perf data if requested by user if (analyze_performance) diff --git a/indra/llcommon/llmetricperformancetester.cpp b/indra/llcommon/llmetricperformancetester.cpp index 1f1c633909..41d3eb0bf3 100644 --- a/indra/llcommon/llmetricperformancetester.cpp +++ b/indra/llcommon/llmetricperformancetester.cpp @@ -63,7 +63,18 @@ BOOL LLMetricPerformanceTesterBasic::addTester(LLMetricPerformanceTesterBasic* t sTesterMap.insert(std::make_pair(name, tester)); return TRUE; } - + +/*static*/ +void LLMetricPerformanceTesterBasic::deleteTester(std::string name) +{ + name_tester_map_t::iterator tester = sTesterMap.find(name); + if (tester != sTesterMap.end()) + { + delete tester->second; + sTesterMap.erase(tester); + } +} + /*static*/ LLMetricPerformanceTesterBasic* LLMetricPerformanceTesterBasic::getTester(std::string name) { diff --git a/indra/llcommon/llmetricperformancetester.h b/indra/llcommon/llmetricperformancetester.h index b790b636a7..1a18cdf36f 100644 --- a/indra/llcommon/llmetricperformancetester.h +++ b/indra/llcommon/llmetricperformancetester.h @@ -137,6 +137,12 @@ public: */ static LLMetricPerformanceTesterBasic* getTester(std::string name) ; + /** + * @return Delete the named tester from the list + * @param[in] name - Name of the tester instance to delete. + */ + static void deleteTester(std::string name); + /** * @return Returns TRUE if that metric *or* the default catch all metric has been requested to be logged * @param[in] name - Name of the tester queried. diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index cb2a85fa91..80fec7f8a0 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -474,6 +474,7 @@ LLImageCompressionTester::LLImageCompressionTester() : LLMetricPerformanceTester LLImageCompressionTester::~LLImageCompressionTester() { + outputTestResults(); LLImageJ2C::sTesterp = NULL; } -- cgit v1.2.3