当前位置: 首页>>代码示例>>C++>>正文


C++ dtime函数代码示例

本文整理汇总了C++中dtime函数的典型用法代码示例。如果您正苦于以下问题:C++ dtime函数的具体用法?C++ dtime怎么用?C++ dtime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dtime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: handle_request

void handle_request(FILE* fin, FILE* fout, char* code_sign_key) {
    SCHEDULER_REQUEST sreq;
    SCHEDULER_REPLY sreply;
    char buf[1024];

    g_request = &sreq;
    g_reply = &sreply;
    g_wreq = &sreply.wreq;

    sreply.nucleus_only = true;

    log_messages.set_indent_level(1);

    MIOFILE mf;
    XML_PARSER xp(&mf);
    mf.init_file(fin);
    const char* p = sreq.parse(xp);
    double start_time = dtime();
    if (!p){
        process_request(code_sign_key);

        if ((config.locality_scheduling || config.locality_scheduler_fraction) && !sreply.nucleus_only) {
            send_file_deletes();
        }
    } else {
        sprintf(buf, "Error in request message: %s", p);
        log_incomplete_request();
        sreply.insert_message(buf, "low");
    }

    if (config.debug_user_messages) {
        log_user_messages();
    }

    sreply.write(fout, sreq);
    log_messages.printf(MSG_NORMAL,
        "Scheduler ran %.3f seconds\n", dtime()-start_time
    );

    if (strlen(config.sched_lockfile_dir)) {
        unlock_sched();
    }
}
开发者ID:FpgaAtHome,项目名称:seti_fpga,代码行数:43,代码来源:handle_request.cpp

示例2: calloc

static lcc_value_list_t *create_value_list (void) /* {{{ */
{
  lcc_value_list_t *vl;
  int host_num;

  vl = calloc (1, sizeof (*vl));
  if (vl == NULL)
  {
    fprintf (stderr, "calloc failed.\n");
    return (NULL);
  }

  vl->values = calloc (/* nmemb = */ 1, sizeof (*vl->values));
  if (vl->values == NULL)
  {
    fprintf (stderr, "calloc failed.\n");
    free (vl);
    return (NULL);
  }

  vl->values_types = calloc (/* nmemb = */ 1, sizeof (*vl->values_types));
  if (vl->values_types == NULL)
  {
    fprintf (stderr, "calloc failed.\n");
    free (vl->values);
    free (vl);
    return (NULL);
  }

  vl->values_len = 1;

  host_num = get_boundet_random (0, conf_num_hosts);

  vl->interval = conf_interval;
  vl->time = 1.0 + dtime ()
    + (host_num % (1 + (int) vl->interval));

  if (get_boundet_random (0, 2) == 0)
    vl->values_types[0] = LCC_TYPE_GAUGE;
  else
    vl->values_types[0] = LCC_TYPE_DERIVE;

  snprintf (vl->identifier.host, sizeof (vl->identifier.host),
      "host%04i", host_num);
  snprintf (vl->identifier.plugin, sizeof (vl->identifier.plugin),
      "plugin%03i", get_boundet_random (0, conf_num_plugins));
  strncpy (vl->identifier.type,
      (vl->values_types[0] == LCC_TYPE_GAUGE) ? "gauge" : "derive",
      sizeof (vl->identifier.type));
  vl->identifier.type[sizeof (vl->identifier.type) - 1] = 0;
  snprintf (vl->identifier.type_instance, sizeof (vl->identifier.type_instance),
      "ti%li", random ());

  return (vl);
} /* }}} int create_value_list */
开发者ID:beorn-,项目名称:collectd,代码行数:55,代码来源:collectd-tg.c

示例3: main

// add your sensor class below, i.e. CSensorTest
int main(int argc, char** argv)
{
    const float RUN_SECONDS = 100.0f; // how many seconds to run -- max is 200 seconds (or bump up MAXI in define.h to RUN_SECONDS / DT )

    int iRetVal = 0, iErrCnt = 0;
    sm = new CQCNShMem();

    CSensorLinuxUSBONavi sms;

    if (sms.detect()) {
       double tstart = dtime(), tend;
       // initialize timers
       sm->t0active = tstart; // use the function in boinc/lib
       sm->t0check = sm->t0active + sm->dt;

       // MySQL
       sms.connectDatabase();

       // assuming we're at 50Hz, run 500 times for 10 seconds of output, note array only holds 10,000 so don't go past that!
			 //sm->lOffset++;	//debug
       //for (sm->lOffset = 0; sm->lOffset < (int) (RUN_SECONDS / DT); sm->lOffset++) {	//debug
       while(true){
           if (!sms.mean_xyz(true)) iErrCnt++;   // pass in true for verbose output, false for silent
       }

       tend = dtime();
       fprintf(stdout, "%f seconds of samples read from %f to %f in %f seconds real time -- error of %3.3f %c\n"
               "%d Timing Errors Encountered\n",
	  RUN_SECONDS, tstart, tend, tend - tstart, ((RUN_SECONDS - (tend - tstart)) / RUN_SECONDS) * 100.0f, '%', iErrCnt);
    }
    else {
       fprintf(stdout, "No sensor detected!\n");
       iRetVal = 1;
    }

    if (sm) {
        delete sm;
        sm = NULL;
    }

    return iRetVal;
}
开发者ID:hirokiu,项目名称:csn_raspi,代码行数:43,代码来源:main.cpp

示例4: test_equalizer_chain_pth

void test_equalizer_chain_pth(LTE_PHY_PARAMS *lte_phy_params)
{
	double tstart, tend, ttime;
	
	GeneRandomInput((lte_phy_params + 0)->ofdemod_in, (lte_phy_params + 0)->ofdemod_in_buf_sz, "./testsuite/SubCarrierMapInputReal", "./testsuite/SubCarrierMapInputImag");
	GeneRandomInput((lte_phy_params + 1)->ofdemod_in, (lte_phy_params + 1)->ofdemod_in_buf_sz, "./testsuite/SubCarrierMapInputReal", "./testsuite/SubCarrierMapInputImag");
	GeneRandomInput((lte_phy_params + 2)->ofdemod_in, (lte_phy_params + 2)->ofdemod_in_buf_sz, "./testsuite/SubCarrierMapInputReal", "./testsuite/SubCarrierMapInputImag");

	tstart = dtime();
	
	equalizer_chain_pth(lte_phy_params);

	tend = dtime();
	ttime = tend - tstart;
	printf("%.3fms\n", ttime);

	WriteOutputToFiles((lte_phy_params + 0)->eq_out, (lte_phy_params + 0)->eq_out_buf_sz, "./testsuite/testLSCELSEqOutputReal", "./testsuite/testLSCELSEqOutputImag");
	WriteOutputToFiles((lte_phy_params + 1)->eq_out, (lte_phy_params + 1)->eq_out_buf_sz, "./testsuite/testLSCELSEqOutputReal", "./testsuite/testLSCELSEqOutputImag");
	WriteOutputToFiles((lte_phy_params + 2)->eq_out, (lte_phy_params + 2)->eq_out_buf_sz, "./testsuite/testLSCELSEqOutputReal", "./testsuite/testLSCELSEqOutputImag");
}
开发者ID:troore,项目名称:unico,代码行数:20,代码来源:test.cpp

示例5: timer_handler

static VOID CALLBACK timer_handler(HWND, UINT, UINT, DWORD) {
    RECT rt;
    int width, height;
    char buf[MSG_CHANNEL_SIZE];
	if (g_sleep) return;

    // check for graphics-related message from core client
    //
    if (app_client_shm) {
        if (app_client_shm->shm->graphics_request.get_msg(buf)) {
            BOINCINFO("Received Graphics Message: %s", buf);
            app_client_shm->decode_graphics_msg(buf, graphics_msg);
            switch (graphics_msg.mode) {
            case MODE_REREAD_PREFS:
                // only reread graphics prefs if we have a window open
                //
                switch(current_graphics_mode) {
                case MODE_WINDOW:
                case MODE_FULLSCREEN:
                    app_graphics_reread_prefs();
                    break;
                }
                break;
            case MODE_HIDE_GRAPHICS:
            case MODE_WINDOW:
            case MODE_FULLSCREEN:
            case MODE_BLANKSCREEN:
                set_mode(graphics_msg.mode);
                break;
            }
        }
        // ack graphics mode
        //
        if (acked_graphics_mode != current_graphics_mode) {
            bool sent = app_client_shm->shm->graphics_reply.send_msg(
                xml_graphics_modes[current_graphics_mode]
            );
            if (sent) acked_graphics_mode = current_graphics_mode;
        }
    }
    if (!visible) return;
    if (current_graphics_mode == MODE_HIDE_GRAPHICS) return;
    if (!hWnd) return;

    // TODO: remove width, height from API
    //
    GetClientRect(hWnd, &rt);
    width = rt.right-rt.left;
    height = rt.bottom-rt.top;

    if (throttled_app_render(width, height, dtime())) {
        SwapBuffers(hDC);
    }
}
开发者ID:drshawnkwang,项目名称:boinc,代码行数:54,代码来源:windows_opengl.cpp

示例6: callback

void callback(struct libusb_transfer *xfr) {
	if (xfr->status!=LIBUSB_TRANSFER_COMPLETED) {
		fprintf(stderr,"Transfer failed: %d\n",xfr->status);
		exit(1);
	}
	transfer(xfr);

	total += xfr->length;
	double rate = total/(dtime()-t);
	fprintf(stderr,"%10d %lf\n",total,rate);
}
开发者ID:amcinnes,项目名称:uc_am_xmit,代码行数:11,代码来源:write.c

示例7: bucketsort

int bucketsort(void **a, size_t n, keyaccessor_t key, indexer_t idx,
	       comparator_t cmp)
{
    _cons_t *lists = (_cons_t *) malloc(n * sizeof(_cons_t));
    if (!lists) {
	perror("malloc failed!");
	return -1;
    }
    #if BUCKETSORT_PROFILE
    when = dtime(); array2list(a, lists, n); ptime();
    when = dtime(); list_t l = bucketsort_l(lists, key, idx, cmp); ptime();
    when = dtime(); list2array(l, a, n); ptime();
    #else
    array2list(a, lists, n);
    list_t l = bucketsort_l(lists, key, idx, cmp);
    list2array(l, a, n);
    #endif
    free(lists);
    return 0;
}
开发者ID:dankogai,项目名称:c-bucketsort,代码行数:20,代码来源:bucketsort.c

示例8: delete_project_owned_file

/// Delete the file located at path.
/// If "retry" is set, do retries for 5 sec in case some
/// other program (e.g. virus checker) has the file locked.
/// Don't do this if deleting directories - it can lock up the Manager.
///
/// \param[in] path The path name of the file that should be deleted.
/// \param[in] retry If true this function will try to delete the file
///                  multiple times if the first attempt failed.
/// \return Zero on success, ERR_UNLINK on error.
int delete_project_owned_file(const char* path, bool retry) {
    int retval = 0;

    if (!boinc_file_or_symlink_exists(path)) {
        return 0;
    }
    retval = delete_project_owned_file_aux(path);
    if (retval && retry) {
        double start = dtime();
        do {
            boinc_sleep(drand() * 2.0);       // avoid lockstep
            retval = delete_project_owned_file_aux(path);
            if (!retval) break;
        } while (dtime() < start + FILE_RETRY_INTERVAL);
    }
    if (retval) {
        safe_strcpy(boinc_failed_file, path);
        return ERR_UNLINK;
    }
    return 0;
}
开发者ID:phenix3443,项目名称:synecdoche,代码行数:30,代码来源:sandbox.C

示例9: FD_ZERO

int RPC_CLIENT::init_poll() {
    fd_set read_fds, write_fds, error_fds;
    struct timeval tv;
    int retval;

    FD_ZERO(&read_fds);
    FD_ZERO(&write_fds);
    FD_ZERO(&error_fds);

    FD_SET(sock, &read_fds);
    FD_SET(sock, &write_fds);
    FD_SET(sock, &error_fds);

    BOINCTRACE("RPC_CLIENT::init_poll sock = %d\n", sock);

    tv.tv_sec = tv.tv_usec = 0;
    select(FD_SETSIZE, &read_fds, &write_fds, &error_fds, &tv);
    retval = 0;
    if (FD_ISSET(sock, &error_fds)) {
        retval =  ERR_CONNECT;
    } else if (FD_ISSET(sock, &write_fds)) {
        retval = get_socket_error(sock);
        if (!retval) {
            BOINCTRACE("RPC_CLIENT::init_poll connected to port %d\n", ntohs(addr.sin_port));
            retval = boinc_socket_asynch(sock, false);
            if (retval) {
                BOINCTRACE("asynch error: %d\n", retval);
                return retval;
            }
            return 0;
        } else {
            BOINCTRACE("init_poll: get_socket_error(): %d\n", retval);
        }
    }
    if (dtime() > start_time + timeout) {
        BOINCTRACE("RPC_CLIENT init timed out\n");
        return ERR_CONNECT;
    }
    if (retval) {
        if (retry) {
            boinc_close_socket(sock);
            retval = boinc_socket(sock);
            retval = boinc_socket_asynch(sock, true);
            retval = connect(sock, (const sockaddr*)(&addr), sizeof(addr));
            BOINCTRACE("RPC_CLIENT::init_poll attempting connect\n");
            return ERR_RETRY;
        } else {
            return ERR_CONNECT;
        }
    }
    return ERR_RETRY;
}
开发者ID:phenix3443,项目名称:synecdoche,代码行数:52,代码来源:gui_rpc_client.C

示例10: main_loop

void main_loop() {
    int retval;
    int node=0,n;
    while (node<n1) {
        check_stop_daemons();
	retval = count_unsent_results(n, 0);
        if (retval) {
            log_messages.printf(MSG_CRITICAL,
                "count_unsent_jobs() failed: %s\n", boincerror(retval)
            );
            exit(retval);
        }
        if (n > CUSHION) {
            daemon_sleep(5);
        } else {

          //  int njobs =  (CUSHION-n)/REPLICATION_FACTOR;
            log_messages.printf(MSG_DEBUG,
                "Making job for %d\n", node
            );
      //      for (int i=0; i<njobs; i++) {
      	      for (int i=0; i<n1; i+=CLIENT_LIMIT)
      	      {
                retval = make_job(node,i);
                if (retval) {
                    log_messages.printf(MSG_CRITICAL,
                        "can't make job: %s\n", boincerror(retval)
                    );
                    exit(retval);
                }
      	      }
   //         }
            // Now sleep for a few seconds to let the transitioner
            // create instances for the jobs we just created.
            // Otherwise we could end up creating an excess of jobs.
            double now = dtime();
            while (1) {
                daemon_sleep(5);
                double x;
                retval = min_transition_time(x);
                if (retval) {
                    log_messages.printf(MSG_CRITICAL,
                        "min_transition_time failed: %s\n", boincerror(retval)
                    );
                    exit(retval);
                }
                if (x > now) break;
            }
        }
        node++;
    }
}
开发者ID:godlytalias,项目名称:BOINC,代码行数:52,代码来源:work_generator.cpp

示例11: tx_rate_matching

void tx_rate_matching(LTE_PHY_PARAMS *lte_phy_params)
{
	std::cout << "Tx RateMatching starts" << std::endl;

	//ReadInputFromFiles(lte_phy_params->rm_in, lte_phy_params->rm_in_buf_sz, "../testsuite/RandomTxRateMatchInput");
	GeneRandomInput(lte_phy_params->rm_in, lte_phy_params->rm_in_buf_sz, "/root/RateMatching/testsuite/RandomTxRateMatchInput");
	TxRateMatching(lte_phy_params, lte_phy_params->rm_in, lte_phy_params->rm_out);
	double energy,ttime,tbegin;
	micpower_start();
	tbegin = dtime();
	for(int i=0;i<10000;i++)
		TxRateMatching(lte_phy_params, lte_phy_params->rm_in, lte_phy_params->rm_out);
	ttime = dtime() - tbegin;
	energy = micpower_finalize();
//	printf("Energy used in %lf\n", energy);
//	printf("whole time is %fms\n", ttime);
	printf("%lf\t%f\t%f\n", energy, ttime, (energy * 1000.0) / ttime);
	
	WriteOutputToFiles(lte_phy_params->rm_out, lte_phy_params->rm_out_buf_sz, "/root/RateMatching/testsuite/testTxRateMatchOutput");

	std::cout << "Tx RateMatching ends" << std::endl;
}
开发者ID:troore,项目名称:ParWiBench,代码行数:22,代码来源:test.cpp

示例12: test_turbo_decoding

void test_turbo_decoding(LTE_PHY_PARAMS *lte_phy_params, int n_log_decoder_iters)
{
	std::cout << "Turbo Decoder starts" << std::endl;
	
	ReadInputFromFiles(lte_phy_params->td_in, lte_phy_params->td_in_buf_sz, "../testsuite/testTurboEncoderOutput");
	
	for (int i = 0; i < lte_phy_params->td_in_buf_sz; i++)
	{
		lte_phy_params->td_in[i] = (1 - 2 * lte_phy_params->td_in[i]);
	}

	double tstart, tend, ttime;
	double n_gflops, gflops;

	tstart = dtime();

	int n_test_iters = 1;
	for (int i = 0; i < n_test_iters; i++)
	{
	turbo_decoding(lte_phy_params, lte_phy_params->td_in, lte_phy_params->td_out, n_log_decoder_iters);
	}

	tend = dtime();
	ttime = tend - tstart;
	n_gflops = n_test_iters * gflop_counter(lte_phy_params);
	gflops = (n_gflops * 10e3) / ttime;
//	printf("%fms\n", ttime);
//	printf("Number of gflops = %lf\n", n_gflops);
//	printf("GFlops = %f\n", gflops);

	for (int i = 0; i < lte_phy_params->td_out_buf_sz; i++)
	{
		lte_phy_params->td_out[i] = (1 - lte_phy_params->td_out[i]) / 2;
	}
	
	WriteOutputToFiles(lte_phy_params->td_out, lte_phy_params->td_out_buf_sz, "../testsuite/testTurboDecoderOutput");
	
	std::cout << "Turbo Decoder ends" << std::endl;
}
开发者ID:troore,项目名称:ParWiBench,代码行数:39,代码来源:test.cpp

示例13: defaults

void GLOBAL_PREFS::parse(const char* buf, const char* venue) {
    char buf2[BLOB_SIZE];
    double dtemp;

    defaults();

    if (parse_double(buf, "<mod_time>", mod_time)) {
        // mod_time is outside of venue
        if (mod_time > dtime()) mod_time = dtime();
    }
    extract_venue(buf, venue, buf2);
    parse_double(buf2, "<disk_max_used_gb>", disk_max_used_gb);
    parse_double(buf2, "<disk_max_used_pct>", disk_max_used_pct);
    parse_double(buf2, "<disk_min_free_gb>", disk_min_free_gb);
    parse_double(buf2, "<work_buf_min_days>", work_buf_min_days);
    if (parse_double(buf2, "<ram_max_used_busy_pct>", dtemp)) {
        ram_max_used_busy_frac = dtemp/100.;
    }
    if (parse_double(buf2, "<ram_max_used_idle_pct>", dtemp)) {
        ram_max_used_idle_frac = dtemp/100.;
    }
    parse_double(buf2, "<max_ncpus_pct>", max_ncpus_pct);
}
开发者ID:freehal,项目名称:boinc-freehal,代码行数:23,代码来源:sched_types.cpp

示例14: writefile

void writefile () {
	if (!activevents) errx(1,"Internal error");
	E("write", write(1, header, sizeof(header)));
	struct timeval lastime = events[0].time;
	int remain = activevents;
	for (ME* cur = events; remain; remain--, cur++) {
		write_variable_length_quantity(dtime(lastime, cur->time));
		lastime = cur->time;
		mm_write(1, &cur->m); }
	E("write", write(1, trailer, sizeof(trailer)));
	off_t ending_offset;
 	E("lseek", (ending_offset = lseek(1, 0, SEEK_CUR)));
	E("lseek", lseek(1, 18, SEEK_SET));
	write_four_byte_int(ending_offset - sizeof(header), 1); }
开发者ID:bsummer4,项目名称:midiutils,代码行数:14,代码来源:brainstorm.c

示例15: main_loop

void main_loop() {
    int retval;

    while (1) {
        check_stop_daemons();
        long n;
        retval = count_unsent_results(n, app.id);
        if (retval) {
            log_messages.printf(MSG_CRITICAL,
                "count_unsent_jobs() failed: %s\n", boincerror(retval)
            );
            exit(retval);
        }
        if (n > CUSHION) {
            daemon_sleep(10);
        } else {
            int njobs = (CUSHION-n)/REPLICATION_FACTOR;
            log_messages.printf(MSG_DEBUG,
                "Making %d jobs\n", njobs
            );
            for (int i=0; i<njobs; i++) {
                retval = make_job();
                if (retval) {
                    log_messages.printf(MSG_CRITICAL,
                        "can't make job: %s\n", boincerror(retval)
                    );
                    exit(retval);
                }
            }
            // Wait for the transitioner to create instances
            // of the jobs we just created.
            // Otherwise we'll create too many jobs.
            //
            double now = dtime();
            while (1) {
                daemon_sleep(5);
                double x;
                retval = min_transition_time(x);
                if (retval) {
                    log_messages.printf(MSG_CRITICAL,
                        "min_transition_time failed: %s\n", boincerror(retval)
                    );
                    exit(retval);
                }
                if (x > now) break;
            }
        }
    }
}
开发者ID:WilliamStilte,项目名称:boinc,代码行数:49,代码来源:sample_work_generator.cpp


注:本文中的dtime函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。