int main(int argc, char* argv[]) { FILE *statsFile = fopen("perfstats.raw", "w"); TfStopwatch watch; int recrusionSizes[] = {1, 2, 10};//, 100}; int testSizes[] = {1000000, 10000000, 100000000}; for (int R : recrusionSizes) { std::cout << "Recursion depth: " << R << std::endl; for (int size : testSizes) { watch.Reset(); watch.Start(); auto collection = CreateTrace(size, R); watch.Stop(); std::cout << "Create Trace N: " << size << " time: " << watch.GetSeconds() << " scopes/msec: " << float(size)/watch.GetMilliseconds() << std::endl; auto reporter = TraceReporter::New( "Test", TraceReporterDataSourceCollection::New(collection)); watch.Reset(); watch.Start(); reporter->UpdateAggregateTree(); watch.Stop(); WriteStats( statsFile, TfStringPrintf("aggregate tree R %d N %d", R, size), watch); std::cout << "Aggregate Tree N: " << size << " time: " << watch.GetSeconds() << " scopes/msec: " << float(size)/watch.GetMilliseconds() << std::endl; watch.Reset(); watch.Start(); auto tree = TraceEventTree::New(*collection); watch.Stop(); WriteStats( statsFile, TfStringPrintf("event tree R %d N %d", R, size), watch); std::cout << "Event Tree N: " << size << " time: " << watch.GetSeconds() << " scopes/msec: " << float(size)/watch.GetMilliseconds() << std::endl; } } fclose(statsFile); return 0; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFStatPanel::ResetStats( void ) { ClearStatsInMemory(); WriteStats(); g_TFSteamStats.UploadStats(); }
//----------------------------------------------------------------------------- // Purpose: called when level is shutting down //----------------------------------------------------------------------------- void CTFStatPanel::LevelShutdown() { // write out stats if they've changed CalcMaxsAndRecords(); WriteStats(); UpdateStatSummaryPanel(); }
void xHeap::DumpUsage(const char * filename) { FILE * f = fopen(filename, "wt"); if(!f) return; uint32 freeSize = 0x7fffffff; WriteStats(f, freeSize); #ifndef USE_APP_HEAP_SAVING_MODE WriteFreeBlockHeader(f, freeSize); WriteFreeBlocks(f, freeSize); #endif // USE_APP_HEAP_SAVING_MODE #ifdef DEBUG_APP_HEAP WriteSmallBlockHeader(f, freeSize); WriteSmallBlocks(f, freeSize); #endif #ifndef USE_APP_HEAP_SAVING_MODE WriteBlockHeader(f, 1, freeSize); WriteBlocks(f, &dummyBlock, freeSize); #endif // USE_APP_HEAP_SAVING_MODE WriteBlockHeader(f, 2, freeSize); WriteBlocks(f, &dummyLargeBlock, freeSize); fclose(f); }
//----------------------------------------------------------------------------- bool psNPCLoader::SaveToFile(int id, csString &filename) { filename.Insert(0,"/this/"); psCharacterLoader loader; npc = loader.LoadCharacterData(id,false); if(!npc) { CPrintf(CON_ERROR, "Error: Couldn't load NPC with id: %i\n",id); return false; } //*npc = *character; // removed npcID = id; area = npc->GetCharName(); csRef<iDocumentSystem> xml; xml.AttachNew(new csTinyDocumentSystem); csRef<iDocument> doc = xml->CreateDocument(); csRef<iDocumentNode> root = doc->CreateRoot(); npcRoot = root->CreateNodeBefore(CS_NODE_ELEMENT); npcRoot->SetValue("npc"); WriteBasicInfo(); WriteDescription(); WriteLocation(); WriteStats(); WriteMoney(); WriteEquipment(); WriteFactions(); WriteSkills(); WriteMerchantInfo(); WriteTrainerInfo(); WriteKnowledgeAreas(); WriteSpecificKnowledge(); csRef<iVFS> vfs = csQueryRegistry<iVFS> (psserver->GetObjectReg()); if(!vfs) return false; csString error = doc->Write(vfs, filename); if(!error.IsEmpty()) { CPrintf(CON_ERROR, "Error writing to file %s: %s\n",filename.GetData(), error.GetData()); return false; } return true; }
//=============================================================================================== // FUNCTION: Write // PURPOSE: Writes the complete protocol to the data file. // BOOL CProtocolWriterABF2::Write( const ABF_FileInfo *pOldFileInfo, ABFFileHeader *pFH ) { MEMBERASSERT(); RPTRASSERT( pFH ); m_pFH = pFH; BOOL bOK = TRUE; // Clear the existing file contents if no data has been written. if( m_pFI->GetAcquiredSamples() == 0 ) bOK &= m_pFI->SetEndOfFile(); if( pOldFileInfo ) m_FileInfo.StringsSection = pOldFileInfo->StringsSection; // Clear the strings since we are about to re-write them. m_Strings.Clear(); // Write out the various bits. bOK &= WriteFileInfo(); bOK &= WriteProtocolInfo(); bOK &= WriteADCInfo(); bOK &= WriteDACInfo(); bOK &= WriteEpochs(); bOK &= WriteStats(); bOK &= WriteUserList(); bOK &= WriteMathInfo(); // Write out the protocol strings. bOK &= WriteStrings(); // Now re-write the FileInfo to update the the section info. bOK &= m_pFI->Seek( 0L, FILE_BEGIN); bOK &= m_pFI->Write( &m_FileInfo, sizeof( m_FileInfo ) ); bOK &= m_pFI->Seek( 0L, FILE_END); m_pFI->FillToNextBlock( &m_lNextBlock ); if( m_pFI->GetAcquiredSamples() == 0 ) { m_FileInfo.DataSection.uBlockIndex = m_lNextBlock; m_pFH->lDataSectionPtr = m_lNextBlock; } return bOK; }
int WriteDatabases() { if (!WriteOpers()) return (0); #ifdef STATSERVICES if (!WriteStats()) return (0); #endif /* STATSERVICES */ #ifdef SEENSERVICES if (!WriteSeen()) return (0); #endif /* SEENSERVICES */ #ifdef NICKSERVICES if (!WriteNicks()) return (0); #ifdef CHANNELSERVICES if (!WriteChans()) return (0); #endif /* CHANNELSERVICES */ #ifdef MEMOSERVICES if (!WriteMemos()) return (0); #endif /* MEMOSERVICES */ #endif /* NICKSERVICES */ return (1); } /* WriteDatabases() */
void CreateStatistics(char *InputFile, char *OutputFile) { int i, j, k; char lkk1[LONGSTRINGSIZE], llog[LONGSTRINGSIZE]; statistics stats; FILE *fIn, *fOut, *fcfg; double aux; int num_measures; /* ------------------------------------------------------------------ ------------------------------------------------------------------ */ /*create summary: table version*/ for (i = 0; i <= (MAXMEAS-1); i++) { stats.avg[i] = 0.0; /*initialization of statistics variables*/ stats.sig[i] = 0.0; stats.max[i] = -1.7e38; stats.min[i] = 1.7e38; } if ((fIn=fopen(InputFile,"rt")) == 0) { printf("auxfunc_log.c - Cannot open input file: %s\n", InputFile); exit(EXIT_FAILURE); } if ((fOut=fopen(OutputFile,"wt")) == 0) { printf("auxfunc_log.c - Cannot open output file: %s\n", OutputFile); exit(EXIT_FAILURE); } fgets2(lkk, LONGSTRINGSIZE, fIn); if (P_eof(fIn)) /*if there is only 1 line*/ fseek(fIn, 0, SEEK_SET); strsub(lkk1, lkk, 1, strpos2(lkk, ":", 1)-1); i=0; j=1; k=0; while (!P_eof(fIn)) { aux = asc2real(lkk1, 1, (int)strlen(lkk1)); stats.avg[i] += aux; stats.sig[i] += aux * aux; /*variancia=sum(x^2)/n - (avg(x))^2 # sigma=sqrt(variancia)*/ if (aux > stats.max[i]) stats.max[i] = aux; if (aux < stats.min[i]) stats.min[i] = aux; if (j==(int)strlen(lkk)) { num_measures=i; i=0;j=1;k++; fgets2(lkk, LONGSTRINGSIZE, fIn); strsub(lkk1, lkk, 1, strpos2(lkk, ":", 1)-1); } else { ReadSubKey(lkk1, lkk, &j, ':', ':', 1); i++; j--; } } WriteStats(num_measures-1, k, stats, &fOut); /* -- */ i=0; dd_ffblk fb; char *mask="*.cfg"; if (!dd_findfirst( mask, &fb, DD_DIREC )) { /*Find first file having extension .cfg */ if (!strcmp(fb.dd_name, "rfmodule.cfg")) /*and make sure that it is not rfmodule.cfg*/ i=dd_findnext(&fb); /*otherwise find next .cfg file */ if (i==0) printf("Opening config file: %s\n", fb.dd_name); } /* -- */ fprintf(fOut, "\n\n# Parameters #\n"); /*--------*/ strcpy(llog,lkk); /*last line from log file*/ fcfg=NULL; if ((fcfg=fopen(fb.dd_name,"rt")) == 0) { if (fb.dd_name) { printf("auxfunc_log.c - Cannot open config file: %s\n", fb.dd_name); /*exit(EXIT_FAILURE);*/ } SimpleParametersCategory(num_measures-1, llog, stats, &fOut); } else { ReadKey(lkk, "# Parameters #", fcfg); /*configuration parameters*/ if (strcmp(lkk, "# Parameters #")) { printf("INFO: auxfunc_log.c - Step2 -- No parameters in config file\n"); SimpleParametersCategory(num_measures-1, llog, stats, &fOut); } else { ComplexParametersCategory(llog, stats, &fOut, &fcfg); } } /*--------*/ fprintf(fOut, "#\n"); if (fOut != NULL) fclose(fOut); fOut = NULL; if (fIn != NULL) fclose(fIn); fIn = NULL; /* ------------------------------------------------------------------ ------------------------------------------------------------------ */ }