From cf02b2e258b617decd966477a6c79f5e9781abba Mon Sep 17 00:00:00 2001 From: Marina Kolpakova Date: Sat, 7 Apr 2012 12:51:59 +0000 Subject: [PATCH] additional android logging for output gtest xml file --- .../core/include/opencv2/core/devmem2d.hpp | 2 +- modules/ts/misc/run.py | 37 +++++++++++++------ modules/ts/src/ts_perf.cpp | 26 +++++++++++-- 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/modules/core/include/opencv2/core/devmem2d.hpp b/modules/core/include/opencv2/core/devmem2d.hpp index 3496399e2..ae8935f68 100644 --- a/modules/core/include/opencv2/core/devmem2d.hpp +++ b/modules/core/include/opencv2/core/devmem2d.hpp @@ -59,7 +59,7 @@ namespace cv // It is intended to pass to nvcc-compiled code. GpuMat depends on headers that nvcc can't compile template struct StaticAssert; - template <> struct StaticAssert {static __CV_GPU_HOST_DEVICE__ void check(){}}; + template <> struct StaticAssert {static __CV_GPU_HOST_DEVICE__ void check(){}}; template struct DevPtr { diff --git a/modules/ts/misc/run.py b/modules/ts/misc/run.py index 7c23da18e..b9db8d010 100644 --- a/modules/ts/misc/run.py +++ b/modules/ts/misc/run.py @@ -197,10 +197,15 @@ def getRunningProcessExePathByName(name): return None class RunInfo(object): + def setCallback(self, name, callback): + setattr(self, name, callback) + def __init__(self, path, options): self.options = options self.path = path self.error = None + self.setUp = None + self.tearDown = None self.nameprefix = "opencv_" + options.mode + "_" for p in parse_patterns: setattr(self, p["name"], p["default"]) @@ -602,7 +607,11 @@ class RunInfo(object): else: command = exename + " " + " ".join(args) print >> _stderr, "Running:", command + if self.setUp is not None: + self.setUp() Popen(self.adb + ["shell", "export OPENCV_TEST_DATA_PATH=" + self.test_data_path + "&& cd " + andoidcwd + "&& ./" + command], stdout=_stdout, stderr=_stderr).wait() + if self.tearDown is not None: + self.tearDown() # try get log if not self.options.help: print >> _stderr, "Pulling", logfile, "from device..." @@ -651,12 +660,27 @@ class RunInfo(object): print >> _stderr, "Error: Test \"%s\" is not found in %s" % (test, self.tests_dir) return logs +def getRunArgs(args): + run_args = [] + for path in args: + path = os.path.abspath(path) + while (True): + if os.path.isdir(path) and os.path.isfile(os.path.join(path, "CMakeCache.txt")): + run_args.append(path) + break + npath = os.path.dirname(path) + if npath == path: + break + path = npath + return run_args + if __name__ == "__main__": test_args = [a for a in sys.argv if a.startswith("--perf_") or a.startswith("--gtest_")] argv = [a for a in sys.argv if not(a.startswith("--perf_") or a.startswith("--gtest_"))] parser = OptionParser() parser.add_option("-t", "--tests", dest="tests", help="comma-separated list of modules to test", metavar="SUITS", default="") + parser.add_option("-w", "--cwd", dest="cwd", help="working directory for tests", metavar="PATH", default=".") parser.add_option("-a", "--accuracy", dest="accuracy", help="look for accuracy tests instead of performance tests", action="store_true", default=False) parser.add_option("-l", "--longname", dest="useLongNames", action="store_true", help="generate log files with long names", default=False) @@ -672,18 +696,7 @@ if __name__ == "__main__": else: options.mode = "perf" - run_args = [] - - for path in args: - path = os.path.abspath(path) - while (True): - if os.path.isdir(path) and os.path.isfile(os.path.join(path, "CMakeCache.txt")): - run_args.append(path) - break - npath = os.path.dirname(path) - if npath == path: - break - path = npath + run_args = getRunArgs(args) if len(run_args) == 0: print >> sys.stderr, "Usage:\n", os.path.basename(sys.argv[0]), "" diff --git a/modules/ts/src/ts_perf.cpp b/modules/ts/src/ts_perf.cpp index 26076d01f..7e6e79d40 100644 --- a/modules/ts/src/ts_perf.cpp +++ b/modules/ts/src/ts_perf.cpp @@ -1,5 +1,9 @@ #include "precomp.hpp" +#if ANDROID +# include +#endif + using namespace perf; int64 TestBase::timeLimitDefault = 0; @@ -17,6 +21,7 @@ const char *command_line_keys = #if ANDROID "{ |perf_time_limit |6.0 |default time limit for a single test (in seconds)}" "{ |perf_affinity_mask |0 |set affinity mask for the main thread}" + "{ |perf_log_power_checkpoints |false |additional xml logging for power measurement}" #else "{ |perf_time_limit |3.0 |default time limit for a single test (in seconds)}" #endif @@ -34,6 +39,7 @@ static int param_tbb_nthreads; static bool param_write_sanity; #if ANDROID static int param_affinity_mask; +static bool log_power_checkpoints; #include #include @@ -515,6 +521,8 @@ performance_metrics::performance_metrics() /*****************************************************************************************\ * ::perf::TestBase \*****************************************************************************************/ + + void TestBase::Init(int argc, const char* const argv[]) { cv::CommandLineParser args(argc, argv, command_line_keys); @@ -525,10 +533,10 @@ void TestBase::Init(int argc, const char* const argv[]) param_time_limit = std::max(0., args.get("perf_time_limit")); param_force_samples = args.get("perf_force_samples"); param_write_sanity = args.get("perf_write_sanity"); - param_tbb_nthreads = args.get("perf_tbb_nthreads"); #if ANDROID param_affinity_mask = args.get("perf_affinity_mask"); + log_power_checkpoints = args.get("perf_log_power_checkpoints"); #endif if (args.get("help")) @@ -627,7 +635,19 @@ cv::Size TestBase::getSize(cv::InputArray a) bool TestBase::next() { - return ++currentIter < nIters && totalTime < timeLimit; + bool has_next = ++currentIter < nIters && totalTime < timeLimit; +#if ANDROID + if (log_power_checkpoints) + { + timeval tim; + gettimeofday(&tim, NULL); + unsigned long long t1 = tim.tv_sec * 1000LLU + (unsigned long long)(tim.tv_usec / 1000.f); + + if (currentIter == 1) RecordProperty("test_start", cv::format("%llu",t1).c_str()); + if (!has_next) RecordProperty("test_complete", cv::format("%llu",t1).c_str()); + } +#endif + return has_next; } void TestBase::warmup_impl(cv::Mat m, int wtype) @@ -999,7 +1019,7 @@ TestBase::_declareHelper& TestBase::_declareHelper::tbb_threads(int n) if (n > 0) test->p_tbb_initializer=new tbb::task_scheduler_init(n); #endif - (void)n; + (void)n; return *this; }