您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ timeval_diff函数代码示例

51自学网 2021-06-03 08:52:05
  C++
这篇教程C++ timeval_diff函数代码示例写得很实用,希望能帮到您。

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

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

示例1: IOSIG_posix_write_log

/* * Format: OPER, FD, POS, SIZE, T1, T2, [PATH] */void IOSIG_posix_write_log (const char * operation, int fildes, off64_t position,         size_t size, struct timeval * start, struct timeval * end,         const char * path) {    //return;    struct timeval diffstart, diffend;    timeval_diff(&diffstart, start, &bigbang);    timeval_diff(&diffend, end, &bigbang);    /* Format: OPEN, file_path, position, size, time1, time2 */    //pthread_mutex_lock(&posix_fp_mutex);    if (path) {        sprintf(posix_logtext, "%-10s %3d %6ld %6ld %4ld.%06ld %4ld.%06ld %s/n",                 operation, fildes, position, size,                (long) diffstart.tv_sec, (long) diffstart.tv_usec,                 (long) diffend.tv_sec, (long) diffend.tv_usec, path);        __real_fwrite(posix_logtext, strlen(posix_logtext), 1, posix_fp);    } else {        sprintf(posix_logtext, "%-10s %3d %6ld %6ld %4ld.%06ld %4ld.%06ld -/n",                 operation, fildes, position, size,                (long) diffstart.tv_sec, (long) diffstart.tv_usec,                 (long)diffend.tv_sec, (long) diffend.tv_usec);        __real_fwrite(posix_logtext, strlen(posix_logtext), 1, posix_fp);    }    //pthread_mutex_unlock(&posix_fp_mutex);}
开发者ID:yinyanlong,项目名称:iosig,代码行数:28,


示例2: hello_send

void hello_send(void *arg){	RREP *rrep;	u8_t flags = 0;	struct in_addr dest;	struct timeval now;	long time_diff;		gettimeofday(&now, NULL);	if(timeval_diff(&now, &this_host.last_forward_time) > ACTIVE_ROUTE_TIMEOUT)	{		hello_stop();		return;	}	time_diff = timeval_diff(&now, &this_host.last_broadcast_time);	if(time_diff >= HELLO_INTERVAL)	{		rrep = rrep_create(flags, 0, 0, this_host.dev.ipaddr, this_host.seqno, this_host.dev.ipaddr, ALLOWED_HELLO_LOSS * HELLO_INTERVAL);	/////////No ext				dest.s_addr = AODV_BROADCAST;		aodv_socket_send((AODV_msg *)rrep, dest, RREP_SIZE, 1, &this_host.dev);		timer_set_timeout(&hello_timer, HELLO_INTERVAL);	}	else	{		timer_set_timeout(&hello_timer, HELLO_INTERVAL - time_diff);	}}
开发者ID:lvniqi,项目名称:aodv,代码行数:34,


示例3: print_times

/* *	print_times -- Print absolute and delta time for debugging * *	Inputs: * *	None. * *	Returns: * *	None. * *	This function is only used for debugging.  It should not be called *	from production code. */voidprint_times(void) {   static struct timeval time_first;    /* When print_times() was first called */   static struct timeval time_last;     /* When print_times() was last called */   static int first_call=1;   struct timeval time_now;   struct timeval time_delta1;   struct timeval time_delta2;   Gettimeofday(&time_now);   if (first_call) {      first_call=0;      time_first.tv_sec  = time_now.tv_sec;      time_first.tv_usec = time_now.tv_usec;      printf("%lu.%.6lu (0.000000) [0.000000]/n",             (unsigned long)time_now.tv_sec, (unsigned long)time_now.tv_usec);   } else {      timeval_diff(&time_now, &time_last, &time_delta1);      timeval_diff(&time_now, &time_first, &time_delta2);      printf("%lu.%.6lu (%lu.%.6lu) [%lu.%.6lu]/n",             (unsigned long)time_now.tv_sec,             (unsigned long)time_now.tv_usec,             (unsigned long)time_delta1.tv_sec,             (unsigned long)time_delta1.tv_usec,             (unsigned long)time_delta2.tv_sec,             (unsigned long)time_delta2.tv_usec);   }   time_last.tv_sec  = time_now.tv_sec;   time_last.tv_usec = time_now.tv_usec;}
开发者ID:chriskoli,项目名称:tcp-scan,代码行数:45,


示例4: camera_connect

pslr_handle_t camera_connect( char *model, char *device, int timeout, char *error_message ) {    struct timeval prev_time;    struct timeval current_time;    pslr_handle_t camhandle;    int r;    gettimeofday(&prev_time, NULL);    while (!(camhandle = pslr_init( model, device ))) {        gettimeofday(&current_time, NULL);        DPRINT("diff: %f/n", timeval_diff(&current_time, &prev_time) / 1000000.0);        if( timeout == 0 || timeout > timeval_diff(&current_time, &prev_time) / 1000000.0 ) {          DPRINT("sleep 1 sec/n");          sleep_sec(1);        } else {          snprintf(error_message, 1000, "%d %ds timeout exceeded/n", 1, timeout);          return NULL;        }    }    DPRINT("before connect/n");    if (camhandle) {      if ((r=pslr_connect(camhandle)) ) {          if( r != -1 ) {            snprintf(error_message, 1000, "%d Cannot connect to Pentax camera. Please start the program as root./n",1);          } else {            snprintf(error_message, 1000, "%d Unknown Pentax camera found./n",1);          }          return NULL;        }    }    return camhandle;}
开发者ID:asalamon74,项目名称:pktriggercord,代码行数:32,


示例5: gettimeofday

void OTExtensionWithMatrix::transfer(int nOTs,        const BitVector& receiverInput){#ifdef OTEXT_TIMER    timeval totalstartv, totalendv;    gettimeofday(&totalstartv, NULL);#endif    cout << "/tDoing " << nOTs << " extended OTs as " << role_to_str(ot_role) << endl;    // resize to account for extra k OTs that are discarded    BitVector newReceiverInput(nOTs);    for (unsigned int i = 0; i < receiverInput.size_bytes(); i++)    {        newReceiverInput.set_byte(i, receiverInput.get_byte(i));    }    for (int loop = 0; loop < nloops; loop++)    {        extend<gf2n>(nOTs, newReceiverInput);#ifdef OTEXT_TIMER        gettimeofday(&totalendv, NULL);        double elapsed = timeval_diff(&totalstartv, &totalendv);        cout << "/t/tTotal thread time: " << elapsed/1000000 << endl << flush;#endif    }#ifdef OTEXT_TIMER    gettimeofday(&totalendv, NULL);    times["Total thread"] +=  timeval_diff(&totalstartv, &totalendv);#endif}
开发者ID:lance6716,项目名称:SPDZ-2,代码行数:31,


示例6: stats_new_thread

/* * Called by main thread only (in fact in tftpd_receive_request(), but * before stdin_mutex is released) every time a new thread is created. * We record the number of thread, the number of simultaeous thread, the * between threads. */void stats_new_thread(int number_of_thread){     struct timeval tmp;     if (number_of_thread > s_stats.max_simul_threads)          s_stats.max_simul_threads = number_of_thread;     /* calculate the arrival time of this thread */     if (s_stats.prev_time.tv_sec != 0)     {          gettimeofday(&s_stats.curr_time, NULL);          timeval_diff(&s_stats.diff_time, &s_stats.curr_time,                       &s_stats.prev_time);          if (timeval_diff(&tmp, &s_stats.diff_time,                           &s_stats.min_time) < 0)               memcpy(&s_stats.min_time, &s_stats.diff_time,                      sizeof(struct timeval));          if (timeval_diff(&tmp, &s_stats.diff_time,                           &s_stats.max_time) > 0)               memcpy(&s_stats.max_time, &s_stats.diff_time,                      sizeof(struct timeval));          memcpy(&s_stats.prev_time, &s_stats.curr_time,                 sizeof(struct timeval));     }     else          gettimeofday(&s_stats.prev_time, NULL);}
开发者ID:DonCN,项目名称:haiku,代码行数:33,


示例7: h_os

void OTExtensionWithMatrix::hash_outputs(int nOTs){    //cout << "Hashing... " << flush;    octetStream os, h_os(HASH_SIZE);    square128 tmp;    MMO mmo;#ifdef OTEXT_TIMER    timeval startv, endv;    gettimeofday(&startv, NULL);#endif    for (int i = 0; i < nOTs / 128; i++)    {        if (ot_role & SENDER)        {            tmp = senderOutputMatrices[0].squares[i];            tmp ^= baseReceiverInput;            senderOutputMatrices[0].squares[i].hash_row_wise<T>(mmo, senderOutputMatrices[0].squares[i]);            senderOutputMatrices[1].squares[i].hash_row_wise<T>(mmo, tmp);        }        if (ot_role & RECEIVER)        {            receiverOutputMatrix.squares[i].hash_row_wise<T>(mmo, receiverOutputMatrix.squares[i]);        }    }    //cout << "done./n";#ifdef OTEXT_TIMER    gettimeofday(&endv, NULL);    double elapsed = timeval_diff(&startv, &endv);    cout << "/t/tOT ext hashing took time " << elapsed/1000000 << endl << flush;    times["Hashing"] += timeval_diff(&startv, &endv);#endif}
开发者ID:lance6716,项目名称:SPDZ-2,代码行数:33,


示例8: receiverOutputSlice

void OTExtensionWithMatrix::transpose(int start, int slice){    BitMatrixSlice receiverOutputSlice(receiverOutputMatrix, start, slice);    BitMatrixSlice senderOutputSlices[2] = {            BitMatrixSlice(senderOutputMatrices[0], start, slice),            BitMatrixSlice(senderOutputMatrices[1], start, slice)    };    // transpose t0[i] onto receiverOutput and tmp (q[i]) onto senderOutput[i][0]    //cout << "Starting matrix transpose/n" << flush << endl;#ifdef OTEXT_TIMER    timeval transt1, transt2;    gettimeofday(&transt1, NULL);#endif    // transpose in 128-bit chunks    if (ot_role & RECEIVER)        receiverOutputSlice.transpose();    if (ot_role & SENDER)        senderOutputSlices[0].transpose();#ifdef OTEXT_TIMER    gettimeofday(&transt2, NULL);    double transtime = timeval_diff(&transt1, &transt2);    cout << "/t/tMatrix transpose took time " << transtime/1000000 << endl << flush;    times["Matrix transpose"] += timeval_diff(&transt1, &transt2);#endif}
开发者ID:lance6716,项目名称:SPDZ-2,代码行数:28,


示例9: check_read_stop

static boolcheck_read_stop(){    uint64_t diff, history_diff, cur_diff;    history_diff = timeval_diff(&first_pack_time, &last_pack_time);    cur_diff     = timeval_diff(&base_time, &cur_time);    if (clt_settings.accelerated_times > 1) {        cur_diff = cur_diff * clt_settings.accelerated_times;    }    if (clt_settings.interval > 0) {        if (adj_v_pack_diff > 0 && adj_v_pack_diff > clt_settings.interval) {            accumulated_diff += adj_v_pack_diff;            tc_log_info(LOG_NOTICE, 0, "accumulated time saved:%llu",                    accumulated_diff);        }        cur_diff = cur_diff + accumulated_diff;    }    if (history_diff <= cur_diff) {        return false;    }    diff = history_diff - cur_diff;    if (diff > 0) {        return true;    }    return false;}
开发者ID:CyaLiven,项目名称:tcpcopy,代码行数:33,


示例10: print_diff

static void print_diff (struct mi_timestamp *start, struct mi_timestamp *end)  {    fprintf_unfiltered      (raw_stdout,       ",time={wallclock=/"%0.5f/",user=/"%0.5f/",system=/"%0.5f/"}",        timeval_diff (start->wallclock, end->wallclock) / 1000000.0,        timeval_diff (start->utime, end->utime) / 1000000.0,        timeval_diff (start->stime, end->stime) / 1000000.0);  }
开发者ID:gygy,项目名称:asuswrt,代码行数:10,


示例11: reciver_looper

static void reciver_looper(void){    if (shut_down_flag)    {        int i;        for (i = 0; i < settings.hash_table_num; ++i)        {            flush_table(&settings.tables[i]);        }        log_vip("reciver, shut down...");        exit(0);    }    struct timeval now;    gettimeofday(&now, NULL);    dlog_check(NULL, &now);    static time_t last_log_min;    time_t curr_min = now.tv_sec / 60;    if (curr_min != last_log_min)    {        if (last_log_min != 0)        {            log_info("reciver: recv pkg: %d, succ: %d, fail: %d", /                    recv_pkg_count, process_pkg_succ_count, process_pkg_fail_count);            recv_pkg_count = 0;            process_pkg_succ_count = 0;            process_pkg_fail_count = 0;        }        last_log_min = curr_min;    }    static struct timeval last_check;    if (settings.cache_time_in_ms && ((timeval_diff(&last_check, &now) / 1000) > (uint64_t)settings.check_time_in_ms))    {        int i;        for (i = 0; i < settings.hash_table_num; ++i)        {            if (settings.tables[i].buf_use &&                    (timeval_diff(&settings.tables[i].start, &now) / 1000) > (uint64_t)settings.cache_time_in_ms)            {                flush_table(&settings.tables[i]);            }        }        last_check = now;    }    return;}
开发者ID:cheetah0216,项目名称:logdb,代码行数:55,


示例12: mem_calibrate

void mem_calibrate(void){    int i, p;// Limits for interval_rand()    int lr = 0, hr = 100;// No of loops to calibrate with.    int calib_length = MEM_CALIBRATION_LOOPS;// Working set size used for calibration.    int calib_wss = MEM_CALIBRATION_WSS;    long long start_usec, end_usec;// No of loops needed to achieve loop_length    long long calib_loops;    /*     * Initialize the memness_array. This is done in such a way that each structure     * points to the next one in the array, which is chosen at random. Care is     * taken to ensure that there are no loops created with these pointers.     */    for (i = 0; i < MEMNESS_INT_ARRAY_SIZE; i++) {        memness_array[i].num = interval_rand(lr, hr);        memness_array[i].touched = 1;        memness_array[i].next = NULL;    }    randomize_array(memness_array, MEMNESS_INT_ARRAY_SIZE);    if (!WILEE_CALIBRATE)        return;    /*     * Calibrate by checking how long it takes to run calib_length number of     * loops on a calib_wss sized working set.     */    gettimeofday(&pr, NULL);    mem_inner_loop(calib_length, calib_wss, p);    gettimeofday(&ne, NULL);    time_per_memness_iteration = (float)(timeval_diff(&pr, &ne))                                 / (float)calib_length;    calib_loops = loop_length / time_per_memness_iteration;//	calib_loops = 0;    gettimeofday(&pr, NULL);    mem_inner_loop(calib_loops, calib_wss, p);    gettimeofday(&ne, NULL);    printf("------------------/n");    printf("Memory Calibration/n");    printf("------------------/n");    printf("Working set size used: %d/n", calib_wss);    printf("Time per iteration: %f/n", time_per_memness_iteration);    printf("Number of loops for 100%% Memory-ness: %lld/n", calib_loops);    printf("Time for above loops: %ld/n", timeval_diff(&pr, &ne));}
开发者ID:sopwithcamel,项目名称:wilee,代码行数:52,


示例13: DIV_CEIL

void OTExtensionWithMatrix::extend_correlated(int nOTs_requested, BitVector& newReceiverInput){//    if (nOTs % nbaseOTs != 0)//        throw invalid_length(); //"nOTs must be a multiple of nbaseOTs/n");    if (nOTs_requested == 0)        return;    nOTs_requested = DIV_CEIL(nOTs_requested, 128) * 128;    // add k + s to account for discarding k OTs    int nOTs = nOTs_requested + 2 * 128;    int slice = nOTs / nsubloops / 128;    nOTs = slice * nsubloops * 128;    resize(nOTs);    newReceiverInput.resize(nOTs);    // randomize last 128 + 128 bits that will be discarded    for (int i = 0; i < 4; i++)        newReceiverInput.set_word(nOTs/64 - i - 1, G.get_word());    // subloop for first part to interleave communication with computation    for (int start = 0; start < nOTs / 128; start += slice)    {        expand<gf2n>(start, slice);        correlate<gf2n>(start, slice, newReceiverInput, true);        transpose(start, slice);    }#ifdef OTEXT_TIMER    double elapsed;#endif    // correlation check    if (!passive_only)    {#ifdef OTEXT_TIMER        timeval startv, endv;        gettimeofday(&startv, NULL);#endif        check_correlation(nOTs, newReceiverInput);#ifdef OTEXT_TIMER        gettimeofday(&endv, NULL);        elapsed = timeval_diff(&startv, &endv);        cout << "/t/tTotal correlation check time: " << elapsed/1000000 << endl << flush;        times["Total correlation check"] += timeval_diff(&startv, &endv);#endif    }    receiverOutputMatrix.resize(nOTs_requested);    senderOutputMatrices[0].resize(nOTs_requested);    senderOutputMatrices[1].resize(nOTs_requested);    newReceiverInput.resize(nOTs_requested);}
开发者ID:lance6716,项目名称:SPDZ-2,代码行数:51,


示例14: main

int main () {    char * request_uri;    /* Load the controller .so from this sub directory */    route_import_controllers("controllers/");    /* Initialize session system */    session_init();    while (FCGI_Accept() >= 0) {      /* Record start time */      gettimeofday(&start_time,NULL);      request_uri = cleanrequest( getenv("REQUEST_URI"));      /* Initialize session for this request */      fprintf(stderr, "Request for %s/n", request_uri );      /* Dispatch the request to the correct controller */      route_dispatch(request_uri);      free(request_uri);           /* Calculate total runtime of the operation */      gettimeofday(&end_time,NULL);      timeval_diff( &difference_time, &end_time, &start_time );            printf("time: %ld.%06ld/n", difference_time.tv_sec, difference_time.tv_usec);      FCGI_Finish();    }    fprintf(stderr, "FF Exiting/n");    return 0;}
开发者ID:adamsch1,项目名称:ff,代码行数:34,


示例15: time_since

/* *    Time since a timeval */static inttime_since(const struct timeval *when){    struct timeval now;    gettimeofday(&now, NULL);    return timeval_diff(when, &now);}
开发者ID:arthurtumanyan,项目名称:squid-3.0-stable1-shaga,代码行数:10,


示例16: __agent_schedule_abs

static void __agent_schedule_abs(struct ice_agent *ag, const struct timeval *tv) {	struct timeval nxt;	long long diff;	if (!ag) {		ilog(LOG_ERR, "ice ag is NULL");		return;	}	nxt = *tv;	mutex_lock(&ice_agents_timers_lock);	if (ag->last_run.tv_sec) {		/* make sure we don't run more often than we should */		diff = timeval_diff(&nxt, &ag->last_run);		if (diff < TIMER_RUN_INTERVAL * 1000)			timeval_add_usec(&nxt, TIMER_RUN_INTERVAL * 1000 - diff);	}	if (ag->next_check.tv_sec && timeval_cmp(&ag->next_check, &nxt) <= 0)		goto nope; /* already scheduled sooner */	if (!g_tree_remove(ice_agents_timers, ag))		obj_hold(ag); /* if it wasn't removed, we make a new reference */	ag->next_check = nxt;	g_tree_insert(ice_agents_timers, ag, ag);	cond_broadcast(&ice_agents_timers_cond);nope:	mutex_unlock(&ice_agents_timers_lock);}
开发者ID:Zodiac-Evil,项目名称:rtpengine,代码行数:28,


示例17: main

int main(int argc, char *argv[]){  struct timeval tvStart, tvEnd;  int err;  int num; // number of operations for compute  if(argc!=2)    exit(EXIT_FAILURE);  else    num=atoi(argv[1]);  err=gettimeofday(&tvStart, NULL);  if(err!=0)    exit(EXIT_FAILURE);  // long computation  compute(num);  err=gettimeofday(&tvEnd, NULL);  if(err!=0)    exit(EXIT_FAILURE);  printf("Duration : %ld microseconds/n", timeval_diff(&tvEnd, &tvStart));  return(EXIT_SUCCESS);}
开发者ID:BaptisteDegryse,项目名称:SystemesInformatiques,代码行数:25,


示例18: stats_print

/* * Called at the end of the main thread, when no other threads are * running, to print the final statistics. */void stats_print(void){     struct timeval tmp;     timeval_diff(&tmp, &s_stats.end_time, &s_stats.start_time);     times(&s_stats.tms);     s_stats.tms.tms_utime += s_stats.tms_thread.tms_utime;     s_stats.tms.tms_stime += s_stats.tms_thread.tms_stime;     logger(LOG_INFO, "  Load measurements:");     logger(LOG_INFO, "   User: %8.3fs  Sys:%8.3fs",            (double)(s_stats.tms.tms_utime) / CLK_TCK,            (double)(s_stats.tms.tms_stime) / CLK_TCK);     logger(LOG_INFO, "   Total:%8.3fs  CPU:%8.3f%%",             (double)(tmp.tv_sec + tmp.tv_usec * 1e-6),            (double)(s_stats.tms.tms_utime + s_stats.tms.tms_stime) /            (double)(tmp.tv_sec + tmp.tv_usec * 1e-6));     logger(LOG_INFO, "  Time between connections:");     if (s_stats.min_time.tv_sec == LONG_MAX)          logger(LOG_INFO, "   Min: -----   Max: -----");     else          logger(LOG_INFO, "   Min: %.3fs Max: %.3fs",                 (double)(s_stats.min_time.tv_sec + s_stats.min_time.tv_usec * 1e-6),                 (double)(s_stats.max_time.tv_sec + s_stats.max_time.tv_usec * 1e-6));     logger(LOG_INFO, "  Thread stats:");     logger(LOG_INFO, "   simultaneous threads:     %d", s_stats.max_simul_threads);     logger(LOG_INFO, "   number of servers:        %d", s_stats.number_of_server);     logger(LOG_INFO, "   number of aborts:         %d", s_stats.number_of_abort);     logger(LOG_INFO, "   number of errors:         %d", s_stats.number_of_err);     logger(LOG_INFO, "   number of files sent:     %d", s_stats.num_file_send);     logger(LOG_INFO, "   number of files received: %d", s_stats.num_file_recv);}
开发者ID:DonCN,项目名称:haiku,代码行数:36,


示例19: timer_cb

void timer_cb(mrp_timer_t *timer, void *user_data){    test_timer_t   *t = (test_timer_t *)user_data;    struct timeval  now;    double          diff, error;    MRP_UNUSED(timer);    timeval_now(&now);    diff  = timeval_diff(&now, &t->prev) / 1000.0;    error = diff - t->interval;    if (error < 0.0)        error = -error;    info("MRPH timer #%d: %d/%d, diff %.2f (lag %.2f, %.3f %%)",         t->id, t->count, t->target, diff, error, 100 * error / diff);    t->count++;    t->prev = now;    if (t->count >= t->target) {        info("MRPH timer #%d has finished.", t->id);        mrp_del_timer(t->timer);        t->timer = NULL;        cfg.nrunning--;    }}
开发者ID:01org,项目名称:murphy,代码行数:28,


示例20: progress_cb

static voidprogress_cb (guestfs_h *g, void *vp, uint64_t event,             int eh, int flags,             const char *buf, size_t buflen,             const uint64_t *array, size_t arraylen){  uint64_t transferred;  struct timeval now;  int64_t millis;  assert (event == GUESTFS_EVENT_PROGRESS);  assert (arraylen >= 4);  gettimeofday (&now, NULL);  /* Bytes transferred. */  transferred = array[2];  /* Calculate the speed of the upload or download. */  millis = timeval_diff (&start, &now);  assert (millis >= 0);  if (millis != 0) {    rate = 1000 * transferred / millis;    printf ("%s: %" PRIi64 " bytes/sec          /r",            operation, rate);    fflush (stdout);  }}
开发者ID:AlphaStaxLLC,项目名称:libguestfs,代码行数:29,


示例21: kdi

//kernel code identificationint kdi(unsigned startVirtualAddr, Mem * mem, int pageSize,        unsigned cr3Pages[], int *kdi_time, int *allPages){    struct timeval earlier;    struct timeval later;    if (gettimeofday(&earlier, NULL)) {        perror("gettimeofday() error");        exit(1);    }    //generate step 1 clusters    unsigned cluster_index =        getClusters(startVirtualAddr, mem, pageSize, allPages);        print_clusters(cluster_index);    findKernelCodePageByCr3(startVirtualAddr, mem, pageSize, cr3Pages);    if (gettimeofday(&later, NULL)) {        perror("gettimeofday() error");        exit(1);    }    (*kdi_time) = timeval_diff(NULL, &later, &earlier) / 1000;    printf        ("step1,all pages: %d, cluster: %d,kdi time cost is %d milliseconds/n",         *allPages, cluster_index, (*kdi_time));    return cluster_index;}
开发者ID:flyrain,项目名称:osmem_md5,代码行数:28,


示例22: end

void end(struct timeval *timer){	struct timeval tend, tdiff;	gettimeofday(&tend, NULL);	timeval_diff(&tdiff, timer, &tend);	printf("Elapsed Time = %ld.%06ld(s)/n",tdiff.tv_sec, tdiff.tv_usec);}
开发者ID:SibghatullahSheikh,项目名称:HMM-SpeechRecogntion-GPU,代码行数:7,


示例23: glib_timer_cb

static gboolean glib_timer_cb(gpointer user_data){    glib_timer_t   *t = (glib_timer_t *)user_data;    struct timeval  now;    double          diff, error;    timeval_now(&now);    diff  = timeval_diff(&now, &t->prev) / 1000.0;    error = diff - t->interval;    if (error < 0.0)        error = -error;    info("GLIB timer #%d: %d/%d, diff %.2f (lag %.2f, %.3f %%)",         t->id, t->count, t->target, diff, error, 100 * error / diff);    t->count++;    t->prev = now;    if (t->count >= t->target) {        info("GLIB timer #%d has finished.", t->id);        t->gsrc = 0;        cfg.nrunning--;        return FALSE;    }    else        return TRUE;}
开发者ID:01org,项目名称:murphy,代码行数:28,


示例24: wakeup_cb

static void wakeup_cb(mrp_wakeup_t *w, mrp_wakeup_event_t event,                      void *user_data){    static struct timeval  prev[2] = { {0, 0}, {0, 0} };    const char            *evt;    struct timeval         now;    double                 diff;    int                    id;    MRP_UNUSED(w);    MRP_UNUSED(user_data);    timeval_now(&now);    switch (event) {    case MRP_WAKEUP_EVENT_TIMER: evt = "timer";           break;    case MRP_WAKEUP_EVENT_IO:    evt = "I/O (or signal)"; break;    case MRP_WAKEUP_EVENT_LIMIT: evt = "limit";           break;    default:                     evt = "???";    }    id = user_data ? 1 : 0;    if (MRP_LIKELY(prev[id].tv_usec != 0)) {        diff = timeval_diff(&now, &prev[id]) / 1000.0;        info("woken up #%d by %s, %.2f msecs since previous", id, evt, diff);    }    prev[id] = now;}
开发者ID:01org,项目名称:murphy,代码行数:30,


示例25: main

int main(int argc, char *argv[]) {    int *vector;  long mesures[LOOP], sum;  struct timeval tvStart, tvEnd;   int err;  vector=(int *)malloc(SIZE*sizeof(int));  free(vector);  for(int i=0;i<LOOP+1;i++) {    err=gettimeofday(&tvStart, NULL);    if(err!=0)      exit(EXIT_FAILURE);         vector=(int *)calloc(SIZE,sizeof(int));     //vector=(int *)malloc(SIZE*sizeof(int));    err=gettimeofday(&tvEnd, NULL);    if(err!=0)      exit(EXIT_FAILURE);        mesures[i]=timeval_diff(&tvEnd, &tvStart);    sum+=mesures[i];    free(vector);  }  printf("Durée moyenne : %ld /n",sum/LOOP);  return(EXIT_SUCCESS);}
开发者ID:HappyRave,项目名称:SystemesInformatiques,代码行数:30,


示例26: sigMatch

//signatures matchvoid sigMatch(range range, Mem *mem, int pageSize, int dsmPages[], int *match_time) {	int i;	struct timeval earlier;	struct timeval later;	//begin match	int osNumber = initDb();	extern fingerprint fingerprints[FINGERPRINT_NO];	if (gettimeofday(&earlier, NULL)) {		perror("gettimeofday() error");		exit(1);	}	int availableOs[FINGERPRINT_NO], matchCounts[FINGERPRINT_NO];	for (i = 0; i < FINGERPRINT_NO; i++) {		availableOs[i] = 1;		matchCounts[i] = 0;	}	unsigned startVirtualAddr = range.start;	for (; startVirtualAddr <= range.end; startVirtualAddr += 0x1000) {		unsigned pAddr = vtop(mem->mem, mem->mem_size, mem->pgd, startVirtualAddr);		if (pAddr == -1 || pAddr > mem->mem_size)			continue;		int pageIndex = pAddr / pageSize;		if (dsmPages[pageIndex] == 1) {			int offset = (startVirtualAddr - range.start) / 4096;			void *startAdress = (void*) ((unsigned) mem->mem + pageIndex * pageSize);			unsigned char md5digest[16];			MDMem(startAdress, pageSize, md5digest);			//	printf("%x ", vaddr); //print vaddr			MDPrint(md5digest);			printf("/n");			int ret = matchByIndex(osNumber, md5digest, offset, availableOs, matchCounts);			//			if(ret ==1)		}	}	int maxIndex = -1;	int maxMatch = 0;	for (i = 0; i < FINGERPRINT_NO; i++) {		if (matchCounts[i] > maxMatch) {			maxIndex = i;			maxMatch = matchCounts[i];		}	}	if (maxMatch > 0)		printf("Os is %s, match count is %d/n", fingerprints[maxIndex].osVersion, maxMatch);	else		puts("Unknown OS!");	if (gettimeofday(&later, NULL)) {		perror("gettimeofday() error");		exit(1);	}	*match_time = timeval_diff(NULL, &later, &earlier) / 1000;	printf("match time cost is %d milliseconds/n", *match_time);}
开发者ID:flyrain,项目名称:data_layout,代码行数:59,


示例27: os

void OTExtensionWithMatrix::correlate(int start, int slice,        BitVector& newReceiverInput, bool useConstantBase, int repeat){    vector<octetStream> os(2);    BitMatrixSlice receiverOutputSlice(receiverOutputMatrix, start, slice);    BitMatrixSlice senderOutputSlices[2] = {            BitMatrixSlice(senderOutputMatrices[0], start, slice),            BitMatrixSlice(senderOutputMatrices[1], start, slice)    };    BitMatrixSlice t1Slice(t1, start, slice);    BitMatrixSlice uSlice(u, start, slice);    // create correlation    if (ot_role & RECEIVER)    {        t1Slice.rsub<T>(receiverOutputSlice);        t1Slice.add<T>(newReceiverInput, repeat);        t1Slice.pack(os[0]);//        t1 = receiverOutputMatrix;//        t1 ^= newReceiverInput;//        receiverOutputMatrix.print_side_by_side(t1);    }#ifdef OTEXT_TIMER    timeval commst1, commst2;    gettimeofday(&commst1, NULL);#endif    // send t0 + t1 + x    send_if_ot_receiver(player, os, ot_role);    // sender adjusts using base receiver bits    if (ot_role & SENDER)    {        // u = t0 + t1 + x        uSlice.unpack(os[1]);        senderOutputSlices[0].conditional_add<T>(baseReceiverInput, u, !useConstantBase);    }#ifdef OTEXT_TIMER    gettimeofday(&commst2, NULL);    double commstime = timeval_diff(&commst1, &commst2);    cout << "/t/tCommunication took time " << commstime/1000000 << endl << flush;    times["Communication"] += timeval_diff(&commst1, &commst2);#endif}
开发者ID:lance6716,项目名称:SPDZ-2,代码行数:45,


示例28: get_timeval_passed

inline __useconds_tget_timeval_passed(struct timeval *since, struct timeval *diff){	struct timeval now;	gettimeofday(&now, NULL);	return timeval_diff(&now, since, diff);}
开发者ID:antweb,项目名称:bluez-ant,代码行数:9,


示例29: check_read_stop

static bool check_read_stop(){    uint64_t history_diff = timeval_diff(&first_pack_time, &last_pack_time);    uint64_t cur_diff     = timeval_diff(&base_time, &cur_time);    uint64_t diff;    tc_log_debug2(LOG_DEBUG, "diff,old:%llu,new:%llu",             history_diff, cur_diff);    if(history_diff <= cur_diff){        return false;    }    diff = history_diff - cur_diff;    /* More than 1 seconds */    if(diff > 1000){        return true;    }    return false;}
开发者ID:jbli,项目名称:tcpcopy,代码行数:18,



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


C++ timeval_subtract函数代码示例
C++ timeval_current_ofs函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。