void keyboardthread(void *) { Rune r; Timer *timer; Text *t; enum { KTimer, KKey, NKALT }; static Alt alts[NKALT+1]; alts[KTimer].c = nil; alts[KTimer].v = nil; alts[KTimer].op = CHANNOP; alts[KKey].c = keyboardctl->c; alts[KKey].v = &r; alts[KKey].op = CHANRCV; alts[NKALT].op = CHANEND; timer = nil; typetext = nil; threadsetname("keyboardthread"); for(;;){ switch(alt(alts)){ case KTimer: timerstop(timer); t = typetext; if(t!=nil && t->what==Tag){ winlock(t->w, 'K'); wincommit(t->w, t); winunlock(t->w); flushimage(display, 1); } alts[KTimer].c = nil; alts[KTimer].op = CHANNOP; break; case KKey: casekeyboard: typetext = rowtype(&row, r, mouse->xy); t = typetext; if(t!=nil && t->col!=nil && !(r==Kdown || r==Kleft || r==Kright)) /* scrolling doesn't change activecol */ activecol = t->col; if(t!=nil && t->w!=nil) t->w->body.file->curtext = &t->w->body; if(timer != nil) timercancel(timer); if(t!=nil && t->what==Tag) { timer = timerstart(500); alts[KTimer].c = timer->c; alts[KTimer].op = CHANRCV; }else{ timer = nil; alts[KTimer].c = nil; alts[KTimer].op = CHANNOP; } if(nbrecv(keyboardctl->c, &r) > 0) goto casekeyboard; flushimage(display, 1); break; } } }
void benchrenderpage(fz_context *ctx, pdf_document *xref, pdf_page *page, int pagenum) { fz_device *dev; fz_pixmap *pix; fz_bbox bbox; mstimer timer; timerstart(&timer); bbox = fz_round_rect(pdf_bound_page(xref, page)); pix = fz_new_pixmap_with_bbox(ctx, fz_device_rgb, bbox); fz_clear_pixmap_with_value(ctx, pix, 0xFF); dev = fz_new_draw_device(ctx, pix); fz_try(ctx) { pdf_run_page(xref, page, dev, fz_identity, NULL); timerstop(&timer); logbench("pagerender %3d: %.2f ms\n", pagenum, timeinms(&timer)); } fz_catch(ctx) { logbench("Error: pdf_run_page() failed\n"); } fz_drop_pixmap(ctx, pix); fz_free_device(dev); }
void ponycountdownplasma::update() { m_label_season->setText(i18n("Season №%1", info("season"))); m_label_name->setText(i18n("Episode Name: %1", info("name"))); m_label_ep->setText(i18n("Episode №%1", info("episode"))); timerstart(); }
void rt_finalize(void) { timerstart(); if(global_usegraphics) do { rt_sleep(10); timerstop(); } while(timertime() < 10 && video->next_frame()); #ifdef _WINDOWS else rt_sleep(10000); #endif }
void keyboardthread(void *) { Timer *timer; Text *t; Rune r; static Alt alts[NKALT+1]; alts[KTimer].c = nil; alts[KTimer].v = nil; alts[KTimer].op = CHANNOP; alts[KKey].c = keyboardctl->c; alts[KKey].v = &r; alts[KKey].op = CHANRCV; alts[NKALT].op = CHANEND; timer = nil; threadsetname("keyboardthread"); for(;;){ switch(alt(alts)){ case KTimer: timerstop(timer); alts[KTimer].c = nil; alts[KTimer].op = CHANNOP; break; case KKey: casekeyboard: typetext = rowwhich(&row, mouse->xy, r, TRUE); t = typetext; if(t!=nil && t->col!=nil && !(r==Kdown || r==Kleft || r==Kright)) /* scrolling doesn't change activecol */ activecol = t->col; if(timer != nil) timercancel(timer); if(t!=nil){ texttype(t, r); timer = timerstart(500); alts[KTimer].c = timer->c; alts[KTimer].op = CHANRCV; }else{ timer = nil; alts[KTimer].c = nil; alts[KTimer].op = CHANNOP; } if(nbrecv(keyboardctl->c, &r) > 0) goto casekeyboard; flushimage(display, 1); break; } } }
main_module::main_module(potoc_sun &sun_p, drain_parametrs_solar_battery &drain_p,drain_position_salleter & position) { position_salleter_potoc=&position; sun_potoc=&sun_p; drain=&drain_p; QObject::connect(this,SIGNAL(stop_sun_signal()),sun_potoc,SLOT(timerstop())); QObject::connect(this,SIGNAL(start_sun_signal()),sun_potoc,SLOT(timerstart())); QObject::connect(this,SIGNAL(qdebug_sun_signal(bool)),sun_potoc,SLOT(debug(bool))); QObject::connect(this,SIGNAL(replay_sun_signal(int)),sun_potoc,SLOT(upreplay(int))); qdebug=setting_f.Get_qdebug_main_modul(); }
// Host code int* abstract_vectorAdd(int* A,int* B,int* C,int TOTAL_SIZE) { timerstart("MPI"); int rank, size; MPI_Init (&argc, &argv); /* starts MPI */ MPI_Comm_rank (MPI_COMM_WORLD, &rank); /* get current process id */ MPI_Comm_size (MPI_COMM_WORLD, &size); /* get number of processes */ /********************* Implementation goes here **********************/ MPI_Finalize(); timerstart("MPI"); return C; }
void on_process() { char buf[128]; flt runtime; timerstart(); rt_renderscene(global_scene); timerstop(); runtime=timertime(); sprintf(buf, "\nCPU Time: %.3f seconds.", runtime); rt_ui_message(MSG_0, buf); buf[0] = ' '; strcat(global_window_title, buf); title = global_window_title; updating = true; show_title(); rt_finalize(); }
void plumbthread(void *v) { CFid *fid; Plumbmsg *m; Timer *t; USED(v); threadsetname("plumbproc"); /* * Loop so that if plumber is restarted, acme need not be. */ for(;;){ /* * Connect to plumber. */ plumbunmount(); while((fid = plumbopenfid("edit", OREAD|OCEXEC)) == nil){ t = timerstart(2000); recv(t->c, nil); timerstop(t); } plumbeditfid = fid; plumbsendfid = plumbopenfid("send", OWRITE|OCEXEC); /* * Relay messages. */ for(;;){ m = plumbrecvfid(plumbeditfid); if(m == nil) break; sendp(cplumb, m); } /* * Lost connection. */ fid = plumbsendfid; plumbsendfid = nil; fsclose(fid); fid = plumbeditfid; plumbeditfid = nil; fsclose(fid); } }
void benchfile(char *pdffilename, int loadonly, int pageNo) { pdf_document *xref = NULL; mstimer timer; int page_count; int curpage; fz_context *ctx = fz_new_context(NULL, NULL, FZ_STORE_DEFAULT); if (!ctx) { logbench("Error: fz_new_context() failed\n"); return; } logbench("Starting: %s\n", pdffilename); timerstart(&timer); fz_var(xref); fz_try(ctx) { xref = openxref(ctx, pdffilename); } fz_catch(ctx) { goto Exit; } timerstop(&timer); logbench("load: %.2f ms\n", timeinms(&timer)); page_count = pdf_count_pages(xref); logbench("page count: %d\n", page_count); if (loadonly) goto Exit; for (curpage = 1; curpage <= page_count; curpage++) { pdf_page *page; if ((-1 != pageNo) && (pageNo != curpage)) continue; page = benchloadpage(ctx, xref, curpage); if (page) { benchrenderpage(ctx, xref, page, curpage); pdf_free_page(xref, page); } } Exit: logbench("Finished: %s\n", pdffilename); pdf_close_document(xref); fz_free_context(ctx); }
pdf_page *benchloadpage(fz_context *ctx, pdf_document *xref, int pagenum) { pdf_page *page = NULL; mstimer timer; timerstart(&timer); fz_try(ctx) { page = pdf_load_page(xref, pagenum - 1); } fz_catch(ctx) { logbench("Error: failed to load page %d\n", pagenum); return NULL; } timerstop(&timer); logbench("pageload %3d: %.2f ms\n", pagenum, timeinms(&timer)); return page; }
void testgeoipcountry(int flags, const char *msg, int numlookups) { const char *str = NULL; double t = 0; int i4 = 0; int i2 = 0; GeoIP *i = NULL; i = GeoIP_open("/usr/local/share/GeoIP/GeoIP.dat", flags); if (i == NULL) { printf("error: GeoIP.dat does not exist\n"); return; } timerstart(); for (i2 = 0; i2 < numlookups; i2++) { str = GeoIP_country_name_by_addr(i, ipstring[i4]); i4 = (i4 + 1) % numipstrings; } t = timerstop(); printf("%s\n", msg); printf("%d lookups made in %f seconds \n", numlookups, t); GeoIP_delete(i); }
void renderscene(scenedef scene) { //char msgtxt[2048]; //void * outfile; /* Grid based accerlation scheme */ if (scene.boundmode == RT_BOUNDING_ENABLED) engrid_scene(&rootobj); /* grid */ /* Not used now if (scene.verbosemode) { sprintf(msgtxt, "Opening %s for output.", scene.outfilename); rt_ui_message(MSG_0, msgtxt); } createtgafile(scene.outfilename, (unsigned short) scene.hres, (unsigned short) scene.vres); outfile = opentgafile(scene.outfilename); */ timerstart(); trace_region (scene, 0/*outfile*/, 0, 0, scene.hres, scene.vres); //fclose((FILE *)outfile); } /* end of renderscene() */
int main(int argc, char *argv[]) { if(argc==1) usage(argv[0]); LibRaw RawProcessor; int i,arg,c,ret; char opm,opt,*cp,*sp; int use_bigfile=0, use_timing=0,use_mem=0; #ifndef WIN32 int msize = 0,use_mmap=0; #endif void *iobuffer=0; #ifdef OUT #undef OUT #endif #define OUT RawProcessor.imgdata.params argv[argc] = (char*)""; for (arg=1; (((opm = argv[arg][0]) - 2) | 2) == '+'; ) { char *optstr = argv[arg]; opt = argv[arg++][1]; if ((cp = strchr (sp=(char*)"cnbrkStqmHABCgU", opt))!=0) for (i=0; i < "111411111144221"[cp-sp]-'0'; i++) if (!isdigit(argv[arg+i][0]) && !optstr[2]) { fprintf (stderr,"Non-numeric argument to \"-%c\"\n", opt); return 1; } if(!strchr("ftdeam",opt) && argv[arg-1][2]) fprintf (stderr,"Unknown option \"%s\".\n",argv[arg-1]); switch (opt) { case 'v': verbosity++; break; case 'G': OUT.green_matching = 1; break; case 'c': OUT.adjust_maximum_thr = (float)atof(argv[arg++]); break; case 'U': OUT.auto_bright_thr = (float)atof(argv[arg++]); break; case 'n': OUT.threshold = (float)atof(argv[arg++]); break; case 'b': OUT.bright = (float)atof(argv[arg++]); break; case 'P': OUT.bad_pixels = argv[arg++]; break; case 'K': OUT.dark_frame = argv[arg++]; break; case 'r': for(c=0;c<4;c++) OUT.user_mul[c] = (float)atof(argv[arg++]); break; case 'C': OUT.aber[0] = 1 / atof(argv[arg++]); OUT.aber[2] = 1 / atof(argv[arg++]); break; case 'g': OUT.gamm[0] = 1 / atof(argv[arg++]); OUT.gamm[1] = atof(argv[arg++]); break; case 'k': OUT.user_black = atoi(argv[arg++]); break; case 'S': OUT.user_sat = atoi(argv[arg++]); break; case 't': if(!strcmp(optstr,"-timing")) use_timing=1; else if(!argv[arg-1][2]) OUT.user_flip = atoi(argv[arg++]); else fprintf (stderr,"Unknown option \"%s\".\n",argv[arg-1]); break; case 'q': OUT.user_qual = atoi(argv[arg++]); break; case 'm': #ifndef WIN32 if(!strcmp(optstr,"-mmap")) use_mmap = 1; else #endif if(!strcmp(optstr,"-mem")) use_mem = 1; else { if(!argv[arg-1][2]) OUT.med_passes = atoi(argv[arg++]); else fprintf (stderr,"Unknown option \"%s\".\n",argv[arg-1]); } break; case 'H': OUT.highlight = atoi(argv[arg++]); break; case 's': OUT.shot_select = abs(atoi(argv[arg++])); break; case 'o': if(isdigit(argv[arg][0]) && !isdigit(argv[arg][1])) OUT.output_color = atoi(argv[arg++]); #ifndef NO_LCMS else OUT.output_profile = argv[arg++]; break; case 'p': OUT.camera_profile = argv[arg++]; #endif break; case 'h': OUT.half_size = 1; OUT.four_color_rgb = 1; break; case 'f': if(!strcmp(optstr,"-fbdd")) OUT.fbdd_noiserd = atoi(argv[arg++]); else { if(!argv[arg-1][2]) OUT.four_color_rgb = 1; else fprintf (stderr,"Unknown option \"%s\".\n",argv[arg-1]); } break; case 'A': for(c=0; c<4;c++) OUT.greybox[c] = atoi(argv[arg++]); break; case 'B': for(c=0; c<4;c++) OUT.cropbox[c] = atoi(argv[arg++]); break; case 'a': if(!strcmp(optstr,"-aexpo")) { OUT.exp_correc = 1; OUT.exp_shift = (float)atof(argv[arg++]); OUT.exp_preser = (float)atof(argv[arg++]); } else #ifdef LIBRAW_DEMOSAIC_PACK_GPL3 if(!strcmp(optstr,"-acae")) { OUT.ca_correc = 1; OUT.cared = (float)atof(argv[arg++]); OUT.cablue = (float)atof(argv[arg++]); } else if(!strcmp(optstr,"-aline")) { OUT.cfaline = 1; OUT.linenoise = (float)atof(argv[arg++]); } else if(!strcmp(optstr,"-aclean")) { OUT.cfa_clean = 1; OUT.lclean = (float)atof(argv[arg++]); OUT.cclean = (float)atof(argv[arg++]); } else if(!strcmp(optstr,"-agreen")) { OUT.cfa_green = 1; OUT.green_thresh =(float)atof(argv[arg++]); } else #endif if(!argv[arg-1][2]) OUT.use_auto_wb = 1; else fprintf (stderr,"Unknown option \"%s\".\n",argv[arg-1]); break; case 'w': OUT.use_camera_wb = 1; break; case 'M': OUT.use_camera_matrix = (opm == '+'); break; case 'j': OUT.use_fuji_rotate = 0; break; case 'W': OUT.no_auto_bright = 1; break; case 'T': OUT.output_tiff = 1; break; case '4': OUT.gamm[0] = OUT.gamm[1] = OUT.no_auto_bright = 1; /* no break here! */ case '6': OUT.output_bps = 16; break; case 'F': use_bigfile=1; break; case 'd': if(!strcmp(optstr,"-dcbi")) OUT.dcb_iterations = atoi(argv[arg++]); else if(!strcmp(optstr,"-disars")) OUT.use_rawspeed=0; else if(!strcmp(optstr,"-dcbe")) OUT.dcb_enhance_fl = 1; else if(!strcmp(optstr,"-dbnd")) { for(c=0; c<4; c++) OUT.wf_deband_treshold[c] = (float)atof(argv[arg++]); OUT.wf_debanding = 1; } else fprintf (stderr,"Unknown option \"%s\".\n",argv[arg-1]); break; #ifdef LIBRAW_DEMOSAIC_PACK_GPL2 case 'e': if(!strcmp(optstr,"-eeci")) OUT.eeci_refine = 1; else if(!strcmp(optstr,"-esmed")) OUT.es_med_passes = atoi(argv[arg++]); else fprintf (stderr,"Unknown option \"%s\".\n",argv[arg-1]); break; #endif default: fprintf (stderr,"Unknown option \"-%c\".\n", opt); return 1; } } #ifndef WIN32 putenv ((char*)"TZ=UTC"); // dcraw compatibility, affects TIFF datestamp field #else _putenv ((char*)"TZ=UTC"); // dcraw compatibility, affects TIFF datestamp field #endif #define P1 RawProcessor.imgdata.idata #define S RawProcessor.imgdata.sizes #define C RawProcessor.imgdata.color #define T RawProcessor.imgdata.thumbnail #define P2 RawProcessor.imgdata.other if(verbosity>1) RawProcessor.set_progress_handler(my_progress_callback,(void*)"Sample data passed"); #ifdef LIBRAW_USE_OPENMP if(verbosity) printf ("Using %d threads\n", omp_get_max_threads()); #endif for ( ; arg < argc; arg++) { char outfn[1024]; if(verbosity) printf("Processing file %s\n",argv[arg]); timerstart(); #ifndef WIN32 if(use_mmap) { int file = open(argv[arg],O_RDONLY); struct stat st; if(file<0) { fprintf(stderr,"Cannot open %s: %s\n",argv[arg],strerror(errno)); continue; } if(fstat(file,&st)) { fprintf(stderr,"Cannot stat %s: %s\n",argv[arg],strerror(errno)); close(file); continue; } int pgsz = getpagesize(); msize = ((st.st_size+pgsz-1)/pgsz)*pgsz; iobuffer = mmap(NULL,msize,PROT_READ,MAP_PRIVATE,file,0); if(!iobuffer) { fprintf(stderr,"Cannot mmap %s: %s\n",argv[arg],strerror(errno)); close(file); continue; } close(file); if( (ret = RawProcessor.open_buffer(iobuffer,st.st_size) != LIBRAW_SUCCESS)) { fprintf(stderr,"Cannot open_buffer %s: %s\n",argv[arg],libraw_strerror(ret)); continue; // no recycle b/c open file will recycle itself } } else #endif if (use_mem) { int file = open(argv[arg],O_RDONLY|O_BINARY); struct stat st; if(file<0) { fprintf(stderr,"Cannot open %s: %s\n",argv[arg],strerror(errno)); continue; } if(fstat(file,&st)) { fprintf(stderr,"Cannot stat %s: %s\n",argv[arg],strerror(errno)); close(file); continue; } if(!(iobuffer = malloc(st.st_size))) { fprintf(stderr,"Cannot allocate %d kbytes for memory buffer\n",(int)(st.st_size/1024)); close(file); continue; } int rd; if(st.st_size!=(rd=read(file,iobuffer,st.st_size))) { fprintf(stderr,"Cannot read %d bytes instead of %d to memory buffer\n",(int)rd,(int)st.st_size); close(file); free(iobuffer); continue; } close(file); if( (ret = RawProcessor.open_buffer(iobuffer,st.st_size) != LIBRAW_SUCCESS)) { fprintf(stderr,"Cannot open_buffer %s: %s\n",argv[arg],libraw_strerror(ret)); free(iobuffer); continue; // no recycle b/c open file will recycle itself } } else { if(use_bigfile) // force open_file switch to bigfile processing ret = RawProcessor.open_file(argv[arg],1); else ret = RawProcessor.open_file(argv[arg]); if( ret != LIBRAW_SUCCESS) { fprintf(stderr,"Cannot open %s: %s\n",argv[arg],libraw_strerror(ret)); continue; // no recycle b/c open_file will recycle itself } } if(use_timing) timerprint("LibRaw::open_file()",argv[arg]); timerstart(); if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS) { fprintf(stderr,"Cannot unpack %s: %s\n",argv[arg],libraw_strerror(ret)); continue; } if(use_timing) timerprint("LibRaw::unpack()",argv[arg]); timerstart(); if (LIBRAW_SUCCESS != (ret = RawProcessor.dcraw_process())) { fprintf(stderr,"Cannot do postpocessing on %s: %s\n",argv[arg],libraw_strerror(ret)); if(LIBRAW_FATAL_ERROR(ret)) continue; } if(use_timing) timerprint("LibRaw::dcraw_process()",argv[arg]); snprintf(outfn,sizeof(outfn), "%s.%s", argv[arg], OUT.output_tiff ? "tiff" : (P1.colors>1?"ppm":"pgm")); if(verbosity) { printf("Writing file %s\n",outfn); } if( LIBRAW_SUCCESS != (ret = RawProcessor.dcraw_ppm_tiff_writer(outfn))) fprintf(stderr,"Cannot write %s: %s\n",outfn,libraw_strerror(ret)); #ifndef WIN32 if(use_mmap && iobuffer) { munmap(iobuffer,msize); iobuffer=0; } #endif else if(use_mem && iobuffer) { free(iobuffer); iobuffer = 0; } RawProcessor.recycle(); // just for show this call } return 0; }
int main (int argc, char *argv[]) { int max_points_per_rank = 100; int num_time_steps = 100; REAL time_step = 0.001; int n, i, rank, size, *ranks; REAL *point[3], *velo[3]; struct timing t; double dt[2], gt[2]; if (argc == 1) { printf ("SYNOPSIS: test_dynlb max_points_per_rank [num_time_steps = 100] [time_step = 0.001]\n"); return 0; } if (argc >= 2) max_points_per_rank = atoi(argv[1]); if (argc >= 3) num_time_steps = atoi(argv[2]); if (argc >= 4) time_step = atof(argv[3]); MPI_Init (&argc, &argv); MPI_Comm_rank (MPI_COMM_WORLD, &rank); MPI_Comm_size (MPI_COMM_WORLD, &size); srand(time(NULL) + rank); n = rand() % max_points_per_rank + 1; if (rank == 0) printf ("Generating random points in unit cube...\n"); timerstart (&t); printf ("Generating %d points on rank %d.\n", n, rank); ERRMEM (point[0] = malloc (n * sizeof (REAL))); ERRMEM (point[1] = malloc (n * sizeof (REAL))); ERRMEM (point[2] = malloc (n * sizeof (REAL))); ERRMEM (velo[0] = malloc (n * sizeof (REAL))); ERRMEM (velo[1] = malloc (n * sizeof (REAL))); ERRMEM (velo[2] = malloc (n * sizeof (REAL))); ERRMEM (ranks = malloc (n * sizeof (int))); for (i = 0; i < n; i ++) { point[0][i] = DRAND(); point[1][i] = DRAND(); point[2][i] = DRAND(); velo[0][i] = DRAND()-0.5; velo[1][i] = DRAND()-0.5; velo[2][i] = DRAND()-0.5; } dt[0] = ptimerend (&t); if (rank == 0) printf ("Generating points took %g sec.\n", dt[0]); if (rank == 0) printf ("Timing %d simple morton based balancing steps...\n", num_time_steps); for (i = 0, dt[0] = 0.0, dt[1] = 0.0; i < num_time_steps; i ++) { timerstart (&t); dynlb_morton_balance (n, point, ranks); dt[0] += timerend (&t); if (rank == 0) printf ("."), fflush (stdout); timerstart (&t); unit_cube_step (0, n, point, velo, time_step); dt[1] += timerend (&t); } MPI_Allreduce (dt, gt, 2, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); gt[0] /= (double)size * (double)num_time_steps; gt[1] /= (double)size * (double)num_time_steps; if (rank == 0) printf ("\nMORTON: avg. integration: %g sec. per step, avg. balancing: %g sec. per step; ratio: %g\n", gt[0]+gt[1], gt[1], gt[1]/(gt[0]+gt[1])); if (rank == 0) printf ("Creating partitioning tree based balancer ...\n"); timerstart (&t); struct dynlb *lb = dynlb_create (0, n, point, 0, 0.5, DYNLB_RCB_TREE); dt[0] += ptimerend (&t); if (rank == 0) printf ("Took %g sec.\nInitial imbalance %g\n", dt[0], lb->imbalance); if (rank == 0) printf ("Timing %d partitioning tree based balancing steps...\n", num_time_steps); for (i = 0, dt[0] = 0.0, dt[1] = 0.0; i < num_time_steps; i ++) { timerstart (&t); dynlb_update (lb, n, point); dt[0] += timerend (&t); if (rank == 0) printf ("Step %d imbalance %g\n", i, lb->imbalance); timerstart (&t); unit_cube_step (0, n, point, velo, time_step); dt[1] += timerend (&t); } MPI_Allreduce (dt, gt, 2, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); gt[0] /= (double)size * (double)num_time_steps; gt[1] /= (double)size * (double)num_time_steps; if (rank == 0) printf ("TREE: avg. integration: %g sec. per step, avg. balancing: %g sec. per step; ratio: %g\n", gt[0]+gt[1], gt[1], gt[1]/(gt[0]+gt[1])); free (point[0]); free (point[1]); free (point[2]); free (velo[0]); free (velo[1]); free (velo[2]); free (ranks); MPI_Finalize (); return 0; }
int main(int argc, char *argv[]) { int i, ret,rep=1; LibRaw RawProcessor; #ifdef OUT #undef OUT #endif #define OUT RawProcessor.imgdata.params #define S RawProcessor.imgdata.sizes if(argc<2) { printf( "postprocessing benchmark: LibRaw %s sample, %d cameras supported\n" "Measures postprocessing speed with different options\n" "Usage: %s [-a] [-H N] [-q N] [-h] [-m N] [-n N] [-s N] [-B x y w h] [-R N]\n" "-a average image for white balance\n" "-H <num> Highlight mode (0=clip, 1=unclip, 2=blend, 3+=rebuild)\n" "-q <num> Set the interpolation quality\n" "-h Half-size color image\n" "-m <num> Apply a num-passes 3x3 median filter to R-G and B-G\n" "-n <num> Set threshold for wavelet denoising\n" "-s <num> Select one raw image from input file\n" "-B <x y w h> Crop output image\n" "-R <num> Number of repetitions\n" "-c Do not use rawspeed\n" ,LibRaw::version(), LibRaw::cameraCount(), argv[0]); return 0; } char opm,opt,*cp,*sp; int arg,c; int shrink = 0; argv[argc] = (char*)""; for (arg=1; (((opm = argv[arg][0]) - 2) | 2) == '+'; ) { char *optstr = argv[arg]; opt = argv[arg++][1]; if ((cp = strchr (sp=(char*)"HqmnsBR", opt))!=0) for (i=0; i < "1111141"[cp-sp]-'0'; i++) if (!isdigit(argv[arg+i][0]) && !optstr[2]) { fprintf (stderr,"Non-numeric argument to \"-%c\"\n", opt); return 1; } switch (opt) { case 'a': OUT.use_auto_wb = 1; break; case 'H': OUT.highlight = atoi(argv[arg++]); break; case 'q': OUT.user_qual = atoi(argv[arg++]); break; case 'h': OUT.half_size = 1; OUT.four_color_rgb = 1; shrink = 1; break; case 'm': OUT.med_passes = atoi(argv[arg++]); break; case 'n': OUT.threshold = (float)atof(argv[arg++]); break; case 's': OUT.shot_select = abs(atoi(argv[arg++])); break; case 'B': for(c=0; c<4;c++) OUT.cropbox[c] = atoi(argv[arg++]); break; case 'R': rep = abs(atoi(argv[arg++])); if(rep<1) rep = 1; break; case 'c': OUT.use_rawspeed = 0; break; default: fprintf (stderr,"Unknown option \"-%c\".\n", opt); return 1; } } for ( ; arg < argc; arg++) { printf("Processing file %s\n",argv[arg]); timerstart(); if( (ret = RawProcessor.open_file(argv[arg])) != LIBRAW_SUCCESS) { fprintf(stderr,"Cannot open_file %s: %s\n",argv[arg],libraw_strerror(ret)); continue; // no recycle b/c open file will recycle itself } if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS) { fprintf(stderr,"Cannot unpack %s: %s\n",argv[arg],libraw_strerror(ret)); continue; } float qsec = timerend(); printf("\n%.1f msec for unpack\n",qsec); float mpix,rmpix; timerstart(); for(c=0; c < rep; c++) { if( (ret = RawProcessor.dcraw_process() ) != LIBRAW_SUCCESS) { fprintf(stderr,"Cannot postprocess %s: %s\n",argv[arg],libraw_strerror(ret)); break; } libraw_processed_image_t *p = RawProcessor.dcraw_make_mem_image(); if(p) RawProcessor.dcraw_clear_mem(p); RawProcessor.free_image(); } float msec = timerend()/(float)rep; if( (ret = RawProcessor.adjust_sizes_info_only() ) != LIBRAW_SUCCESS) { fprintf(stderr,"Cannot adjust sizes for %s: %s\n",argv[arg],libraw_strerror(ret)); break; } rmpix = (S.iwidth*S.iheight)/1000000.0f; if(c==rep) // no failure { unsigned int crop[4]; for(int i=0;i<4;i++) crop[i] = (OUT.cropbox[i])>>shrink; if(crop[0]+crop[2]>S.iwidth) crop[2] = S.iwidth-crop[0]; if(crop[1]+crop[3]>S.iheight) crop[3] = S.iheight-crop[1]; mpix = float(crop[2]*crop[3])/1000000.0f; float mpixsec = mpix*1000.0f/msec; printf( "Performance: %.2f Mpix/sec\n" "File: %s, Frame: %d %.1f total Mpix, %.1f msec\n" "Params: WB=%s Highlight=%d Qual=%d HalfSize=%s Median=%d Wavelet=%.0f\n" "Crop: %u-%u:%ux%u, active Mpix: %.2f, %.1f frames/sec\n", mpixsec ,argv[arg],OUT.shot_select,rmpix,msec, OUT.use_auto_wb?"auto":"default",OUT.highlight,OUT.user_qual,OUT.half_size?"YES":"No", OUT.med_passes,OUT.threshold, crop[0],crop[1],crop[2],crop[3],mpix,1000.0f/msec); } }