additional android logging for output gtest xml file

This commit is contained in:
Marina Kolpakova 2012-04-07 12:51:59 +00:00
parent 0ff5712d06
commit cf02b2e258
3 changed files with 49 additions and 16 deletions

View File

@ -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 <bool expr> struct StaticAssert;
template <> struct StaticAssert<true> {static __CV_GPU_HOST_DEVICE__ void check(){}};
template <> struct StaticAssert<true> {static __CV_GPU_HOST_DEVICE__ void check(){}};
template<typename T> struct DevPtr
{

View File

@ -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]), "<build_path>"

View File

@ -1,5 +1,9 @@
#include "precomp.hpp"
#if ANDROID
# include <sys/time.h>
#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 <sys/syscall.h>
#include <pthread.h>
@ -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<double>("perf_time_limit"));
param_force_samples = args.get<unsigned int>("perf_force_samples");
param_write_sanity = args.get<bool>("perf_write_sanity");
param_tbb_nthreads = args.get<int>("perf_tbb_nthreads");
#if ANDROID
param_affinity_mask = args.get<int>("perf_affinity_mask");
log_power_checkpoints = args.get<bool>("perf_log_power_checkpoints");
#endif
if (args.get<bool>("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;
}