inline double RunTestImpl ( const char* title, void (*pfn)(), char* histogramFileName = no_histogram ) { double time = 0, variation = 0, deviation = 0; size_t nrep = 1; while (true) { CalibrateTiming(NRUNS, 1, nrep); StartTiming(NRUNS, 1, nrep); pfn(); StopTiming(time, variation, deviation); time -= util::base; if ( time > 1e-6 ) break; nrep *= 2; } nrep *= (size_t)ceil(ONE_TEST_DURATION/time); CalibrateTiming(NRUNS, 1, nrep); // sets util::base util::durations_t t; StartTimingEx(t, NRUNS, 1, nrep); pfn(); StopTiming(time, variation, deviation); if ( histogramFileName != (char*)-1 ) util::trace_histogram(t, histogramFileName); double clean_time = time - util::base; if ( title ) { // Deviation (in percent) is calulated for the Gross time printf ("\n%-34s %.2e %5.1f ", title, clean_time, deviation); if ( util::sequential_time != 0 ) //printf ("% .2e ", clean_time - util::sequential_time); printf ("% 10.1f ", 100*(clean_time - util::sequential_time)/util::sequential_time); else printf ("%*s ", util::rate_field_len, ""); printf ("%-9u %1.6f |", (unsigned)nrep, time * nrep); } return clean_time; }
void MHmgphy::SolveSystem( vector<double> &X, int nTr ) { fflush( stdout ); clock_t t0 = StartTiming(); #if 0 HmgphyFromHmgphy( X, nTr ); #else vector<double> Xin; AFromTbl( Xin, nTr ); clock_t t2 = StartTiming(); OnePassTH( _OnePass_HFromA, X, Xin, nTr*8, 16, 0.9 ); printf( "Just HfromA\n" ); PrintMagnitude( X ); fflush( stdout ); for( gpass = 0; gpass < 2000; ++gpass ) { // 1000 - 2000 good Xin = X; OnePassTH( _OnePass_HFromH, X, Xin, nTr*8, 16, 0.9 ); printf( "Done pass %d\n", gpass + 1 ); fflush( stdout ); } PrintMagnitude( X ); StopTiming( stdout, "Iters", t2 ); fflush( stdout ); myc.clear(); #endif StopTiming( stdout, "SolveH", t0 ); }
int main( int argc, char* argv[] ) { clock_t t0 = StartTiming(); /* ------------------ */ /* Parse command line */ /* ------------------ */ gArgs.SetCmdLine( argc, argv ); TS.SetLogFile( flog ); if( !ReadScriptParams( scr, gArgs.script, flog ) ) goto exit; inv_scl = 1.0 / scr.crossscale; /* ---------------- */ /* Read source data */ /* ---------------- */ if( gArgs.zb >= 0 && gArgs.za < 0 ) gArgs.za = gArgs.zb; TS.FillFromRgns( gArgs.srcmons, gArgs.idb, gArgs.zb, gArgs.za ); fprintf( flog, "Got %d images.\n", (int)TS.vtil.size() ); if( !TS.vtil.size() ) goto exit; TS.SetTileDimsFromImageFile(); TS.GetTileDims( gW, gH ); t0 = StopTiming( flog, "ReadFile", t0 ); /* ------------- */ /* Sort by layer */ /* ------------- */ TS.SortAll_z(); /* ----- */ /* Stuff */ /* ----- */ ScapeStuff(); /* ---- */ /* Done */ /* ---- */ exit: fprintf( flog, "\n" ); VMStats( flog ); fclose( flog ); return 0; }
void CDecPerformanceForm::StartTiming() { if (perf_operation) return ; // just to be sure StopTiming(); // update number of passes from edit control CString strPhaseCount; edit_passes.GetWindowText(strPhaseCount); phase_count = StrToInt(strPhaseCount); phase_count = max(phase_count, 1); phase_count = min(phase_count, PASSES_MAX); // update the file list CString source_file; cb_files.GetWindowText(source_file); file_list.UpdateList(source_file); file_list.SaveList(_T("DecPerfFileList")); cb_files.ResetContent(); for (int i=0; i<file_list.GetCount(); i++) { cb_files.AddString(file_list[i]); } cb_files.SetWindowText(source_file); list_results.DeleteAllItems(); // update view view->UpdateGraphState(); view->graph.RefreshFilters(); view->graph.SmartPlacement(false); view->Invalidate(); // reset the clock // if this was done before the filters were refreshed, the graph was not reset for some reason :-/ // NB this may not be necessary after recent bug fixes to clock management view->graph.SetClock(0 != IsDlgButtonChecked(IDC_CHECK_USE_CLOCK), NULL); // update the display again view->graph.RefreshFilters(); view->graph.SmartPlacement(false); view->Invalidate(); // Find first time measure filter in graph and store a reference to it for (int i=0; i<view->graph.filters.GetCount() && !time_filter; i++) { if (view->graph.filters[i]->filter) view->graph.filters[i]->filter->QueryInterface(__uuidof(ITimeMeasureFilter), (void**)&time_filter); } // run the graph phase_cur = 0; timings_min = Timings(); timings_max = Timings(); timings_avg = Timings(); running = true; view->OnPlayClick(); }
static void PrintResults(std::ostream & out = std::cout) { // Print out the timing and operation count results for the // program in a standard format. if (_stopTime == 0) { StopTiming(); } out << "Sys\tName\tRunTime\tOperations\tThreads\topsPerSec\tBandwidth\n"; out << _system << "\t" << _name << "\t" << _stopTime - _startTime << "\t" << _operationsCompleted << "\t" << _threadCount << "\t" << (static_cast<float>(_operationsCompleted)/(_stopTime - _startTime)) << "\t" << (static_cast<float>(GetFootPrintMB())/(_stopTime - _startTime)) << "\n"; }
void CDecPerformanceForm::OnBuildGraphClick() { time_filter = NULL; view->OnNewClick(); // clear any existing graph // just to be sure StopTiming(); view->graph.params->MarkRender(true); HRESULT hr = BuildPerformanceGraph(view->graph.gb); // errors displayed in here with context view->graph.params->MarkRender(false); view->OnRenderFinished(); view->graph.RefreshFilters(); view->graph.SmartPlacement(); view->Invalidate(); }
void CDecPerformanceForm::OnPhaseComplete() { if (!running) return ; Timings timings; // Get current results of current phase if (time_filter) { time_filter->GetStats(&timings.runtime_ns, &timings.frames, &timings.realtime_ns); } else { timings.runtime_ns = view->last_stop_time_ns - view->last_start_time_ns; // no time measure filter but we can measure the total streaming time } if (timings.runtime_ns <= 0) timings.runtime_ns = 1; // avoid division by zero. timings_avg.runtime_ns += timings.runtime_ns; // update average timings timings_avg.frames += timings.frames; timings_avg.realtime_ns += timings.realtime_ns; if (0 == phase_cur) { // update min/max timings timings_min = timings; timings_max = timings; } else { if (timings.runtime_ns < timings_min.runtime_ns) timings_min = timings; if (timings.runtime_ns > timings_max.runtime_ns) timings_max = timings; } CString phase_idx_str; // display timings for the current phase phase_idx_str.Format(_T("%d"), phase_cur+1); InsertListItem(timings, phase_cur, phase_idx_str); phase_cur ++; if (phase_cur >= phase_count) { // if we're done StopTiming(); } else { view->OnStopClick(); // start the next run view->OnPlayClick(); } }
void CDecPerformanceForm::OnStopClick() { StopTiming(); }
int main( int argc, char **argv ) { clock_t t0 = StartTiming(); /* ---------- */ /* Parameters */ /* ---------- */ MPIInit( argc, argv ); if( !gArgs.SetCmdLine( argc, argv ) || !gArgs.GetRanges() ) { MPIExit(); exit( 42 ); } /* ------------ */ /* Initial data */ /* ------------ */ if( !LayerCat( vL, gArgs.tempdir, gArgs.cachedir, gArgs.zolo, gArgs.zohi, false ) ) { MPIExit(); exit( 42 ); } InitTables( gArgs.zilo, gArgs.zihi ); { CLoadPoints *LP = new CLoadPoints; LP->Load( gArgs.tempdir, gArgs.cachedir ); delete LP; } /* ----- */ /* Solve */ /* ----- */ printf( "\n---- Solve ----\n" ); SetSolveParams( gArgs.regtype, gArgs.Wr, gArgs.Etol ); XArray Xevn, Xodd; if( !strcmp( gArgs.mode, "A2A" ) ) { Xevn.Load( gArgs.prior ); if( gArgs.untwist ) UntwistAffines( Xevn ); Xodd.Resize( 6 ); Solve( Xevn, Xodd, gArgs.iters ); } else if( !strcmp( gArgs.mode, "A2H" ) ) { Xevn.Resize( 8 ); { // limit A lifetime XArray *A = new XArray; A->Load( gArgs.prior ); if( gArgs.untwist ) UntwistAffines( *A ); Solve( *A, Xevn, 1 ); delete A; } Xodd.Resize( 8 ); Solve( Xevn, Xodd, gArgs.iters ); } else if( !strcmp( gArgs.mode, "H2H" ) ) { Xevn.Load( gArgs.prior ); Xodd.Resize( 8 ); Solve( Xevn, Xodd, gArgs.iters ); } else if( !strcmp( gArgs.mode, "eval" ) ) { Xevn.Load( gArgs.prior ); if( gArgs.untwist ) UntwistAffines( Xevn ); gArgs.iters = 0; } else { // split Xevn.Load( gArgs.prior ); gArgs.iters = 0; } const XArray& Xfinal = ((gArgs.iters & 1) ? Xodd : Xevn); /* ----------- */ /* Postprocess */ /* ----------- */ if( gArgs.mode[0] == 's' ) { Split S( Xfinal, gArgs.splitmin ); S.Run(); } else { Evaluate( Xfinal ); if( gArgs.mode[0] != 'e' ) Xfinal.Save(); } /* ------- */ /* Cleanup */ /* ------- */ if( !wkid ) { printf( "\n" ); StopTiming( stdout, "Lsq", t0 ); } MPIExit(); VMStats( stdout ); return 0; }
// The strip alignment from S.DenovoBestAngle (followed by SetXY) // produces a transform A->B = best.T for the scaled down scapes. // Here's how to convert that to a transform between the original // montages: // // Recapitulate total process... // TAffine Rbi, Ra, t; // // Scale back up // best.T.MulXY( scr.crossscale ); // A.x0 *= scr.crossscale; // A.y0 *= scr.crossscale; // B.x0 *= scr.crossscale; // B.y0 *= scr.crossscale; // // A-montage -> A-oriented // Ra.NUSetRot( A.deg*PI/180 ); // // A-oriented -> A-scape // Ra.AddXY( -A.x0, -A.y0 ); // // A-scape -> B-scape // t = best.T * Ra; // // B-scape -> B-oriented // t.AddXY( B.x0, B.y0 ); // // B-oriented -> B-montage // Rbi.NUSetRot( -B.deg*PI/180 ); // best.T = Rbi * t; // static void ScapeStuff() { clock_t t0 = StartTiming(); CSuperscape A, B; ThmRec thm; CThmScan S; CorRec best; B.FindLayerIndices( gArgs.zb ); B.OrientLayer(); if( gArgs.ismb ) { char buf[256]; B.MakeWholeRaster(); sprintf( buf, "montages/M_%d_0.png", gArgs.zb ); B.DrawRas( buf ); B.KillRas(); B.WriteMeta( 'M', gArgs.zb ); t0 = StopTiming( flog, "MakeMontage", t0 ); } if( !gArgs.isab ) return; A.FindLayerIndices( gArgs.za ); A.OrientLayer(); MakeStripRasters( A, B ); t0 = StopTiming( flog, "MakeStrips", t0 ); A.MakePoints( thm.av, thm.ap ); A.WriteMeta( 'A', gArgs.za ); B.MakePoints( thm.bv, thm.bp ); B.WriteMeta( 'B', gArgs.zb ); thm.ftc.clear(); thm.reqArea = int(gW * gH * inv_scl * inv_scl); thm.olap1D = int(gW * inv_scl * 0.5); thm.scl = 1; S.Initialize( flog, best ); S.SetRThresh( scr.stripmincorr ); S.SetNbMaxHt( 0.99 ); S.SetSweepConstXY( false ); S.SetSweepPretweak( true ); S.SetSweepNThreads( scr.stripslots ); S.SetUseCorrR( true ); S.SetNewAngProc( NewAngProc ); gA = &A; gB = &B; gS = &S; if( gArgs.abdbg ) { //S.RFromAngle( best, gArgs.abctr, thm ); //S.Pretweaks( best.R, gArgs.abctr, thm ); dbgCor = true; S.RFromAngle( best, gArgs.abctr, thm ); } else { if( scr.stripsweepspan && scr.stripsweepstep ) { S.DenovoBestAngle( best, 0, scr.stripsweepspan / 2, scr.stripsweepstep, thm, true ); } else { best.A = 0; S.PeakHunt( best, 0, thm ); } best.T.Apply_R_Part( A.Opts ); best.X += B.Opts.x - A.Opts.x; best.Y += B.Opts.y - A.Opts.y; best.T.SetXY( best.X, best.Y ); fprintf( flog, "*T: [0,1,2,3,4,5] (strip-strip)\n" ); fprintf( flog, "[%f,%f,%f,%f,%f,%f]\n", best.T.t[0], best.T.t[1], best.T.t[2], best.T.t[3], best.T.t[4], best.T.t[5] ); } t0 = StopTiming( flog, "Corr", t0 ); }
bool PixPair::Load( const char *apath, const char *bpath, int order, int bDoG, int r1, int r2, FILE* flog ) { printf( "\n---- Image loading ----\n" ); clock_t t0 = StartTiming(); /* ----------------------------- */ /* Load and sanity check rasters */ /* ----------------------------- */ uint8 *aras, *bras; uint32 wa, ha, wb, hb; int ok = false; aras = Raster8FromAny( apath, wa, ha, flog ); bras = Raster8FromAny( bpath, wb, hb, flog ); if( !aras || !bras ) { fprintf( flog, "PixPair: Picture load failure.\n" ); goto exit; } if( wa != wb || ha != hb ) { fprintf( flog, "PixPair: Nonmatching picture dimensions.\n" ); goto exit; } ok = true; wf = wa; hf = ha; ws = wa; hs = ha; scl = 1; /* -------------- */ /* Resin removal? */ /* -------------- */ //if( dbgCor ) { // ZeroResin( "bloba.tif", aras ); // ZeroResin( "blobb.tif", bras ); //} //else { // ZeroResin( NULL, aras ); // ZeroResin( NULL, bras ); //} //StopTiming( flog, "Resin removal", t0 ); /* ------- */ /* Flatten */ /* ------- */ LegPolyFlatten( _avf, aras, wf, hf, order ); RasterFree( aras ); LegPolyFlatten( _bvf, bras, wf, hf, order ); RasterFree( bras ); avs_vfy = avs_aln = avf_vfy = avf_aln = &_avf; bvs_vfy = bvs_aln = bvf_vfy = bvf_aln = &_bvf; /* ------------- */ /* Apply filters */ /* ------------- */ //{ // vector<CD> kfft; // double K[] = { // 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; // Convolve( _avf, _avf, wf, hf, K, 11, 11, true, true, kfft ); // Normalize( _avf ); // Convolve( _bvf, _bvf, wf, hf, K, 11, 11, true, true, kfft ); // Normalize( _bvf ); //} #if 0 { vector<CD> kfft; double K[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; Convolve( _avfflt, _avf, wf, hf, K, 11, 11, true, true, kfft ); Normalize( _avfflt ); Convolve( _bvfflt, _bvf, wf, hf, K, 11, 11, true, true, kfft ); Normalize( _bvfflt ); avs_aln = avf_aln = &_avfflt; bvs_aln = bvf_aln = &_bvfflt; bDoG = true; } #endif if( bDoG ) { vector<double> DoG; vector<CD> kfft; int dim = MakeDoGKernel( DoG, r1, r2, flog ); Convolve( _avfflt, _avf, wf, hf, &DoG[0], dim, dim, true, true, kfft ); Normalize( _avfflt ); Convolve( _bvfflt, _bvf, wf, hf, &DoG[0], dim, dim, true, true, kfft ); Normalize( _bvfflt ); avs_aln = avf_aln = &_avfflt; bvs_aln = bvf_aln = &_bvfflt; } /* --------------------- */ /* Downsample all images */ /* --------------------- */ if( ws > 2048 || hs >= 2048 ) { do { ws /= 2; hs /= 2; scl *= 2; } while( ws > 2048 || hs > 2048 ); fprintf( flog, "PixPair: Scaling by %d\n", scl ); if( ws * scl != wf || hs * scl != hf ) { fprintf( flog, "PixPair: Dimensions not multiple of scale!\n" ); goto exit; } Downsample( _avs, _avf ); Downsample( _bvs, _bvf ); avs_vfy = avs_aln = &_avs; bvs_vfy = bvs_aln = &_bvs; if( bDoG ) { if( _avfflt.size() ) { Downsample( _avsflt, _avfflt ); avs_aln = &_avsflt; } if( _bvfflt.size() ) { Downsample( _bvsflt, _bvfflt ); bvs_aln = &_bvsflt; } } } else fprintf( flog, "PixPair: Using image scale=1.\n" ); /* ------------------------------ */ /* Write DoG images for debugging */ /* ------------------------------ */ #if 0 if( bDoG ) { VectorDblToTif8( "DoGa.tif", avs_aln, ws, hs ); VectorDblToTif8( "DoGb.tif", bvs_aln, ws, hs ); } #endif /* -------- */ /* Clean up */ /* -------- */ exit: if( aras ) RasterFree( aras ); if( bras ) RasterFree( bras ); StopTiming( flog, "Image conditioning", t0 ); return ok; }