From b4b07c2cacc997b24860cf8cb3805195d000e754 Mon Sep 17 00:00:00 2001 From: Tamas TEVESZ Date: Thu, 23 Sep 2010 01:27:53 +0200 Subject: [PATCH] Kill BENCH Nice idea, x86 assembly is so 1980s. tests/testgrad.c could probably have been saved, but seriously, who's going to miss it? Signed-off-by: Tamas TEVESZ --- wrlib/bench.h | 68 -------------------------------------------------- wrlib/context.c | 2 -- wrlib/convert.c | 24 ------------------ wrlib/tests/testgrad.c | 56 ----------------------------------------- 4 files changed, 150 deletions(-) delete mode 100644 wrlib/bench.h diff --git a/wrlib/bench.h b/wrlib/bench.h deleted file mode 100644 index e7dba0c4..00000000 --- a/wrlib/bench.h +++ /dev/null @@ -1,68 +0,0 @@ - - - -inline static void -cycle_bench(int start) -{ - static volatile unsigned int start_cycle; - - if (start) { - asm volatile - ("pushl %%edx \n\t" - "rdtsc \n\t" - "movl %%eax,%0 \n\t" - "cld \n\t" - "popl %%edx \n\t" - "nop \n\t" - "nop \n\t" - "nop \n\t" - "nop \n\t" - "nop \n\t" - "nop \n\t" - "nop \n\t" - "nop \n\t" - : "=m" (start_cycle) : : "eax", "edx"); - } else { - volatile int end; - - asm volatile - ("pushl %%edx \n\t" - "clc \n\t" - "rdtsc \n\t" - "movl %%eax, %0 \n\t" - "popl %%edx \n\t" - : "=m" (end) : : "eax", "edx"); - - printf("Cycle count = %u\n", end - start_cycle - 68); - } -} - - - -#if 0 -// seems linux doesnt allow user progs to exec rdpmc -inline static void -cache_bench(int start) -{ - static int start_cycle; - - if (start) { - asm volatile - ("movl $1,%%ecx \n\t" - "rdpmc \n\t" - "movl %%eax,%0 \n\t" - : "=m" (start_cycle)); - } else { - int end; - - asm volatile - ("movl $1,%%ecx \n\t" - "rdpmc \n\t" - "movl %%eax,%0" - : "=m" (end)); - - printf("Cache reloads counted = %i\n", end - start_cycle); - } -} - -#endif diff --git a/wrlib/context.c b/wrlib/context.c index 6c61e2ca..fd484c73 100644 --- a/wrlib/context.c +++ b/wrlib/context.c @@ -595,9 +595,7 @@ RContext *RCreateContext(Display * dpy, int screen_number, RContextAttributes * /* get configuration from environment variables */ gatherconfig(context, screen_number); -#ifndef BENCH _wraster_change_filter(context->attribs->scaling_filter); -#endif if ((context->attribs->flags & RC_VisualID)) { XVisualInfo *vinfo, templ; int nret; diff --git a/wrlib/convert.c b/wrlib/convert.c index 4b15cc55..3f045569 100644 --- a/wrlib/convert.c +++ b/wrlib/convert.c @@ -34,10 +34,6 @@ #include -#ifdef BENCH -#include "bench.h" -#endif - #include "wraster.h" #ifdef XSHM @@ -324,10 +320,6 @@ static RXImage *image2TrueColor(RContext * ctx, RImage * image) return NULL; } -#ifdef BENCH - cycle_bench(1); -#endif - if (ctx->attribs->render_mode == RBestMatchRendering) { int ofs, r, g, b; int x, y; @@ -424,10 +416,6 @@ static RXImage *image2TrueColor(RContext * ctx, RImage * image) } -#ifdef BENCH - cycle_bench(0); -#endif - return ximg; } @@ -900,27 +888,15 @@ int RConvertImage(RContext * context, RImage * image, Pixmap * pixmap) switch (context->vclass) { case TrueColor: -#ifdef BENCH - cycle_bench(1); -#endif ximg = image2TrueColor(context, image); -#ifdef BENCH - cycle_bench(0); -#endif break; case PseudoColor: case StaticColor: -#ifdef BENCH - cycle_bench(1); -#endif if (context->attribs->standard_colormap_mode != RIgnoreStdColormap) ximg = image2StandardPseudoColor(context, image); else ximg = image2PseudoColor(context, image); -#ifdef BENCH - cycle_bench(0); -#endif break; case GrayScale: diff --git a/wrlib/tests/testgrad.c b/wrlib/tests/testgrad.c index 1f43f2cd..b4a32570 100644 --- a/wrlib/tests/testgrad.c +++ b/wrlib/tests/testgrad.c @@ -4,10 +4,6 @@ #include #include #include -#ifdef BENCH -#include -#include -#endif Display *dpy; Window win; @@ -26,9 +22,6 @@ void print_help() puts(" -v visual id to use"); } -#ifdef BENCH -#include "bench.h" -#endif int main(int argc, char **argv) { RContextAttributes attr; @@ -38,10 +31,6 @@ int main(int argc, char **argv) XColor color; XSetWindowAttributes val; int visualID = -1; -#ifdef BENCH - double t1, t2, total, t, rt; - struct timeval timev; -#endif ProgName = strrchr(argv[0], '/'); if (!ProgName) @@ -135,56 +124,12 @@ int main(int argc, char **argv) val.background_pixel = ctx->black; val.colormap = ctx->cmap; val.backing_store = Always; -#ifdef BENCH - win = XCreateWindow(dpy, DefaultRootWindow(dpy), 10, 10, 250, 250, - 0, ctx->depth, InputOutput, ctx->visual, - CWColormap | CWBackPixel | CWBackingStore, &val); -#else win = XCreateWindow(dpy, DefaultRootWindow(dpy), 10, 10, 750, 250, 0, ctx->depth, InputOutput, ctx->visual, CWColormap | CWBackPixel | CWBackingStore, &val); -#endif XMapRaised(dpy, win); XFlush(dpy); -#ifdef BENCH - rt = 0; - gettimeofday(&timev, NULL); - t = (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000); - for (i = 0; i < 9; i++) { - if (i > 0) - printf("\nrepeating...\n\n"); - gettimeofday(&timev, NULL); - t1 = (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000); - if (i % 3 == 0) - imgh = RRenderMultiGradient(550, 550, colors, RGRD_HORIZONTAL); - else if (i % 3 == 1) - imgh = RRenderMultiGradient(550, 550, colors, RGRD_VERTICAL); - else - imgh = RRenderMultiGradient(550, 550, colors, RGRD_DIAGONAL); - - gettimeofday(&timev, NULL); - t2 = (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000); - total = t2 - t1; - printf("gradient rendered in %f sec\n", total); - - RConvertImage(ctx, imgh, &pix); - gettimeofday(&timev, NULL); - t1 = (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000); - total = t1 - t2; - rt += total; - printf("image converted in %f sec\n", total); - - XCopyArea(dpy, pix, win, ctx->copy_gc, 0, 0, 250, 250, 0, 0); - - XFlush(dpy); - } - t1 = (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000); - printf("------------------------------------------\n"); - printf("%i images processed in %f sec\n", i, t1 - t); - printf("average time per convertion %f sec\n", rt / i); - printf("------------------------------------------\n"); -#else imgh = RRenderMultiGradient(250, 250, colors, RGRD_HORIZONTAL); imgv = RRenderMultiGradient(250, 250, colors, RGRD_VERTICAL); imgd = RRenderMultiGradient(250, 250, colors, RGRD_DIAGONAL); @@ -198,7 +143,6 @@ int main(int argc, char **argv) XCopyArea(dpy, pix, win, ctx->copy_gc, 0, 0, 250, 250, 500, 0); XFlush(dpy); -#endif getchar(); return 0; -- 2.11.4.GIT