Пример #1
0
void
speed_test (fractal_context * c, struct image *img)
{
    //unsigned int sum;
    tl_timer *t;
    int time;
    unsigned int i;
    set_fractalc (c, img);
    t = tl_create_timer ();
    cfractalc.maxiter = 100;
#ifdef SLOWFUNCPTR
    i = calculateswitch (0.0, 0.0, 0.0, 0.0, 0);
#else
    (void) cfractalc.currentformula->calculate (0.0, 0.0, 0.0, 0.0);
    if (cfractalc.currentformula->calculate_periodicity != NULL)
        (void) cfractalc.currentformula->calculate_periodicity (0.0, 0.0, 0.0, 0.0);
    if (cfractalc.currentformula->smooth_calculate != NULL)
        (void) cfractalc.currentformula->smooth_calculate (0.0, 0.0, 0.0, 0.0);
    if (cfractalc.currentformula->smooth_calculate_periodicity != NULL)
        (void) cfractalc.currentformula->smooth_calculate_periodicity (0.0, 0.0, 0.0, 0.0);
#endif
    cfractalc.maxiter = 20000000;

    tl_update_time ();
    tl_reset_timer (t);
    /*sum = rdtsc (); */
#ifdef SLOWFUNCPTR
    i = calculateswitch (0.0, 0.0, 0.0, 0.0, 0);
#else
    i = cfractalc.currentformula->calculate (0.0, 0.0, 0.0, 0.0);
#endif
    /*sum -= rdtsc ();
       printf ("%f\n", (double) (-sum) / cfractalc.maxiter); */
    tl_update_time ();
    time = tl_lookup_timer (t);
    x_message ("Result:%i Formulaname:%s Time:%i Mloops per sec:%.2f", (int) i, cfractalc.currentformula->name[0], time, cfractalc.maxiter / (double) time);

#ifndef SLOWFUNCPTR


    if (cfractalc.currentformula->smooth_calculate != NULL) {
        tl_update_time ();
        tl_reset_timer (t);
        i = cfractalc.currentformula->smooth_calculate (0.0, 0.0, 0.0, 0.0);
        tl_update_time ();
        time = tl_lookup_timer (t);
        x_message ("Result:%i Formulaname:%s Time:%i Mloops per sec:%.2f", (int) i, cfractalc.currentformula->name[0], time, cfractalc.maxiter / (double) time);
    }
#endif

    tl_free_timer (t);
}
Пример #2
0
int tl_process_group(tl_group * group)
{
    int again = 1;
    tl_timer *timer;
    int minwait = INT_MAX;
    tl_update_time();
    while (again) {
	again = 0;
	minwait = INT_MAX;
	timer = group->next;
	while (timer != NULL) {
	    if (timer->handler && timer->interval > 0) {
		int time = timer->wait - tl_lookup_timer(timer);
		if (time < 500) {
		    again = 1;
		    tl_reset_timer(timer);
		    if (time < -200 * 1000000)
			time = 0;	/*underflow? */
		    timer->wait = timer->interval + time;
		    time = timer->wait;
		    timer->handler();
		    tl_update_time();
		}
		if (time < minwait)
		    minwait = time;
	    }
	    else if (timer->multihandler && timer->interval > 0) {
		int time = timer->wait - tl_lookup_timer(timer);
		if (time < 500) {
		    int n;
		    tl_reset_timer(timer);
		    if (time < -200 * 1000000)
			time = 0;	/*underflow? */
		    n = -(time + 500) / timer->interval + 1;
		    timer->wait = timer->interval * n + time;
		    time = timer->wait;
		    timer->multihandler(n);
		    tl_update_time();
		}
		if (time < minwait)
		    minwait = time;
	    }
	    timer = timer->next;
	}
    }
    if (minwait != INT_MAX) {
	if (minwait < 0)
	    return (0);
	return (minwait);
    }
    return (-1);
}
Пример #3
0
Файл: bb.c Проект: stroucki/bb
int bbupdate()
{
    int ch;
    tl_update_time();
    update_sound();
    TIME = tl_lookup_timer(scenetimer);
    ch = aa_getkey(context, 0);
    switch (ch) {
    case 's':
    case 'S':
    case AA_BACKSPACE:
	finish_stuff = 1;
	break;
    case AA_ESC:
    case 'q':
	finish_stuff = 1, quitnow = 1;
    }
    return (ch);
}
Пример #4
0
int tl_process_group(tl_group * group, int *activated)
{
    int again = 1;
    tl_timer *timer, *timer1;
    int minwait = INT_MAX;
    tl_update_time();
    if (activated != NULL)
	*activated = 0;
    while (again) {
	group->slowdown = 0;
	again = 0;
	minwait = INT_MAX;
	timer = group->next;
	while (timer != NULL) {
	    timer1 = timer->next;
	    if (timer->handler && timer->interval >= 0) {
		int time = timer->interval - tl_lookup_timer(timer);
		if (time < 500) {
		    if (activated != NULL)
			(*activated)++;
		    again = 1;
		    tl_reset_timer(timer);
		    if (time < -200 * 1000000)
			time = 0;	/*underflow? */
		    tl_slowdown_timer(timer, time);
		    time = timer->interval + time;
		    timer->handler(timer->userdata);
		    tl_update_time();
		}
		if (time < minwait)
		    minwait = time;
	    } else if (timer->multihandler && timer->interval > 0) {
		int time = timer->interval - tl_lookup_timer(timer);
		if (time < 500) {
		    int n;
		    if (activated != NULL)
			(*activated)++;
		    tl_reset_timer(timer);
		    if (time < -200 * 1000000)
			time = 0;	/*underflow? */
		    n = -(time + 500) / timer->interval + 1;
		    time = timer->interval * n + time;
		    tl_slowdown_timer(timer,
				      time - timer->interval +
				      n * timer->interval);
		    timer->multihandler(timer->userdata, n);
		    tl_update_time();
		}
		if (time < minwait)
		    minwait = time;
	    }
	    if (group->slowdown) {
		again = 1;
		break;
	    }
	    timer = timer1;
	}
    }
    if (minwait != INT_MAX) {
	if (minwait < 0)
	    return (0);
	return (minwait);
    }
    return (-1);
}
Пример #5
0
void tl_reset_timer(tl_timer * t)
{
    tl_update_time();
    t->lastactivated = currenttime;
}