VOID AutoTest(void){ static OPENFILENAME ofn; static char szFilename[80]; char szT[80]; int i, hfile; Sleep (5000); gfAll = TRUE; for (gibmi = 0; gibmi < gcbmi; gibmi++) { gabmi[gibmi].pfnBenchmark(gabmi[gibmi].cIterations); } hfile = _lopen("usrbench.out", OF_READWRITE); //try to open file if (hfile == -1){ hfile = _lcreat("usrbench.out", 0); //create it if it does not exist if (hfile == -1) return; } else _llseek(hfile, 0L, 2); // go to end of file for append WriteResults(hfile); _lclose(hfile); }
void CAutoTester::Stop() { const char * mapName; if (g_pGame && g_pGame->GetIGameFramework()->GetILevelSystem()->GetCurrentLevel()) { mapName = g_pGame->GetIGameFramework()->GetILevelSystem()->GetCurrentLevel()->GetLevelInfo()->GetName(); } else { mapName = "NoMapLoaded"; } if (g_pGame) { // ITelemetryCollector *itc = g_pGame->GetITelemetryCollector(); // if (itc) // itc->OutputMemoryUsage("AutoTester::Stop", mapName); } m_finished=true; gEnv->pConsole->ExecuteString("memReplayStop"); WriteResults(kWriteResultsFlag_writeDoneMarkerFile); m_testSuites.clear(); }
VOID br_predict(ADDRINT ins_ptr, INT32 taken) { CountSeen++; if (taken) CountTaken++; if(BTB_lookup(ins_ptr)) { if(BTB_prediction(ins_ptr) == taken) CountCorrect++; BTB_update(ins_ptr, taken); } else { if(!taken) CountCorrect++; else { CountMissed++; BTB_insert(ins_ptr);} } if(CountSeen == KnobBranchLimit.Value()) { WriteResults(true); exit(0); } }
int main(int argc, char* argv[]) { MakeList(); std::string filePath; //filePath = argv[1]; /*if(argc > 1) std::string filePath(argv[1]); else { cout << "Please type in the file path of a SIC Basic or XE source code" << endl; getline(cin, filePath); }*/ cout << ParseLine("first = one1 + two2 - three3 / four4 ;") << "\n"; cout << ParseLine("second = one1 * ( ( two2 * three3 ) + ( two2 * three3 ) );") << "\n"; cout << ParseLine("third = ONE + twenty - three3 ;") << "\n"; cout << ParseLine("third = old * thirty2 / b567 ;") << "\n"; cout << ParseLine("one1 * i8766e98e + bignum") << "\n"; cout << ParseLine("third = ONE + twenty - three3 ;") << "\n"; cout << ParseLine("third = ONE + twenty - three3 ;") << "\n"; cout << ParseLine("first = = one1 + two2 - three3 / four4 ;") << "\n"; cout << ParseLine("first = one1 + two2 - three3 / four4") << "\n"; cout << ParseLine("first = 1 + - two2 - three3 / four4 ;") << "\n"; cout << ParseLine("first = one1 + two2 ? three3 / four4 ;") << "\n"; cout << ParseLine("second = 4 + ( one1 * two2 ) * ( three3 + four4 ;") << "\n"; cout << ParseLine("third = one1 + 24 - three3 ;") << "\n"; cout << ParseLine("one1 + - delta") << "\n"; cout << ParseLine("sixty6 / min = fourth ;") << "\n"; filePath = ".\\SICTEST.asm"; WriteResults(); system("PAUSE"); }
unsigned int optimize(PanoramaData& pano, const char * userScript) { char * script = 0; unsigned int retval = 0; if (userScript == 0) { std::ostringstream scriptbuf; UIntSet allImg; fill_set(allImg,0, unsigned(pano.getNrOfImages()-1)); pano.printPanoramaScript(scriptbuf, pano.getOptimizeVector(), pano.getOptions(), allImg, true); script = strdup(scriptbuf.str().c_str()); } else { script = const_cast<char *>(userScript); } OptInfo opt; AlignInfo ainf; if (ParseScript( script, &ainf ) == 0) { if( CheckParams( &ainf ) == 0 ) { ainf.fcn = fcnPano; SetGlobalPtr( &ainf ); opt.numVars = ainf.numParam; opt.numData = ainf.numPts; opt.SetVarsToX = SetLMParams; opt.SetXToVars = SetAlignParams; opt.fcn = ainf.fcn; *opt.message = 0; RunLMOptimizer( &opt ); ainf.data = opt.message; // get results from align info. #ifdef DEBUG_WRITE_OPTIM_OUTPUT fullPath path; StringtoFullPath(&path, DEBUG_WRITE_OPTIM_OUTPUT_FILE ); ainf.data = opt.message; WriteResults( script, &path, &ainf, distSquared, 0); #endif pano.updateVariables( GetAlignInfoVariables(ainf) ); pano.updateCtrlPointErrors( GetAlignInfoCtrlPoints(ainf) ); } else { std::cerr << "Bad params" << std::endl; retval = 2; } DisposeAlignInfo( &ainf ); } else { std::cerr << "Bad params" << std::endl; retval = 1; } if (! userScript) { free(script); } return retval; }
int main(int argc,char *argv[]) { aPrefs aP; char* script; OptInfo opt; AlignInfo ainf; fullPath infile; //fullPath outfile; // SetAdjustDefaults(&aP); if(argc != 2) { printf(PT_OPTIMIZER_VERSION); printf("Usage: %s /path/to/script.txt\n", argv[0]); exit(1); } StringtoFullPath(&infile, argv[1]); script = LoadScript( &infile ); if( script != NULL ) { if (ParseScript( script, &ainf ) == 0) { if( CheckParams( &ainf ) == 0 ) { ainf.fcn = fcnPano; SetGlobalPtr( &ainf ); opt.numVars = ainf.numParam; opt.numData = ainf.numPts; opt.SetVarsToX = SetLMParams; opt.SetXToVars = SetAlignParams; opt.fcn = ainf.fcn; *opt.message = 0; RunLMOptimizer( &opt ); ainf.data = opt.message; WriteResults( script, &infile, &ainf, distSquared, 0); exit(0); } //TODO: if optCreatePano is 1 then should call stitcher OR the option removed //if (ainf.sP.optCreatePano == 1) //{ // Stitch(); //} DisposeAlignInfo( &ainf ); } free( script ); } exit(1); }
void PTools::optimize(Panorama & pano, utils::MultiProgressDisplay & progDisplay, int maxIter) { // VariableMapVector res; // setup data structures aPrefs aP; OptInfo opt; SetAdjustDefaults(&aP); AlignInfoWrap aInfo; // copy pano information int libpano data structures if (aInfo.setInfo(pano)) { aInfo.setGlobal(); opt.numVars = aInfo.gl.numParam; opt.numData = aInfo.gl.numPts; opt.SetVarsToX = SetLMParams; opt.SetXToVars = SetAlignParams; opt.fcn = aInfo.gl.fcn; *opt.message = 0; DEBUG_DEBUG("starting optimizer"); RunLMOptimizer( &opt ); #ifdef DEBUG fullPath path; StringtoFullPath(&path, "c:/debug_optimizer.txt"); aInfo.gl.data = opt.message; WriteResults( "debug_test", &path, &aInfo.gl, distSquared, 0); #endif std::ostringstream oss; /* oss << "optimizing images"; for (UIntVector::const_iterator it = imgs.begin(); it != imgs.end(); ++it) { if (it + 1 != imgs.end()) { oss << *it << ","; } else { oss << *it; } } oss << "\n" << opt.message; progDisplay.setMessage(oss.str()); */ DEBUG_DEBUG("optimizer finished:" << opt.message); pano.updateVariables(aInfo.getVariables()); pano.updateCtrlPointErrors( aInfo.getCtrlPoints()); } }
VOID SaveResults( HWND hwnd) { static OPENFILENAME ofn; static char szFilename[80]; char szT[80]; int i, hfile; // if (ofn.lStructSize != sizeof(ofn)) { for (i = 0; i < sizeof(ofn); i++) ((char *)&ofn)[i] = 0; // clear out the OPENFILENAME struct ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwnd; ofn.hInstance = ghinst; ofn.lpstrFilter = "UserBench Output\0*.ubo\0All Files\0*.*\0"; ofn.lpstrCustomFilter = NULL; ofn.nMaxCustFilter = 0; ofn.nFilterIndex = 0; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = "c:\\"; ofn.Flags = 0; ofn.lpstrDefExt = NULL; ofn.lCustData = 0; ofn.lpfnHook = NULL; ofn.lpTemplateName = NULL; lstrcpy(szFilename, "timings.ubo"); // } ofn.lpstrFile = szFilename; ofn.nMaxFile = sizeof(szFilename); ofn.lpstrTitle = "Save As"; if (!GetSaveFileName(&ofn)) return; hfile = _lcreat(szFilename, 0); if (hfile == -1) return; /* * Write out the build information and current date. */ #ifdef LATER #endif WriteResults(hfile); _lclose(hfile); }
VOID Fini(int n, void *v) { WriteResults(false); }
void CombineTGraphsFromTwoDirectories(TDirectory *dir1, TDirectory *dir2, Int_t iBaseDir, TDirectory *outputDir, Bool_t shouldAddQuadrature) { // Gather TGraphErrors from 1st directory vector<TGraphAsymmErrors*> graphsDir1; TIter nextKey(dir1->GetListOfKeys()); TObject *obj; while ((obj = nextKey())) { TKey *thisKey = dynamic_cast<TKey*>(obj); TGraphAsymmErrors *graph = dynamic_cast<TGraphAsymmErrors*>(thisKey->ReadObj()); if(!graph) continue; graphsDir1.push_back(graph); cout << "This graph name is " << graph->GetName() << endl; } // Gather equivalent TGraphErrors from 2nd directory vector<TGraphAsymmErrors*> graphsDir2; for (UInt_t iGraph = 0; iGraph < graphsDir1.size(); iGraph++) { TString graphName = graphsDir1[iGraph]->GetName(); TGraphAsymmErrors *equivGraph = (TGraphAsymmErrors*)dir2->Get(graphName); if (!equivGraph) { cout << "Could not find equivalent graph in 2nd directory for " << graphName << endl; graphsDir2.push_back(NULL); // Put in Null as a place holder } else { graphsDir2.push_back(equivGraph); } } // Figure out which directory to get the base histogram from TDirectory *baseDir; if (iBaseDir == 1) { baseDir = dir1; } else if (iBaseDir == 2) { baseDir = dir2; } else { cout << "Uh oh! Not a valid directory from which to get base histograms. Index: " << iBaseDir << endl; } // Gather the base histograms vector<TH1D*> baseHists; for (UInt_t iGraph = 0; iGraph < graphsDir1.size(); iGraph++) { TString histName = graphsDir1[iGraph]->GetName(); histName.ReplaceAll("AsymmErrors",""); TH1D *hist = (TH1D*) baseDir->Get(histName); if(!hist) { cout << "Could not find base histogram with name " << histName << endl; baseHists.push_back(NULL); // Put in NULL as placeholder } else { baseHists.push_back(hist); } } // Now combine each graph, save it with its corresponding histogram, and draw it for (UInt_t iGraph = 0; iGraph < graphsDir1.size(); iGraph++) { // Make sure the components exist if (!graphsDir1[iGraph] || !graphsDir2[iGraph] || !baseHists[iGraph]) { cout << "Missing component. Cannot combine graphs for index " << iGraph << endl; continue; } TGraphAsymmErrors* combinedGraph = CombineTwoTGraphAsymm(graphsDir1[iGraph], graphsDir2[iGraph], baseHists[iGraph], shouldAddQuadrature); WriteResults(combinedGraph, baseHists[iGraph], outputDir, shouldAddQuadrature); } }
void Histograms::Finalize() { WriteResults(); JetBase::Finalize(); }