void Phase (const char *phase_name) { while (!(hwPhaseTime && hwStage)) Sleep(1); csLog.Enter (); // Replace phase name with TIME:Name char tbuf [512]; bPhaseChange = TRUE; phase_total_time = timeGetTime()-phase_start_time; sprintf ( tbuf,"%s : %s",make_time(phase_total_time/1000).c_str(), phase); SendMessage ( hwPhaseTime, LB_DELETESTRING, SendMessage(hwPhaseTime,LB_GETCOUNT,0,0)-1,0); SendMessage ( hwPhaseTime, LB_ADDSTRING, 0, (LPARAM) tbuf); // Start _new phase phase_start_time = timeGetTime(); strcpy (phase, phase_name); SetWindowText ( hwStage, phase_name ); sprintf ( tbuf,"--:--:-- * %s",phase); SendMessage ( hwPhaseTime, LB_ADDSTRING, 0, (LPARAM) tbuf); SendMessage ( hwPhaseTime, LB_SETTOPINDEX, SendMessage(hwPhaseTime,LB_GETCOUNT,0,0)-1,0); Progress (0); // Release focus Msg("\n* New phase started: %s",phase_name); csLog.Leave (); }
void Startup(LPSTR lpCmdLine) { char cmd[512],name[256]; BOOL bModifyOptions = FALSE; strcpy(cmd,lpCmdLine); strlwr(cmd); if (strstr(cmd,"-?") || strstr(cmd,"-h")) { Help(); return; } if (strstr(cmd,"-f")==0) { Help(); return; } if (strstr(cmd,"-o")) bModifyOptions = TRUE; // Give a LOG-thread a chance to startup InitCommonControls (); thread_spawn (logThread, "log-update", 1024*1024,0); Sleep (150); // Load project name[0]=0; sscanf (strstr(cmd,"-f")+2,"%s",name); //FS.update_path (name,"$game_levels$",name); FS.get_path ("$level$")->_set (name); CTimer dwStartupTime; dwStartupTime.Start(); xrCompiler (0); // Show statistic char stats[256]; extern std::string make_time(u32 sec); extern HWND logWindow; sprintf (stats,"Time elapsed: %s",make_time((dwStartupTime.GetElapsed_ms())/1000).c_str()); MessageBox (logWindow,stats,"Congratulation!",MB_OK|MB_ICONINFORMATION); bClose = TRUE; Sleep (500); }
static void metar_tok_time (gchar *tokp, WeatherInfo *info) { gint day, hr, min; sscanf (tokp, "%2u%2u%2u", &day, &hr, &min); info->update = make_time (day, hr, min); }
void string_format_time(char *ptr, size_t maxsize, const char *format, const PblTm *timeptr) { struct tm tm_time; make_time(timeptr, &tm_time); mktime(&tm_time); size_t actual = strftime(ptr, maxsize, format, &tm_time); if(actual == 0) printf("[WARN] strftime failed - %d:%s\n", maxsize, format); }
std::shared_ptr<ErrorContext> PlacementContentHandler::start_message( uint16_t version, uint16_t length, uint32_t export_time, uint32_t sequence_number, uint32_t observation_domain, uint64_t base_time) { LOG4CPLUS_TRACE(logger, "ENTER start_message" << ", version=" << version << ", length=" << length << ", export_time=" << make_time(export_time) << ", sequence_number=" << sequence_number << ", observation_domain=" << observation_domain << ", base_time=" << base_time); assert(current_wire_template == 0); /* At this point, we can be sure that the version is correct for * the underlying MessageStreamParser class. In other words, if * the MessageStreamParser that calls this method is an * IPFIXMessageStreamParser, then version will be equal to 10, and * so on. But still, some things don't make sense for IPFIX, for * example a nonzero base time. */ if (version == kIpfixVersion && base_time != 0) CH_REPORT_ERROR(ipfix_basetime, "Expected base_time 0 for IPFIX, got 0x" << std::hex << std::setw(4) << base_time); /* TODO: Figure out (and check for) minimal message lengths for v9 * and v5. */ if (version == kIpfixVersion && length < kIpfixMinMessageLen) CH_REPORT_ERROR(short_message, "must be at least " << kIpfixMinMessageLen << " bytes long, got only " << length); this->observation_domain = observation_domain; LOG4CPLUS_TRACE(logger, "LEAVE start_message"); return std::shared_ptr<ErrorContext>(0); }
/**************************************************** * * Dump a delimited record for each item in the * * cache to stdout. ****************************************************/ void dump_cache_users(void) { unsigned int x; struct bucket *ref_bucket; time_t epoch_to; epoch_to = time(NULL) - table_stats->timeout; fprintf(stdout, "\"user\",\"realm\",\"service\",\"created\",\"created_localtime\"\n"); for (x = 0; x < (table_stats->table_size * table_stats->max_buckets_per); x++) { ref_bucket = table + x; if (ref_bucket->created > epoch_to && *(ref_bucket->creds) != '\0') { fprintf(stderr, "\"%s\",", ref_bucket->creds + ref_bucket->user_offt); fprintf(stderr, "\"%s\",", ref_bucket->creds + ref_bucket->realm_offt); fprintf(stderr, "\"%s\",", ref_bucket->creds + ref_bucket->service_offt); fprintf(stderr, "\"%lu\",", ref_bucket->created); fprintf(stderr, "\"%s\"\n", make_time(ref_bucket->created)); } } }
void logThread(void *dummy) { SetProcessPriorityBoost (GetCurrentProcess(),TRUE); logWindow = CreateDialog( HINSTANCE(GetModuleHandle(0)), MAKEINTRESOURCE(IDD_LOG), 0, logDlgProc ); if (!logWindow) { R_CHK (GetLastError()); }; SetWindowPos(logWindow,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW); hwLog = GetDlgItem(logWindow, IDC_LOG); hwProgress = GetDlgItem(logWindow, IDC_PROGRESS); hwInfo = GetDlgItem(logWindow, IDC_INFO); hwStage = GetDlgItem(logWindow, IDC_STAGE); hwTime = GetDlgItem(logWindow, IDC_TIMING); hwPText = GetDlgItem(logWindow, IDC_P_TEXT); hwPhaseTime = GetDlgItem(logWindow, IDC_PHASE_TIME); SendMessage(hwProgress, PBM_SETRANGE, 0, MAKELPARAM(0, 1000)); SendMessage(hwProgress, PBM_SETPOS, 0, 0); Msg("\"LevelBuilder v4.1\" beta build\nCompilation date: %s\n",__DATE__); { char tmpbuf[128]; Msg("Startup time: %s",_strtime(tmpbuf)); } BOOL bHighPriority = FALSE; string256 u_name; unsigned long u_size = sizeof(u_name)-1; GetUserName (u_name,&u_size); _strlwr (u_name); if ((0==xr_strcmp(u_name,"oles"))||(0==xr_strcmp(u_name,"alexmx"))) bHighPriority = TRUE; // Main cycle u32 LogSize = 0; float PrSave = 0; while (TRUE) { SetPriorityClass (GetCurrentProcess(),IDLE_PRIORITY_CLASS); // bHighPriority?NORMAL_PRIORITY_CLASS:IDLE_PRIORITY_CLASS // transfer data while (!csLog.TryEnter()) { _process_messages ( ); Sleep (1); } if (progress>1.f) progress = 1.f; else if (progress<0) progress = 0; BOOL bWasChanges = FALSE; char tbuf [256]; csLog.Enter (); if (LogSize!=LogFile->size()) { bWasChanges = TRUE; for (; LogSize<LogFile->size(); LogSize++) { const char *S = *(*LogFile)[LogSize]; if (0==S) S = ""; SendMessage ( hwLog, LB_ADDSTRING, 0, (LPARAM) S); } SendMessage ( hwLog, LB_SETTOPINDEX, LogSize-1, 0); //FlushLog ( ); } csLog.Leave (); if (_abs(PrSave-progress)>EPS_L) { bWasChanges = TRUE; PrSave = progress; SendMessage ( hwProgress, PBM_SETPOS, u32(progress*1000.f), 0); // timing if (progress>0.005f) { u32 dwCurrentTime = timeGetTime(); u32 dwTimeDiff = dwCurrentTime-phase_start_time; u32 secElapsed = dwTimeDiff/1000; u32 secRemain = u32(float(secElapsed)/progress)-secElapsed; xr_sprintf(tbuf, "Elapsed: %s\n" "Remain: %s", make_time(secElapsed).c_str(), make_time(secRemain).c_str() ); SetWindowText ( hwTime, tbuf ); } else { SetWindowText ( hwTime, "" ); } // percentage text xr_sprintf(tbuf,"%3.2f%%",progress*100.f); SetWindowText ( hwPText, tbuf ); } if (bStatusChange) { bWasChanges = TRUE; bStatusChange = FALSE; SetWindowText ( hwInfo, status); } if (bWasChanges) { UpdateWindow ( logWindow); bWasChanges = FALSE; } csLog.Leave (); _process_messages (); if (bClose) break; Sleep (200); } // Cleanup DestroyWindow(logWindow); }
void Startup(LPSTR lpCmdLine) { char cmd[512],name[256]; BOOL bModifyOptions = FALSE; strcpy(cmd,lpCmdLine); strlwr(cmd); if (strstr(cmd,"-?") || strstr(cmd,"-h")) { Help(); return; } if (strstr(cmd,"-f")==0) { Help(); return; } if (strstr(cmd,"-o")) bModifyOptions = TRUE; if (strstr(cmd,"-gi")) b_radiosity = TRUE; if (strstr(cmd,"-noise")) b_noise = TRUE; if (strstr(cmd,"-nosun")) b_nosun = TRUE; // Give a LOG-thread a chance to startup //_set_sbh_threshold(1920); InitCommonControls (); thread_spawn (logThread, "log-update", 1024*1024,0); Sleep (150); // Faster FPU SetPriorityClass (GetCurrentProcess(),NORMAL_PRIORITY_CLASS); /* u32 dwMin = 1800*(1024*1024); u32 dwMax = 1900*(1024*1024); if (0==SetProcessWorkingSetSize(GetCurrentProcess(),dwMin,dwMax)) { clMsg("*** Failed to expand working set"); }; */ // Load project name[0]=0; sscanf(strstr(cmd,"-f")+2,"%s",name); string256 prjName; FS.update_path (prjName,"$game_levels$",strconcat(prjName,name,"\\build.prj")); string256 phaseName; Phase (strconcat(phaseName,"Reading project [",name,"]...")); string256 inf; extern HWND logWindow; IReader* F = FS.r_open(prjName); if (NULL==F){ sprintf (inf,"Build failed!\nCan't find level: '%s'",name); clMsg (inf); MessageBox (logWindow,inf,"Error!",MB_OK|MB_ICONERROR); return; } // Version u32 version; F->r_chunk (EB_Version,&version); clMsg ("version: %d",version); R_ASSERT(XRCL_CURRENT_VERSION==version); // Header b_params Params; F->r_chunk (EB_Parameters,&Params); // Show options if needed if (bModifyOptions) { Phase ("Project options..."); HMODULE L = LoadLibrary ("xrLC_Options.dll"); void* P = GetProcAddress (L,"_frmScenePropertiesRun"); R_ASSERT (P); xrOptions* O = (xrOptions*)P; int R = O(&Params,version,false); FreeLibrary (L); if (R==2) { ExitProcess(0); } } // Conversion Phase ("Converting data structures..."); pBuild = xr_new<CBuild>(); pBuild->Load (Params,*F); xr_delete (F); // Call for builder string256 lfn; CTimer dwStartupTime; dwStartupTime.Start(); FS.update_path (lfn,_game_levels_,name); pBuild->Run (lfn); xr_delete (pBuild); // Show statistic extern std::string make_time(u32 sec); u32 dwEndTime = dwStartupTime.GetElapsed_ms(); sprintf (inf,"Time elapsed: %s",make_time(dwEndTime/1000).c_str()); clMsg ("Build succesful!\n%s",inf); MessageBox (logWindow,inf,"Congratulation!",MB_OK|MB_ICONINFORMATION); // Close log bClose = TRUE; Sleep (500); }
/* ------------------------------------------------------------- * MAIN: * Check all parameters passed on the command line, calculate * the date to be displayed, and display it. * ------------------------------------------------------------- */ int main( int argc, char **argv, char **envp ) { struct tm *time_var; time_t time_number; signed long time_offset; char *ptr; int i, date_override; char saved_command[MAX_PARM_LEN+1]; char saved_format[MAX_MASK_LEN+1]; char saved_startdate_override[13]; /* YYYYMMDDHHMM_ */ /* * Check to see what command line parameters we have */ if (argc < 2) { printf( "%s: (c)Mark Dickinson, 2001\n", argv[0] ); show_syntax(); exit( 1 ); } time_offset = 0; /* default, and start point for adjustments */ date_override = 0; /* use current system date and time */ strcpy(saved_format,"YYYYMMDD"); /* default */ i = 1; /* use a while loop instead of a for loop as we may * increment the counter ourselves */ while ( i < argc ) { ptr = argv[i]; i++; if (i >= argc) { printf( "Missing value for %s\n", ptr ); exit( 1 ); } strncpy( saved_command, ptr, MAX_PARM_LEN ); ptr = argv[i]; if (strncmp("-format",saved_command,7) == 0) { validate_format( ptr, saved_format ); } else if (strncmp("-workingdate",saved_command,12) == 0) { date_override = 1; strncpy( saved_startdate_override, ptr, 12 ); /* YYYYMMDDHHMM */ } else { time_offset = time_offset + check_parameter( saved_command, ptr ); } i++; } /* * Work out the new time and print the result. */ if (date_override == 1) { /* have to get the dst flag setting for this */ time_number = time(0); time_var = localtime( &time_number ); /* then workout the callers passed time */ time_number = make_time( (char *)&saved_startdate_override, time_var->tm_isdst ); } else { time_number = time(0); /* time now in seconds from 00:00, Jan 1 1970 */ } time_number = time_number + time_offset; if (strcmp("CTIME",saved_format) == 0) { printf( "%s", ctime( &time_number ) ); } else { time_var = localtime( &time_number ); print_time( time_var, saved_format ); } exit( 0 ); } /* end main */
void execute_time_statistics::log ()const { string64 buf; Msg( "calc time: %s ", make_time( buf, m_time ) ); }