using application start time as one of the benchmark statistics key.

This commit is contained in:
rachytski 2011-04-27 23:52:05 +03:00 committed by Alex Zolotarev
parent c152581524
commit 179db664d0
5 changed files with 128 additions and 4 deletions

83
data/benchmark_stats.py Normal file
View file

@ -0,0 +1,83 @@
import math
import sys
f1 = open(sys.argv[2], "r")
lns1 = f1.readlines()
lns1 = [l.split(" ") for l in lns1]
bench_cfg = {}
for l in lns1:
c_name = l[0]
is_country = False
if c_name.find(".") <> -1:
is_country = True
bench_cfg[l[0]] = []
bench_cfg[l[0]].append(is_country)
if len(l) > 0:
if not is_country:
bench_cfg[c_name].append(float(l[1]))
bench_cfg[c_name].append(float(l[2]))
bench_cfg[c_name].append(float(l[3]))
bench_cfg[c_name].append(float(l[4]))
bench_cfg[c_name].append(int(l[5]))
else:
bench_cfg[c_name].append(int(l[1]))
f = open(sys.argv[1], "r")
lns = f.readlines()
def scale_level(r):
dx = 360.0 / (r[2] - r[0])
dy = 360.0 / (r[3] - r[1])
v = (dx + dy) / 2.0
l = math.log(v) / math.log(2.0) + 1
if l > 17:
l = 17
if l < 0:
return 0
else:
return math.floor(l + 0.5)
lns = [l.split(" ") for l in lns]
rev = {}
for l in lns:
rev_name = l[1]
start_time = l[2]
bench_name = l[3]
rect = [float(l[4]), float(l[5]), float(l[6]), float(l[7])]
dur = float(l[8])
if not rev.has_key(rev_name):
rev[rev_name] = {}
if not rev[rev_name].has_key(start_time):
rev[rev_name][start_time] = {}
if not rev[rev_name][start_time].has_key(bench_name):
rev[rev_name][start_time][bench_name] = {}
scale = scale_level(rect)
if not rev[rev_name][start_time][bench_name].has_key(scale):
rev[rev_name][start_time][bench_name][scale] = 0
rev[rev_name][start_time][bench_name][scale] += dur
for rev_name in rev.keys():
print rev_name
for start_time in rev[rev_name].keys():
print "\t", start_time
for bench_name in rev[rev_name][start_time].keys():
cfg_info = bench_cfg[bench_name]
if not cfg_info[0]:
print "\t\t", bench_name, "[", cfg_info[1], cfg_info[2], cfg_info[3], cfg_info[4], "]", "endScale=", cfg_info[5]
else:
print "\t\t", bench_name, "endScale=", cfg_info[1]
k = rev[rev_name][start_time][bench_name].keys()
k.sort()
for scale_level in k:
print "\t\t\t scale: ", scale_level, ", duration: " , rev[rev_name][start_time][bench_name][scale_level]

View file

@ -275,6 +275,7 @@ void FrameWork<TModel>::AddRedrawCommandSure()
m_centeringMode(EDoNothing),
m_maxDuration(0)
{
m_startTime = GetPlatform().TimeString();
m_informationDisplay.setBottomShift(bottomShift);
#ifdef DRAW_TOUCH_POINTS
m_informationDisplay.enableDebugPoints(true);
@ -334,15 +335,13 @@ void FrameWork<TModel>::AddRedrawCommandSure()
template <typename TModel>
void FrameWork<TModel>::SaveBenchmarkResults()
{
string deviceID = GetPlatform().DeviceID();
transform(deviceID.begin(), deviceID.end(), deviceID.begin(), ::tolower);
ofstream fout(GetPlatform().WritablePathForFile(deviceID + "_benchmark_results.txt").c_str(), ios::app);
ofstream fout(GetPlatform().WritablePathForFile("benchmark_results.txt").c_str(), ios::app);
for (int i = 0; i < m_benchmarkResults.size(); ++i)
{
fout << GetPlatform().DeviceID() << " "
<< VERSION_STRING << " "
<< m_startTime << " "
<< m_benchmarkResults[i].m_name << " "
<< m_benchmarkResults[i].m_rect.minX() << " "
<< m_benchmarkResults[i].m_rect.minY() << " "
@ -354,6 +353,16 @@ void FrameWork<TModel>::AddRedrawCommandSure()
m_benchmarkResults.clear();
}
template <typename TModel>
void FrameWork<TModel>::SendBenchmarkResults()
{
// ofstream fout(GetPlatform().WritablePathForFile("benchmark_results.txt").c_str(), ios::app);
// fout << "[COMPLETED]";
// fout.close();
/// send to server for adding to statistics graphics
/// and delete results file
}
template <typename TModel>
void FrameWork<TModel>::NextBenchmarkCommand()
{
@ -366,6 +375,7 @@ void FrameWork<TModel>::AddRedrawCommandSure()
else
{
SaveBenchmarkResults();
SendBenchmarkResults();
LOG(LINFO, ("Bechmarks took ", m_benchmarksTimer.ElapsedSeconds(), " seconds to complete"));
}
}

View file

@ -148,6 +148,7 @@ class FrameWork
vector<BenchmarkResult> m_benchmarkResults;
my::Timer m_benchmarksTimer;
string m_startTime;
struct Benchmark
{
@ -161,6 +162,7 @@ class FrameWork
void BenchmarkCommandFinished();
void NextBenchmarkCommand();
void SaveBenchmarkResults();
void SendBenchmarkResults();
void AddMap(string const & datFile);
void RemoveMap(string const & datFile);

View file

@ -18,6 +18,8 @@ public:
/// Time in seconds passed from application start
virtual double TimeInSec() const = 0;
virtual string TimeString() const = 0;
/// @return always the same writable dir for current user with slash at the end
virtual string WritableDir() const = 0;
/// @return full path to file in user's writable directory

View file

@ -414,6 +414,33 @@ public:
{
return 512 + 256;
}
string TimeString() const
{
time_t rawtime;
time(&rawtime);
tm * ltime;
ltime = localtime(&rawtime);
static char const * wday_name[7] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};
static char const * mon_name[12] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
static char result[26];
sprintf(result, "%s_%s_%d_%d:%d:%d_%d",
wday_name[ltime->tm_wday],
mon_name[ltime->tm_mon],
ltime->tm_mday, ltime->tm_hour,
ltime->tm_min, ltime->tm_sec,
1900 + ltime->tm_year);
return string(result);
}
};
extern "C" Platform & GetPlatform()