void check_switch() { time_t now; now = time(NULL); if(now >= (start + 5)) { start = time(NULL); printf(" Average Frame Rate: ~%f fps (%d pps)\n", avgfps, (int)(polycnt * avgfps)); switch(phase) { case PHASE_HALVE: if(avgfps < 55) { switch_tests(polycnt / 2); } else { printf(" Entering PHASE_INCR\n"); phase = PHASE_INCR; } break; case PHASE_INCR: if(avgfps >= 55) { switch_tests(polycnt + 500); } else { printf(" Entering PHASE_DECR\n"); phase = PHASE_DECR; } break; case PHASE_DECR: if(avgfps < 55) { switch_tests(polycnt - 200); } else { printf(" Entering PHASE_FINAL\n"); phase = PHASE_FINAL; } break; case PHASE_FINAL: break; } } }
int main(int argc, char **argv) { setup(); /* Start off with something obscene */ switch_tests(220000 / 60); start = time(NULL); for(;;) { if (check_start()) break; printf(" \r"); do_frame(); running_stats(); check_switch(); } stats(); return 0; }