C++ (Cpp) time Examples

C++ (Cpp) time - 30 examples found. These are the top rated real world C++ (Cpp) examples of time extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
void do_default(void)
{
    fprintf(stderr, "wait for low-LA ...\n");

    while (1)
    {
        short la = osval_loadavg();
        if (la < 50)
        {
            break;
        }

        fprintf(stderr, "%d ", la);

        sleep(3);
    }

    fprintf(stderr, "\ndone\n");

    time_t start = time(NULL);

    main_proc();

    time_t end = time(NULL);

    fprintf(stderr, "elapsed %ld sec\n", end - start);
}
Example #2
0
/* single core version: compute better solutions for T seconds */
void driver(graph_t *g, int n, int k, double p, double tol, long maxsec)
{

    int np, rank, new_rank = 0, stop;

    double *fits;
    int *allsets;
    time_t start;

    srand(time(NULL));

    problem_t problem;
    problem.graph = g;
    problem.distance = NULL;
    problem.round = 0;

    double fit;

    int s[n];
    gen_starting_set(n, k, s);

    start = time(0);
    do {
        int u, v;

        fit = get_next_state_graph(&problem, n, s, k, p, &u, &v, run);

        if (u >= 0)
            s[u] = 0;
        if (v >= 0)
            s[v] = 1;
    } while(difftime(time(0), start) < maxsec);

    return fit;
}
Example #3
0
void gecko_iteration(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,int32_t maxmillis)
{
    char mineraddr[64];
    int32_t hwmhdrsi,longesthdrsi;
    struct iguana_bundle *bp;
    hwmhdrsi = virt->blocks.hwmchain.height / virt->chain->bundlesize;
    longesthdrsi = virt->longestchain / virt->chain->bundlesize;
    if ( (bp= virt->bundles[hwmhdrsi]) != 0 )
    {
        //iguana_RTspendvectors(myinfo,virt,bp);
        //iguana_RTramchainalloc("RTbundle",virt,bp);
        //iguana_update_balances(virt);
        //iguana_realtime_update(myinfo,virt);
    }
    if ( 0 && hwmhdrsi <= longesthdrsi )//&& virt->blocks.hwmchain.height < virt->longestchain-1 )
    {
        if ( time(NULL) > virt->hdrstime+3 )
        {
            fprintf(stderr,"request %s headers\n",virt->symbol);
            gecko_requesthdrs(myinfo,virt,hwmhdrsi);
            //fprintf(stderr,"R");
            virt->hdrstime = (uint32_t)time(NULL);
        }
    }
    if ( 0 && btcd->FULLNODE != 0 )//&& virt->blocks.hwmchain.height >= virt->longestchain-virt->chain->bundlesize )
    {
        bitcoin_address(mineraddr,virt->chain->pubtype,myinfo->persistent_pubkey33,33);
        //fprintf(stderr,"mine.%s %s\n",virt->symbol,mineraddr);
        gecko_miner(myinfo,btcd,virt,maxmillis,myinfo->persistent_pubkey33);
    }
}
Example #4
0
// called whenever we need to open/close/check the console log file
void Sys_LogFile(bool enable)
{
    if (enable && !g_hLogFile)
    {
        // settings say we should be logging and we don't have a log file .. so create it
        // open a file to log the console (if user prefs say so)
        // the file handle is g_hLogFile
        // the log file is erased
        StringOutputStream name(256);
        name << SettingsPath_get() << "radiant.log";
        g_hLogFile = fopen( name.c_str(), "w" );
        if (g_hLogFile != 0)
        {
            globalOutputStream() << "Started logging to " << name.c_str() << "\n";
            time_t localtime;
            time(&localtime);
            globalOutputStream() << "Today is: " << ctime(&localtime)
                                 << "This is GtkRadiant '" RADIANT_VERSION "' compiled " __DATE__ "\n" RADIANT_ABOUTMSG "\n";
        }
        else
            gtk_MessageBox (0, "Failed to create log file, check write permissions in Radiant directory.\n",
                            "Console logging", eMB_OK, eMB_ICONERROR );
    }
    else if (!enable && g_hLogFile != 0)
    {
        // settings say we should not be logging but still we have an active logfile .. close it
        time_t localtime;
        time(&localtime);
        globalOutputStream() << "Closing log file at " << ctime(&localtime) << "\n";
        fclose( g_hLogFile );
        g_hLogFile = 0;
    }
}
Example #5
0
void PackerJob::updateStats()
{
    DWORD dwNewTick = GetTickCount();
    if (this->uiReaded && (time(NULL) > this->startTS) && (dwNewTick > this->lastUpdateTick + 100))
    {
        this->lastUpdateTick = dwNewTick;

        double speed = ((double)this->uiReaded / 1024)/(time(NULL) - this->startTS);
        mir_sntprintf(this->tab->stzSpeed, _countof(this->tab->stzSpeed), TranslateT("%0.1f kB/s"), speed);

        double perc = this->uiFileSize ? ((double)this->uiReaded / this->uiFileSize) * 100 : 0;
        mir_sntprintf(this->tab->stzComplet, _countof(this->tab->stzComplet), TranslateT("%0.1f%% (%d kB/%d kB)"), perc, (int)this->uiReaded/1024, (int)this->uiFileSize/1024);

        TCHAR buff[256];
        long s = (this->uiFileSize - this->uiReaded) / (long)(speed * 1024);
        int d = (s / 60 / 60 / 24);
        int h = (s - d * 60 * 60 * 24) / 60 / 60;
        int m = (s  - d * 60 * 60 * 24 - h * 60 * 60) / 60;
        s = s - (d * 24 * 60 * 60) - (h * 60 * 60) - (m * 60);

        if (d > 0) mir_sntprintf(buff, _T("%dd %02d:%02d:%02d"), d, h, m, s);
        else mir_sntprintf(buff, _T("%02d:%02d:%02d"), h, m, s);
        mir_sntprintf(this->tab->stzRemain, _countof(this->tab->stzRemain), TranslateT("%s (%d kB/%d kB)"), buff, (this->uiFileSize - this->uiReaded)/1024, this->uiFileSize/1024);

        this->refreshTab(false);
    }
}
Example #6
0
void WorldSession::SendQueryTimeResponse()
{
    WorldPacket data(SMSG_QUERY_TIME_RESPONSE, 4 + 4);
    data << uint32(time(nullptr));
    data << uint32(sWorld.GetNextDailyQuestsResetTime() - time(nullptr));
    SendPacket(&data);
}