Ejemplo n.º 1
0
static void
clist_render_thread(void *data)
{
    clist_render_thread_control_t *thread = (clist_render_thread_control_t *)data;
    gx_device *dev = thread->cdev;
    gx_device_clist *cldev = (gx_device_clist *)dev;
    gx_device_clist_reader *crdev = &cldev->reader;
    gx_device *bdev = thread->bdev;
    gs_int_rect band_rect;
    byte *mdata = crdev->data + crdev->page_tile_cache_size;
    uint raster = bitmap_raster(dev->width * dev->color_info.depth);
    int code;
    int band_height = crdev->page_band_height;
    int band = thread->band;
    int band_begin_line = band * band_height;
    int band_end_line = band_begin_line + band_height;
    int band_num_lines;
#ifdef DEBUG
    long starttime[2], endtime[2];

    gp_get_usertime(starttime);	/* thread start time */
#endif
    if (band_end_line > dev->height)
	band_end_line = dev->height;
    band_num_lines = band_end_line - band_begin_line;

    code = crdev->buf_procs.setup_buf_device
	    (bdev, mdata, raster, NULL, 0, band_num_lines, band_num_lines);
    band_rect.p.x = 0;
    band_rect.p.y = band_begin_line;
    band_rect.q.x = dev->width;
    band_rect.q.y = band_end_line;
    if (code >= 0)
	code = clist_render_rectangle(cldev, &band_rect, bdev, NULL, true);
    /* Reset the band boundaries now */
    crdev->ymin = band_begin_line;
    crdev->ymax = band_end_line;
    crdev->offset_map = NULL;
    if (code < 0)
	thread->status = code;		/* shouldn't happen */
    else
	thread->status = RENDER_THREAD_DONE;	/* OK */

#ifdef DEBUG
    gp_get_usertime(endtime);
    thread->cputime += (endtime[0] - starttime[0]) * 1000 +
	     (endtime[1] - starttime[1]) / 1000000;
#endif
    /*
     * Signal the semaphores. We signal the 'group' first since even if
     * the waiter is released on the group, it still needs to check
     * status on the thread
     */
    gx_semaphore_signal(thread->sema_group);
    gx_semaphore_signal(thread->sema_this);
}
Ejemplo n.º 2
0
int
main(int argc, const char *argv[])
{
    int i;
    int *mem = malloc(1100000);

    capture_stdio();
    for (i = 0;; ++i) {
	int32_t t0[2], t1[2];
	char *msg;
	int n;

	gp_get_usertime(t0);
	switch (i) {
	    case 0:
		iadd(0, n = 10000000, &msg);
		break;
	    case 1:
		imul(1, n = 1000000, &msg);
		break;
	    case 2:
		idiv(1, n = 1000000, &msg);
		break;
	    case 3:
		fadd(3.14, n = 10000000, &msg);
		break;
	    case 4:
		fmul(1.0000001, n = 10000000, &msg);
		break;
	    case 5:
		fdiv(1.0000001, n = 1000000, &msg);
		break;
	    case 6:
		fconv(12345, n = 10000000, &msg);
		break;
	    case 7:
		mfast(mem, n = 10000000, &msg);
		break;
	    case 8:
		mslow(mem, n = 1000000, &msg);
		break;
	    default:
		free(mem);
		exit(0);
	}
	gp_get_usertime(t1);
	fprintf(stdout, "Time for %9d %s = %g ms\n", n, msg,
		(t1[0] - t0[0]) * 1000.0 + (t1[1] - t0[1]) / 1000000.0);
	fflush(stdout);
    }
}
Ejemplo n.º 3
0
Archivo: zmisc.c Proyecto: hackqiang/gs
/* - usertime <int> */
static int
zusertime(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;
    long secs_ns[2];

    gp_get_usertime(secs_ns);
    push(1);
    make_int(op, secs_ns[0] * 1000 + secs_ns[1] / 1000000);
    return 0;
}