mirror of
https://github.com/opencv/opencv.git
synced 2024-12-02 16:00:17 +08:00
additional android logging for output gtest xml file
This commit is contained in:
parent
0ff5712d06
commit
cf02b2e258
@ -197,10 +197,15 @@ def getRunningProcessExePathByName(name):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
class RunInfo(object):
|
class RunInfo(object):
|
||||||
|
def setCallback(self, name, callback):
|
||||||
|
setattr(self, name, callback)
|
||||||
|
|
||||||
def __init__(self, path, options):
|
def __init__(self, path, options):
|
||||||
self.options = options
|
self.options = options
|
||||||
self.path = path
|
self.path = path
|
||||||
self.error = None
|
self.error = None
|
||||||
|
self.setUp = None
|
||||||
|
self.tearDown = None
|
||||||
self.nameprefix = "opencv_" + options.mode + "_"
|
self.nameprefix = "opencv_" + options.mode + "_"
|
||||||
for p in parse_patterns:
|
for p in parse_patterns:
|
||||||
setattr(self, p["name"], p["default"])
|
setattr(self, p["name"], p["default"])
|
||||||
@ -602,7 +607,11 @@ class RunInfo(object):
|
|||||||
else:
|
else:
|
||||||
command = exename + " " + " ".join(args)
|
command = exename + " " + " ".join(args)
|
||||||
print >> _stderr, "Running:", command
|
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()
|
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
|
# try get log
|
||||||
if not self.options.help:
|
if not self.options.help:
|
||||||
print >> _stderr, "Pulling", logfile, "from device..."
|
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)
|
print >> _stderr, "Error: Test \"%s\" is not found in %s" % (test, self.tests_dir)
|
||||||
return logs
|
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__":
|
if __name__ == "__main__":
|
||||||
test_args = [a for a in sys.argv if a.startswith("--perf_") or a.startswith("--gtest_")]
|
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_"))]
|
argv = [a for a in sys.argv if not(a.startswith("--perf_") or a.startswith("--gtest_"))]
|
||||||
|
|
||||||
parser = OptionParser()
|
parser = OptionParser()
|
||||||
parser.add_option("-t", "--tests", dest="tests", help="comma-separated list of modules to test", metavar="SUITS", default="")
|
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("-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("-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)
|
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:
|
else:
|
||||||
options.mode = "perf"
|
options.mode = "perf"
|
||||||
|
|
||||||
run_args = []
|
run_args = getRunArgs(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
|
|
||||||
|
|
||||||
if len(run_args) == 0:
|
if len(run_args) == 0:
|
||||||
print >> sys.stderr, "Usage:\n", os.path.basename(sys.argv[0]), "<build_path>"
|
print >> sys.stderr, "Usage:\n", os.path.basename(sys.argv[0]), "<build_path>"
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
|
|
||||||
|
#if ANDROID
|
||||||
|
# include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace perf;
|
using namespace perf;
|
||||||
|
|
||||||
int64 TestBase::timeLimitDefault = 0;
|
int64 TestBase::timeLimitDefault = 0;
|
||||||
@ -17,6 +21,7 @@ const char *command_line_keys =
|
|||||||
#if ANDROID
|
#if ANDROID
|
||||||
"{ |perf_time_limit |6.0 |default time limit for a single test (in seconds)}"
|
"{ |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_affinity_mask |0 |set affinity mask for the main thread}"
|
||||||
|
"{ |perf_log_power_checkpoints |false |additional xml logging for power measurement}"
|
||||||
#else
|
#else
|
||||||
"{ |perf_time_limit |3.0 |default time limit for a single test (in seconds)}"
|
"{ |perf_time_limit |3.0 |default time limit for a single test (in seconds)}"
|
||||||
#endif
|
#endif
|
||||||
@ -34,6 +39,7 @@ static int param_tbb_nthreads;
|
|||||||
static bool param_write_sanity;
|
static bool param_write_sanity;
|
||||||
#if ANDROID
|
#if ANDROID
|
||||||
static int param_affinity_mask;
|
static int param_affinity_mask;
|
||||||
|
static bool log_power_checkpoints;
|
||||||
|
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
@ -515,6 +521,8 @@ performance_metrics::performance_metrics()
|
|||||||
/*****************************************************************************************\
|
/*****************************************************************************************\
|
||||||
* ::perf::TestBase
|
* ::perf::TestBase
|
||||||
\*****************************************************************************************/
|
\*****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
void TestBase::Init(int argc, const char* const argv[])
|
void TestBase::Init(int argc, const char* const argv[])
|
||||||
{
|
{
|
||||||
cv::CommandLineParser args(argc, argv, command_line_keys);
|
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_time_limit = std::max(0., args.get<double>("perf_time_limit"));
|
||||||
param_force_samples = args.get<unsigned int>("perf_force_samples");
|
param_force_samples = args.get<unsigned int>("perf_force_samples");
|
||||||
param_write_sanity = args.get<bool>("perf_write_sanity");
|
param_write_sanity = args.get<bool>("perf_write_sanity");
|
||||||
|
|
||||||
param_tbb_nthreads = args.get<int>("perf_tbb_nthreads");
|
param_tbb_nthreads = args.get<int>("perf_tbb_nthreads");
|
||||||
#if ANDROID
|
#if ANDROID
|
||||||
param_affinity_mask = args.get<int>("perf_affinity_mask");
|
param_affinity_mask = args.get<int>("perf_affinity_mask");
|
||||||
|
log_power_checkpoints = args.get<bool>("perf_log_power_checkpoints");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (args.get<bool>("help"))
|
if (args.get<bool>("help"))
|
||||||
@ -627,7 +635,19 @@ cv::Size TestBase::getSize(cv::InputArray a)
|
|||||||
|
|
||||||
bool TestBase::next()
|
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)
|
void TestBase::warmup_impl(cv::Mat m, int wtype)
|
||||||
|
Loading…
Reference in New Issue
Block a user