mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-20 23:50:27 +00:00
devmods:: rulegen-tests:: time measuring improvements (movecount and attempts)
This commit is contained in:
parent
1e2ffd611c
commit
1a74241cd9
@ -561,11 +561,38 @@ void test_current(string tesname) {
|
|||||||
println(hlog, "CSV; failed to convert ", tesname);
|
println(hlog, "CSV; failed to convert ", tesname);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(flags & w_known_structure) {
|
||||||
|
dynamicval<flagtype> f(rulegen::flags, sub_rulegen_flags);
|
||||||
|
prepare_rules();
|
||||||
|
alt_treestates = treestates;
|
||||||
|
pointer_indices.clear();
|
||||||
|
}
|
||||||
|
|
||||||
int tstart = SDL_GetTicks();
|
int tstart = SDL_GetTicks();
|
||||||
|
int attempts = 0;
|
||||||
|
double max_time = 0, avg_time = 0, variance_time = 0;
|
||||||
auto begin = clock(); // std::chrono::high_resolution_clock::now();
|
auto begin = clock(); // std::chrono::high_resolution_clock::now();
|
||||||
|
auto last = begin;
|
||||||
try {
|
try {
|
||||||
generate_rules();
|
while(!attempts) { // || (clock() < begin + 0.1 * CLOCKS_PER_SEC && attempts < 1000)) {
|
||||||
|
|
||||||
|
if(true) {
|
||||||
|
rulegen::delete_tmap();
|
||||||
|
rulegen::clear_all();
|
||||||
|
last = clock();
|
||||||
|
rulegen::movecount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_rules();
|
||||||
|
auto cur = clock();
|
||||||
|
double t = (cur - last) * 1. / CLOCKS_PER_SEC;
|
||||||
|
last = cur;
|
||||||
|
if(t > max_time) max_time = t;
|
||||||
|
avg_time += t;
|
||||||
|
variance_time += t * t;
|
||||||
|
attempts++;
|
||||||
|
}
|
||||||
status = "ACC";
|
status = "ACC";
|
||||||
message = "OK";
|
message = "OK";
|
||||||
ok = true;
|
ok = true;
|
||||||
@ -590,6 +617,20 @@ void test_current(string tesname) {
|
|||||||
status = "PRE";
|
status = "PRE";
|
||||||
message = e.what();
|
message = e.what();
|
||||||
}
|
}
|
||||||
|
if(!attempts) {
|
||||||
|
auto cur = clock();
|
||||||
|
double t = (cur - last) * 1. / CLOCKS_PER_SEC;
|
||||||
|
avg_time += t; variance_time += t*t; max_time = t;
|
||||||
|
attempts = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
avg_time /= attempts;
|
||||||
|
variance_time /= attempts;
|
||||||
|
variance_time -= avg_time * avg_time;
|
||||||
|
if(attempts > 1) {
|
||||||
|
variance_time *= attempts;
|
||||||
|
variance_time /= (attempts-1);
|
||||||
|
}
|
||||||
|
|
||||||
auto end = clock(); // std::chrono::high_resolution_clock::now();
|
auto end = clock(); // std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
@ -655,6 +696,10 @@ void test_current(string tesname) {
|
|||||||
case 'T': Out("T", tstart / 1000.);
|
case 'T': Out("T", tstart / 1000.);
|
||||||
// case 'P': Out("Tp", std::chrono::duration_cast<std::chrono::nanoseconds>(end-begin).count() / 1000000000.);
|
// case 'P': Out("Tp", std::chrono::duration_cast<std::chrono::nanoseconds>(end-begin).count() / 1000000000.);
|
||||||
case 'P': Out("Tp", (end-begin) * 1. / CLOCKS_PER_SEC);
|
case 'P': Out("Tp", (end-begin) * 1. / CLOCKS_PER_SEC);
|
||||||
|
case 'N': Out("attempts", attempts);
|
||||||
|
case 'M': Out("maxtime", max_time);
|
||||||
|
case 'E': Out("avgtime", avg_time);
|
||||||
|
case 'V': Out("vartime", variance_time);
|
||||||
case 'y': Out("tree", isize(treestates));
|
case 'y': Out("tree", isize(treestates));
|
||||||
case 'a': Out("amin;amax", lalign(0, areas[0], ";", areas.back()));
|
case 'a': Out("amin;amax", lalign(0, areas[0], ";", areas.back()));
|
||||||
case 'h': Out("shapes", isize(arb::current.shapes));
|
case 'h': Out("shapes", isize(arb::current.shapes));
|
||||||
|
12
rulegen.cpp
12
rulegen.cpp
@ -79,6 +79,8 @@ static const flagtype w_bfs = Flag(17); /*< compute distances using BFS */
|
|||||||
|
|
||||||
EX flagtype flags = 0;
|
EX flagtype flags = 0;
|
||||||
|
|
||||||
|
EX int64_t movecount;
|
||||||
|
|
||||||
#if HDR
|
#if HDR
|
||||||
struct tcell* tmove(tcell *c, int d);
|
struct tcell* tmove(tcell *c, int d);
|
||||||
|
|
||||||
@ -104,11 +106,11 @@ struct tcell {
|
|||||||
/** sometimes we find out that multiple tcells represent the same actual cell -- in this case we unify them; unified_to is used for the union-find algorithm */
|
/** sometimes we find out that multiple tcells represent the same actual cell -- in this case we unify them; unified_to is used for the union-find algorithm */
|
||||||
walker<tcell> unified_to;
|
walker<tcell> unified_to;
|
||||||
int degree() { return type; }
|
int degree() { return type; }
|
||||||
connection_table<tcell> c;
|
connection_table<tcell> c;
|
||||||
tcell*& move(int d) { return c.move(d); }
|
tcell*& move(int d) { movecount++; return c.move(d); }
|
||||||
tcell*& modmove(int d) { return c.modmove(d); }
|
tcell*& modmove(int d) { movecount++; return c.modmove(d); }
|
||||||
tcell* cmove(int d) { return tmove(this, d); }
|
tcell* cmove(int d) { movecount++; return tmove(this, d); }
|
||||||
tcell* cmodmove(int d) { return tmove(this, c.fix(d)); }
|
tcell* cmodmove(int d) { movecount++; return tmove(this, c.fix(d)); }
|
||||||
tcell() { }
|
tcell() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user