From cda7a0f8cf03b7a99e077043daa2d99ac16ace81 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 9 Feb 2011 23:32:46 -0800 Subject: STORM-987 : Create initial files for llimage_libtest (doesn't build) --- .../llimage_libtest/llimage_libtest.cpp | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 indra/integration_tests/llimage_libtest/llimage_libtest.cpp (limited to 'indra/integration_tests/llimage_libtest/llimage_libtest.cpp') diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp new file mode 100644 index 0000000000..a4a4d10bcb --- /dev/null +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -0,0 +1,47 @@ +/** + * @file llimage_libtest.cpp + * @author Merov Linden + * @brief Integration test for the llimage library + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ +#include "linden_common.h" + +#include "llimage_libtest.h" + +// linden library includes + +#include + +// *TODO: switch to using TUT +// *TODO: teach TeamCity about this program, run automatically after full builds + +void init_llimage() +{ +} + +int main(int argc, char** argv) +{ + init_llimage(); + + return 0; +} -- cgit v1.2.3 From 0ca7011b3154fd5db0a125f7d90de1c1e460105f Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 15 Feb 2011 22:43:54 -0800 Subject: STORM-987 : Add in and out command line arguments, builds and runs on Windows and Mac --- .../llimage_libtest/llimage_libtest.cpp | 123 +++++++++++++-------- 1 file changed, 78 insertions(+), 45 deletions(-) (limited to 'indra/integration_tests/llimage_libtest/llimage_libtest.cpp') diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp index e8fe4864fb..6549aa0207 100644 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -41,15 +41,19 @@ // system libraries #include +// doc string provided when invoking the program with --help static const char USAGE[] = "\n" "usage:\tllimage_libtest [options]\n" "\n" " --help print this help\n" +" --in ... list of image files to load and convert\n" +" --out ... list of image files to create (assumes same order as --in files)\n" "\n"; -LLPointer load_image(const std::string &src_filename) +// Create an empty formatted image instance of the correct type from the filename +LLPointer create_image(const std::string &filename) { - std::string exten = gDirUtilp->getExtension(src_filename); + std::string exten = gDirUtilp->getExtension(filename); U32 codec = LLImageBase::getCodecFromExtension(exten); LLPointer image; @@ -73,6 +77,14 @@ LLPointer load_image(const std::string &src_filename) default: return NULL; } + + return image; +} + +// Load an image from file and return a raw (decompressed) instance of its data +LLPointer load_image(const std::string &src_filename) +{ + LLPointer image = create_image(src_filename); if (!image->load(src_filename)) { @@ -94,79 +106,100 @@ LLPointer load_image(const std::string &src_filename) return raw_image; } -bool save_image(const std::string &filepath, LLPointer raw_image) +// Save a raw image instance into a file +bool save_image(const std::string &dest_filename, LLPointer raw_image) { - std::string exten = gDirUtilp->getExtension(filepath); - U32 codec = LLImageBase::getCodecFromExtension(exten); - - LLPointer image; - switch (codec) - { - case IMG_CODEC_BMP: - image = new LLImageBMP(); - break; - case IMG_CODEC_TGA: - image = new LLImageTGA(); - break; - case IMG_CODEC_JPEG: - image = new LLImageJPEG(); - break; - case IMG_CODEC_J2C: - image = new LLImageJ2C(); - break; - case IMG_CODEC_PNG: - image = new LLImagePNG(); - break; - default: - return NULL; - } + LLPointer image = create_image(dest_filename); if (!image->encode(raw_image, 0.0f)) { return false; } - return image->save(filepath); + return image->save(dest_filename); } int main(int argc, char** argv) { + // List of input and output files + std::list input_filenames; + std::list output_filenames; + // Init whatever is necessary ll_init_apr(); LLImage::initClass(); // Analyze command line arguments - for (int arg=1; arg raw_image = load_image("lolcat-monorail.jpg"); - if (raw_image) + // Analyze the list of (input,output) files + if (input_filenames.size() == 0) { - std::cout << "Image loaded\n" << std::endl; + std::cout << "No input file, nothing to do -> exit" << std::endl; + return 0; } - else + // TODO: For the moment, we simply convert each input file to something. This needs to evolve... + if (input_filenames.size() != output_filenames.size()) { - std::cout << "Image not found\n" << std::endl; + std::cout << "Number of output and input files different -> exit" << std::endl; + return 0; } - - // Save file - if (raw_image) + + std::list::iterator in_file = input_filenames.begin(); + std::list::iterator out_file = output_filenames.begin(); + std::list::iterator end = input_filenames.end(); + for (; in_file != end; ++in_file, ++out_file) { - save_image("monorail.png",raw_image); + // Load file + LLPointer raw_image = load_image(*in_file); + if (!raw_image) + { + std::cout << "Error: Image " << *in_file << " could not be loaded" << std::endl; + continue; + } + + // Save file + if (!save_image(*out_file, raw_image)) + { + std::cout << "Error: Image " << *out_file << " could not be saved" << std::endl; + continue; + } + std::cout << *in_file << " -> " << *out_file << std::endl; + + // Output stats on each file } - - // Output stats on each file // Cleanup and exit LLImage::cleanupClass(); -- cgit v1.2.3 From 0dbc5a40cb83919187fed961de835726e044906d Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 16 Feb 2011 17:29:32 -0800 Subject: STORM-987 : Implement in and out list of files and pattern matching --- .../llimage_libtest/llimage_libtest.cpp | 117 ++++++++++++++++++--- 1 file changed, 105 insertions(+), 12 deletions(-) (limited to 'indra/integration_tests/llimage_libtest/llimage_libtest.cpp') diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp index 6549aa0207..37e979b260 100644 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -45,9 +45,10 @@ static const char USAGE[] = "\n" "usage:\tllimage_libtest [options]\n" "\n" -" --help print this help\n" -" --in ... list of image files to load and convert\n" -" --out ... list of image files to create (assumes same order as --in files)\n" +" --help print this help\n" +" --in list of image files to load and convert, patterns can be used\n" +" --out OR list of image files to create (assumes same order as --in files)\n" +" OR 3 letters file type extension to convert each input file into\n" "\n"; // Create an empty formatted image instance of the correct type from the filename @@ -119,6 +120,88 @@ bool save_image(const std::string &dest_filename, LLPointer raw_imag return image->save(dest_filename); } +void store_input_file(std::list &input_filenames, const std::string &path) +{ + // Break the incoming path in its components + std::string dir = gDirUtilp->getDirName(path); + std::string name = gDirUtilp->getBaseFileName(path); + std::string exten = gDirUtilp->getExtension(path); + + // std::cout << "store_input_file : " << path << ", dir : " << dir << ", name : " << name << ", exten : " << exten << std::endl; + + // If extension is not an image type or "*", exit + // Note: we don't support complex patterns for the extension like "j??" + // Note: on most shells, the pattern expansion is done by the shell so that pattern matching limitation is actually not a problem + if ((exten.compare("*") != 0) && (LLImageBase::getCodecFromExtension(exten) == IMG_CODEC_INVALID)) + { + return; + } + + if ((name.find('*') != -1) || ((name.find('?') != -1))) + { + // If file name is a pattern, iterate to get each file name and store + std::string next_name; + while (gDirUtilp->getNextFileInDir(dir,name,next_name)) + { + std::string file_name = dir + gDirUtilp->getDirDelimiter() + next_name; + input_filenames.push_back(file_name); + } + } + else + { + // Verify that the file does exist before storing + if (gDirUtilp->fileExists(path)) + { + input_filenames.push_back(path); + } + else + { + std::cout << "store_input_file : the file " << path << " could not be found" << std::endl; + } + } +} + +void store_output_file(std::list &output_filenames, std::list &input_filenames, const std::string &path) +{ + // Break the incoming path in its components + std::string dir = gDirUtilp->getDirName(path); + std::string name = gDirUtilp->getBaseFileName(path); + std::string exten = gDirUtilp->getExtension(path); + + // std::cout << "store_output_file : " << path << ", dir : " << dir << ", name : " << name << ", exten : " << exten << std::endl; + + if (dir.empty() && exten.empty()) + { + // If dir and exten are empty, we interpret the name as a file extension type name and will iterate through input list to populate the output list + exten = name; + // Make sure the extension is an image type + if (LLImageBase::getCodecFromExtension(exten) == IMG_CODEC_INVALID) + { + return; + } + std::string delim = gDirUtilp->getDirDelimiter(); + std::list::iterator in_file = input_filenames.begin(); + std::list::iterator end = input_filenames.end(); + for (; in_file != end; ++in_file) + { + dir = gDirUtilp->getDirName(*in_file); + name = gDirUtilp->getBaseFileName(*in_file,true); + std::string file_name = dir + delim + name + "." + exten; + output_filenames.push_back(file_name); + } + } + else + { + // Make sure the extension is an image type + if (LLImageBase::getCodecFromExtension(exten) == IMG_CODEC_INVALID) + { + return; + } + // Store the path + output_filenames.push_back(path); + } +} + int main(int argc, char** argv) { // List of input and output files @@ -143,24 +226,40 @@ int main(int argc, char** argv) std::string file_name = argv[arg+1]; while (file_name[0] != '-') // if arg starts with '-', we consider it's not a file name but some other argument { - input_filenames.push_back(file_name); // Add file name to the list + // std::cout << "input file name : " << file_name << std::endl; + store_input_file(input_filenames, file_name); arg += 1; // Skip that arg now we know it's a file name if ((arg + 1) == argc) // Break out of the loop if we reach the end of the arg list break; file_name = argv[arg+1]; // Next argument and loop over } - } + // DEBUG output + std::list::iterator in_file = input_filenames.begin(); + std::list::iterator end = input_filenames.end(); + for (; in_file != end; ++in_file) + { + std::cout << "input file : " << *in_file << std::endl; + } + } else if (!strcmp(argv[arg], "--out") && arg < argc-1) { std::string file_name = argv[arg+1]; while (file_name[0] != '-') // if arg starts with '-', we consider it's not a file name but some other argument { - output_filenames.push_back(file_name); // Add file name to the list + // std::cout << "output file name : " << file_name << std::endl; + store_output_file(output_filenames, input_filenames, file_name); arg += 1; // Skip that arg now we know it's a file name if ((arg + 1) == argc) // Break out of the loop if we reach the end of the arg list break; file_name = argv[arg+1]; // Next argument and loop over } + // DEBUG output + std::list::iterator out_file = output_filenames.begin(); + std::list::iterator end = output_filenames.end(); + for (; out_file != end; ++out_file) + { + std::cout << "output file : " << *out_file << std::endl; + } } } @@ -170,12 +269,6 @@ int main(int argc, char** argv) std::cout << "No input file, nothing to do -> exit" << std::endl; return 0; } - // TODO: For the moment, we simply convert each input file to something. This needs to evolve... - if (input_filenames.size() != output_filenames.size()) - { - std::cout << "Number of output and input files different -> exit" << std::endl; - return 0; - } std::list::iterator in_file = input_filenames.begin(); std::list::iterator out_file = output_filenames.begin(); -- cgit v1.2.3 From 7d47ea1ab254e13cbff476fee317042f81d84b25 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 16 Feb 2011 21:50:32 -0800 Subject: STORM-987 : Allow more flexibility around input and output lists --- .../llimage_libtest/llimage_libtest.cpp | 36 ++++++++++------------ 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'indra/integration_tests/llimage_libtest/llimage_libtest.cpp') diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp index 37e979b260..4104527f83 100644 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -233,13 +233,6 @@ int main(int argc, char** argv) break; file_name = argv[arg+1]; // Next argument and loop over } - // DEBUG output - std::list::iterator in_file = input_filenames.begin(); - std::list::iterator end = input_filenames.end(); - for (; in_file != end; ++in_file) - { - std::cout << "input file : " << *in_file << std::endl; - } } else if (!strcmp(argv[arg], "--out") && arg < argc-1) { @@ -253,13 +246,6 @@ int main(int argc, char** argv) break; file_name = argv[arg+1]; // Next argument and loop over } - // DEBUG output - std::list::iterator out_file = output_filenames.begin(); - std::list::iterator end = output_filenames.end(); - for (; out_file != end; ++out_file) - { - std::cout << "output file : " << *out_file << std::endl; - } } } @@ -270,10 +256,12 @@ int main(int argc, char** argv) return 0; } + // Perform action on each input file std::list::iterator in_file = input_filenames.begin(); std::list::iterator out_file = output_filenames.begin(); - std::list::iterator end = input_filenames.end(); - for (; in_file != end; ++in_file, ++out_file) + std::list::iterator in_end = input_filenames.end(); + std::list::iterator out_end = output_filenames.end(); + for (; in_file != in_end; ++in_file) { // Load file LLPointer raw_image = load_image(*in_file); @@ -284,16 +272,24 @@ int main(int argc, char** argv) } // Save file - if (!save_image(*out_file, raw_image)) + if (out_file != out_end) { - std::cout << "Error: Image " << *out_file << " could not be saved" << std::endl; - continue; + if (!save_image(*out_file, raw_image)) + { + std::cout << "Error: Image " << *out_file << " could not be saved" << std::endl; + } + else + { + std::cout << *in_file << " -> " << *out_file << std::endl; + } + ++out_file; } - std::cout << *in_file << " -> " << *out_file << std::endl; // Output stats on each file } + // Output perf data if required by user + // Cleanup and exit LLImage::cleanupClass(); -- cgit v1.2.3 From cb0dcc204dd8cd6015ffc25c19557b76cf213084 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 8 Mar 2011 23:44:00 -0800 Subject: STORM-987 : Add --logmetrics and --analyzeperformance arguments, moved analyzeMetricPerformanceLog() and doAnalysisMetrics() from LLFastTimerView to LLMetricPerformanceTesterBasic --- .../llimage_libtest/llimage_libtest.cpp | 89 +++++++++++++++++++++- 1 file changed, 87 insertions(+), 2 deletions(-) (limited to 'indra/integration_tests/llimage_libtest/llimage_libtest.cpp') diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp index 4104527f83..2442313ef2 100644 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -26,6 +26,7 @@ */ #include "linden_common.h" #include "llpointer.h" +#include "lltimer.h" #include "llimage_libtest.h" @@ -49,8 +50,13 @@ static const char USAGE[] = "\n" " --in list of image files to load and convert, patterns can be used\n" " --out OR list of image files to create (assumes same order as --in files)\n" " OR 3 letters file type extension to convert each input file into\n" +" --logmetrics log performance metric and data for \n" +" --analyzeperformance create report comparing baseline with current for provided in --logmetrics\n" "\n"; +// true when all image loading is done. Used by metric logging thread to know when to stop the thread. +static bool sAllDone = false; + // Create an empty formatted image instance of the correct type from the filename LLPointer create_image(const std::string &filename) { @@ -202,15 +208,43 @@ void store_output_file(std::list &output_filenames, std::list input_filenames; std::list output_filenames; + bool analyze_performance = false; // Init whatever is necessary ll_init_apr(); LLImage::initClass(); + LogThread* fast_timer_log_thread = NULL; // For performance and metric gathering // Analyze command line arguments for (int arg = 1; arg < argc; ++arg) @@ -246,7 +280,34 @@ int main(int argc, char** argv) break; file_name = argv[arg+1]; // Next argument and loop over } - } + } + else if (!strcmp(argv[arg], "--logmetrics")) + { + // '--logmetrics' needs to be specified with a named test metric argument + // Note: for the moment, only ImageCompressionTester has been tested + std::string test_name; + if ((arg + 1) < argc) + { + test_name = argv[arg+1]; + } + if (((arg + 1) >= argc) || (test_name[0] == '-')) + { + // We don't have an argument left in the arg list or the next argument is another option + std::cout << "No --logmetrics argument given, no perf data will be gathered" << std::endl; + } + else + { + LLFastTimer::sMetricLog = TRUE; + LLFastTimer::sLogName = test_name; + arg += 1; // Skip that arg now we know it's a valid test name + if ((arg + 1) == argc) // Break out of the loop if we reach the end of the arg list + break; + } + } + else if (!strcmp(argv[arg], "--analyzeperformance")) + { + analyze_performance = true; + } } // Analyze the list of (input,output) files @@ -256,6 +317,14 @@ int main(int argc, char** argv) return 0; } + // Create the logging thread if required + if (LLFastTimer::sMetricLog) + { + LLFastTimer::sLogLock = new LLMutex(NULL); + fast_timer_log_thread = new LogThread(LLFastTimer::sLogName); + fast_timer_log_thread->start(); + } + // Perform action on each input file std::list::iterator in_file = input_filenames.begin(); std::list::iterator out_file = output_filenames.begin(); @@ -288,10 +357,26 @@ int main(int argc, char** argv) // Output stats on each file } - // Output perf data if required by user + sAllDone = true; + + // Output perf data if requested by user + if (analyze_performance) + { + std::cout << "Analyzing performance" << std::endl; + + std::string baseline_name = LLFastTimer::sLogName + "_baseline.slp"; + std::string current_name = LLFastTimer::sLogName + ".slp"; + std::string report_name = LLFastTimer::sLogName + "_report.csv"; + + LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline_name, current_name, report_name); + } // Cleanup and exit LLImage::cleanupClass(); + if (fast_timer_log_thread) + { + fast_timer_log_thread->shutdown(); + } return 0; } -- cgit v1.2.3 From 7f42c02cad9dbd068bc49bed4b6cd18fd8fff606 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 9 Mar 2011 20:54:59 -0800 Subject: STORM-987 : Add the --image-stats argument, make argument passing more consistent, fix typos in comments in llimage header --- .../llimage_libtest/llimage_libtest.cpp | 66 ++++++++++++++++------ 1 file changed, 49 insertions(+), 17 deletions(-) (limited to 'indra/integration_tests/llimage_libtest/llimage_libtest.cpp') diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp index 2442313ef2..e4376dd745 100644 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -46,12 +46,19 @@ static const char USAGE[] = "\n" "usage:\tllimage_libtest [options]\n" "\n" -" --help print this help\n" -" --in list of image files to load and convert, patterns can be used\n" -" --out OR list of image files to create (assumes same order as --in files)\n" -" OR 3 letters file type extension to convert each input file into\n" -" --logmetrics log performance metric and data for \n" -" --analyzeperformance create report comparing baseline with current for provided in --logmetrics\n" +" -h, --help\n" +" Print this help\n" +" -i, --input \n" +" List of image files to load and convert, patterns 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" +" -log, --logmetrics \n" +" Log performance metric and data for \n" +" -r, --analyzeperformance\n" +" Create report comparing baseline with current for provided in --logmetrics\n" +" -s, --image-stats\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. @@ -88,8 +95,20 @@ LLPointer create_image(const std::string &filename) return image; } +void output_image_stats(LLPointer image, const std::string &filename) +{ + // Print out some statistical data on the image + std::cout << "Image stats for : " << filename << ", extension : " << image->getExtension() << std::endl; + + std::cout << " with : " << (int)(image->getWidth()) << ", height : " << (int)(image->getHeight()) << std::endl; + std::cout << " comp : " << (int)(image->getComponents()) << ", levels : " << (int)(image->getDiscardLevel()) << std::endl; + std::cout << " head : " << (int)(image->calcHeaderSize()) << ", data : " << (int)(image->getDataSize()) << std::endl; + + return; +} + // Load an image from file and return a raw (decompressed) instance of its data -LLPointer load_image(const std::string &src_filename) +LLPointer load_image(const std::string &src_filename, bool output_stats) { LLPointer image = create_image(src_filename); @@ -104,6 +123,11 @@ LLPointer load_image(const std::string &src_filename) return NULL; } + if (output_stats) + { + output_image_stats(image, src_filename); + } + LLPointer raw_image = new LLImageRaw; if (!image->decode(raw_image, 0.0f)) { @@ -114,7 +138,7 @@ LLPointer load_image(const std::string &src_filename) } // Save a raw image instance into a file -bool save_image(const std::string &dest_filename, LLPointer raw_image) +bool save_image(const std::string &dest_filename, LLPointer raw_image, bool output_stats) { LLPointer image = create_image(dest_filename); @@ -123,6 +147,11 @@ bool save_image(const std::string &dest_filename, LLPointer raw_imag return false; } + if (output_stats) + { + output_image_stats(image, dest_filename); + } + return image->save(dest_filename); } @@ -240,6 +269,7 @@ int main(int argc, char** argv) std::list input_filenames; std::list output_filenames; bool analyze_performance = false; + bool image_stats = false; // Init whatever is necessary ll_init_apr(); @@ -249,13 +279,13 @@ int main(int argc, char** argv) // Analyze command line arguments for (int arg = 1; arg < argc; ++arg) { - if (!strcmp(argv[arg], "--help")) + if (!strcmp(argv[arg], "--help") || !strcmp(argv[arg], "-h")) { // Send the usage to standard out std::cout << USAGE << std::endl; return 0; } - else if (!strcmp(argv[arg], "--in") && arg < argc-1) + else if ((!strcmp(argv[arg], "--input") || !strcmp(argv[arg], "-i")) && arg < argc-1) { std::string file_name = argv[arg+1]; while (file_name[0] != '-') // if arg starts with '-', we consider it's not a file name but some other argument @@ -268,7 +298,7 @@ int main(int argc, char** argv) file_name = argv[arg+1]; // Next argument and loop over } } - else if (!strcmp(argv[arg], "--out") && arg < argc-1) + else if ((!strcmp(argv[arg], "--output") || !strcmp(argv[arg], "-o")) && arg < argc-1) { std::string file_name = argv[arg+1]; while (file_name[0] != '-') // if arg starts with '-', we consider it's not a file name but some other argument @@ -281,7 +311,7 @@ int main(int argc, char** argv) file_name = argv[arg+1]; // Next argument and loop over } } - else if (!strcmp(argv[arg], "--logmetrics")) + else if (!strcmp(argv[arg], "--logmetrics") || !strcmp(argv[arg], "-log")) { // '--logmetrics' needs to be specified with a named test metric argument // Note: for the moment, only ImageCompressionTester has been tested @@ -304,10 +334,14 @@ int main(int argc, char** argv) break; } } - else if (!strcmp(argv[arg], "--analyzeperformance")) + else if (!strcmp(argv[arg], "--analyzeperformance") || !strcmp(argv[arg], "-r")) { analyze_performance = true; } + else if (!strcmp(argv[arg], "--image-stats") || !strcmp(argv[arg], "-s")) + { + image_stats = true; + } } // Analyze the list of (input,output) files @@ -333,7 +367,7 @@ int main(int argc, char** argv) for (; in_file != in_end; ++in_file) { // Load file - LLPointer raw_image = load_image(*in_file); + LLPointer raw_image = load_image(*in_file, image_stats); if (!raw_image) { std::cout << "Error: Image " << *in_file << " could not be loaded" << std::endl; @@ -343,7 +377,7 @@ int main(int argc, char** argv) // Save file if (out_file != out_end) { - if (!save_image(*out_file, raw_image)) + if (!save_image(*out_file, raw_image, image_stats)) { std::cout << "Error: Image " << *out_file << " could not be saved" << std::endl; } @@ -353,8 +387,6 @@ int main(int argc, char** argv) } ++out_file; } - - // Output stats on each file } sAllDone = true; -- cgit v1.2.3 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 ++++++++++++++++------ 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'indra/integration_tests/llimage_libtest/llimage_libtest.cpp') 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) -- cgit v1.2.3 From 29bcedaf0256968ec48ed3c5791da4b4a23e42d1 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 25 Mar 2011 17:18:28 -0700 Subject: STORM-987 : Fix the creation of images in local dir --- indra/integration_tests/llimage_libtest/llimage_libtest.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'indra/integration_tests/llimage_libtest/llimage_libtest.cpp') diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp index 2a1a2ae843..365f5f758c 100644 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -223,7 +223,15 @@ void store_output_file(std::list &output_filenames, std::listgetDirName(*in_file); name = gDirUtilp->getBaseFileName(*in_file,true); - std::string file_name = dir + delim + name + "." + exten; + std::string file_name; + if (!dir.empty()) + { + file_name = dir + delim + name + "." + exten; + } + else + { + file_name = name + "." + exten; + } output_filenames.push_back(file_name); } } -- cgit v1.2.3