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

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

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

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

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

示例1: read_timer

/* *			R E A D _ T I M E R *  */doubleread_timer(char *str, int len){	struct timeval timedol;	struct rusage ru1;	struct timeval td;	struct timeval tend, tstart;	char line[132];	getrusage(RUSAGE_SELF, &ru1);	gettimeofday(&timedol, (struct timezone *)0);	prusage(&ru0, &ru1, &timedol, &time0, line);	/* XXX: buffer overflow if len > sizeof(line) */	(void)strncpy(str, line, len);	/* Get real time */	tvsub(&td, &timedol, &time0);	realt = td.tv_sec + ((double)td.tv_usec) / 1000000;	/* Get CPU time (user+sys) */	tvadd(&tend, &ru1.ru_utime, &ru1.ru_stime);	tvadd(&tstart, &ru0.ru_utime, &ru0.ru_stime);	tvsub(&td, &tend, &tstart);	cput = td.tv_sec + ((double)td.tv_usec) / 1000000;	if (cput < 0.00001)		cput = 0.00001;	return(cput);}
开发者ID:ykhakuna,项目名称:c-practice,代码行数:32,


示例2: latency

voidlatency(uint64 xfers, uint64 size){	struct timeval td;	double  s;	if (!ftiming) ftiming = stderr;	tvsub(&td, &stop_tv, &start_tv);	s = td.tv_sec + td.tv_usec / 1000000.0;	if (s == 0.0) return;	if (xfers > 1) {		fprintf(ftiming, "%d %dKB xfers in %.2f secs, ",		    (int) xfers, (int) (size / KB), s);	} else {		fprintf(ftiming, "%.1fKB in ", size / KB);	}	if ((s * 1000 / xfers) > 100) {		fprintf(ftiming, "%.0f millisec%s, ",		    s * 1000 / xfers, xfers > 1 ? "/xfer" : "s");	} else {		fprintf(ftiming, "%.4f millisec%s, ",		    s * 1000 / xfers, xfers > 1 ? "/xfer" : "s");	}	if (((xfers * size) / (MB * s)) > 1) {		fprintf(ftiming, "%.2f MB/sec/n", (xfers * size) / (MB * s));	} else {		fprintf(ftiming, "%.2f KB/sec/n", (xfers * size) / (KB * s));	}}
开发者ID:lijing1989,项目名称:benchmark,代码行数:29,


示例3: gpu_init_scales

//detect and save detected boxesstatic FLOAT *detect(IplImage *IM,GPUModel *MO,FLOAT thresh,int *D_NUMS,FLOAT *A_SCORE){	/* for measurement */	struct timeval tv, tv_calc_f_pyramid_start, tv_calc_f_pyramid_end;	float time_calc_f_pyramid = 0;	//initialize scale information for hierachical detection	FLOAT *scales = gpu_init_scales(MO->MI,IM,IM->width,IM->height);	//initialize feature-size matrix	int *featsize = gpu_init_featsize(MO->MI);	//calculate feature pyramid	gettimeofday(&tv_calc_f_pyramid_start, NULL);	FLOAT **feature = gpu_calc_f_pyramid(IM,MO->MI,featsize,scales);	gettimeofday(&tv_calc_f_pyramid_end, NULL);	tvsub(&tv_calc_f_pyramid_end, &tv_calc_f_pyramid_start, &tv);	time_kernel += tv.tv_sec * 1000.0 + (float)tv.tv_usec / 1000.0;	time_calc_f_pyramid += tv.tv_sec * 1000.0 + (float)tv.tv_usec / 1000.0;#ifdef PRINT_INFO	printf("/n");	printf("calc_f_pyramid %f[ms]/n", time_calc_f_pyramid);#endif	//detect boundary boxes	FLOAT *boxes = dpm_ttic_gpu_get_boxes(feature,scales,featsize,MO,D_NUMS,A_SCORE,thresh);	free(scales);	free(featsize);	gpu_free_features(feature,MO->MI);	return boxes;}
开发者ID:794523332,项目名称:Autoware,代码行数:35,


示例4: bandwidth

voidbandwidth(uint64 bytes, uint64 times, int verbose){	struct timeval tdiff;	double  mb, secs;	tvsub(&tdiff, &stop_tv, &start_tv);	secs = tdiff.tv_sec;	secs *= 1000000;	secs += tdiff.tv_usec;	secs /= 1000000;	secs /= times;	mb = bytes / MB;	if (!ftiming) ftiming = stderr;	if (verbose) {		(void) fprintf(ftiming,		    "%.4f MB in %.4f secs, %.4f MB/sec/n",		    mb, secs, mb/secs);	} else {		if (mb < 1) {			(void) fprintf(ftiming, "%.6f ", mb);		} else {			(void) fprintf(ftiming, "%.2f ", mb);		}		if (mb / secs < 1) {			(void) fprintf(ftiming, "%.6f/n", mb/secs);		} else {			(void) fprintf(ftiming, "%.2f/n", mb/secs);		}	}}
开发者ID:lijing1989,项目名称:benchmark,代码行数:31,


示例5: timespent

doubletimespent(void){	struct timeval td;	tvsub(&td, &stop_tv, &start_tv);	return (td.tv_sec + td.tv_usec / 1000000.0);}
开发者ID:lijing1989,项目名称:benchmark,代码行数:8,


示例6: gettimeofday

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////detect car-boundary-boxesRESULT *car_detection(IplImage *IM,MODEL *MO,FLOAT thresh,int *D_NUMS,FLOAT *A_SCORE,FLOAT overlap){  /* for measurement */  struct timeval tv;  struct timeval tv_detect_start, tv_detect_end;  float time_detect;  struct timeval tv_nms_start, tv_nms_end;  float time_nms;  struct timeval tv_get_new_rects_start, tv_get_new_rects_end;  float time_get_new_rects;    gettimeofday(&tv_detect_start, NULL);  FLOAT *boxes = detect(IM,MO,thresh,D_NUMS,A_SCORE);	//detect high-score region  gettimeofday(&tv_detect_end, NULL);  gettimeofday(&tv_nms_start, NULL);  FLOAT *rects = nms(boxes,overlap,D_NUMS,MO);			//get boundary-rectangles of car  gettimeofday(&tv_nms_end, NULL);  gettimeofday(&tv_get_new_rects_start, NULL);  RESULT *CUR = get_new_rects(IM,MO,rects,D_NUMS);		//get current result  gettimeofday(&tv_get_new_rects_end, NULL);#if 0  tvsub(&tv_detect_end, &tv_detect_start, &tv);  time_detect = tv.tv_sec * 1000.0 + (float)tv.tv_usec / 1000.0;  tvsub(&tv_nms_end, &tv_nms_start, &tv);  time_nms = tv.tv_sec * 1000.0 + (float)tv.tv_usec / 1000.0;  tvsub(&tv_get_new_rects_end, &tv_get_new_rects_start, &tv);  time_get_new_rects = tv.tv_sec * 1000.0 + (float)tv.tv_usec / 1000.0;  printf("detect : %f/n", time_detect);  printf("nms : %f/n", time_nms);  printf("get_new_rects : %f/n", time_get_new_rects);#endif      s_free(boxes);  s_free(rects);    return CUR;}
开发者ID:caomw,项目名称:dpm_gpu,代码行数:49,


示例7: finish

/* * finish -- *	Print out statistics, and give up. */void finish(void){	struct timeval tv = cur_time;	char *comma = "";	tvsub(&tv, &start_time);	putchar('/n');	fflush(stdout);	printf("--- %s ping statistics ---/n", hostname);	printf("%ld packets transmitted, ", ntransmitted);	printf("%ld received", nreceived);	if (nrepeats)		printf(", +%ld duplicates", nrepeats);	if (nchecksum)		printf(", +%ld corrupted", nchecksum);	if (nerrors)		printf(", +%ld errors", nerrors);	if (ntransmitted) {#ifdef USE_IDN	setlocale(LC_ALL, "C");#endif		printf(", %g%% packet loss",		       (float) ((((long long)(ntransmitted - nreceived)) * 100.0) /			      ntransmitted));		printf(", time %ldms", 1000*tv.tv_sec+tv.tv_usec/1000);	}	putchar('/n');	if (nreceived && timing) {		long tmdev;		tsum /= nreceived + nrepeats;		tsum2 /= nreceived + nrepeats;		tmdev = llsqrt(tsum2 - tsum * tsum);		printf("rtt min/avg/max/mdev = %ld.%03ld/%lu.%03ld/%ld.%03ld/%ld.%03ld ms",		       (long)tmin/1000, (long)tmin%1000,		       (unsigned long)(tsum/1000), (long)(tsum%1000),		       (long)tmax/1000, (long)tmax%1000,		       (long)tmdev/1000, (long)tmdev%1000		       );		comma = ", ";	}	if (pipesize > 1) {		printf("%spipe %d", comma, pipesize);		comma = ", ";	}	if (nreceived && (!interval || (options&(F_FLOOD|F_ADAPTIVE))) && ntransmitted > 1) {		int ipg = (1000000*(long long)tv.tv_sec+tv.tv_usec)/(ntransmitted-1);		printf("%sipg/ewma %d.%03d/%d.%03d ms",		       comma, ipg/1000, ipg%1000, rtt/8000, (rtt/8)%1000);	}	putchar('/n');	exit(!nreceived || (deadline && nreceived < npackets));}
开发者ID:nmav,项目名称:iputils,代码行数:60,


示例8: stoptime

unsigned long stoptime(struct timeval tv_start){        unsigned long  clockus;        struct timeval tv_stop;        if (gettimeofday(&tv_stop, NULL) == -1)                return 0;        tvsub(&tv_stop, &tv_start);        clockus = tv_stop.tv_sec * 1000000 + tv_stop.tv_usec;        return(clockus); //return unit "us"}
开发者ID:cgcym1234,项目名称:heaven,代码行数:10,


示例9: Delta

doubleDelta(void){	struct timeval t;	struct timeval diff;	(void) gettimeofday(&t, (struct timezone *) 0);	tvsub(&diff, &t, &start_tv);	return (diff.tv_sec + diff.tv_usec / 1000000.0);}
开发者ID:lijing1989,项目名称:benchmark,代码行数:10,


示例10: ys_calculate_elapsed_time

doubleys_calculate_elapsed_time(const struct timeval *t0, 	  const struct timeval *t1){	struct timeval td;	double s;	tvsub(&td, t1, t0);	s = td.tv_sec + (td.tv_usec / 1000000.);	return s;}
开发者ID:followheart,项目名称:try-catch-finally,代码行数:11,


示例11: tvdelta

uint64 tvdelta(struct timeval *start, struct timeval *stop){	struct timeval td;	uint64	usecs;	tvsub(&td, stop, start);	usecs = td.tv_sec;	usecs *= 1000000;	usecs += td.tv_usec;	return (usecs);}
开发者ID:GTkernel,项目名称:memlatency,代码行数:11,


示例12: time_measure_end

void time_measure_end(struct timeval *tv){	struct timeval tv_now, tv_diff;	double d;	gettimeofday(&tv_now, NULL);	tvsub(&tv_now, tv, &tv_diff);	d = (double) tv_diff.tv_sec * 1000.0 + (double) tv_diff.tv_usec / 1000.0;	printf("Time (Memory Copy and Launch) = %f (ms)/n", d);}
开发者ID:Constellation,项目名称:gdev-bench,代码行数:11,


示例13: pdeltat

voidpdeltat(struct timeval *t1, struct timeval *t0){	struct timeval td;#ifdef TRACE	tprintf("TRACE- pdeltat()/n");#endif	tvsub(&td, t1, t0);	/* change printf formats */	printf("%d.%01d", td.tv_sec, td.tv_usec / 100000);}
开发者ID:AlainODea,项目名称:illumos-gate,代码行数:12,


示例14: milli

voidmilli(char *s, uint64 n){    struct timeval td;    uint64 milli;    tvsub(&td, &stop_tv, &start_tv);    milli = td.tv_sec * 1000 + td.tv_usec / 1000;    milli /= n;    if (!ftiming) ftiming = stderr;    fprintf(ftiming, "%s: %d milliseconds/n", s, (int)milli);}
开发者ID:Toendex,项目名称:relay,代码行数:12,


示例15: mb

voidmb(uint64 bytes){    struct timeval td;    double  s, bs;    tvsub(&td, &stop_tv, &start_tv);    s = td.tv_sec + td.tv_usec / 1000000.0;    bs = bytes / nz(s);    if (!ftiming) ftiming = stderr;    (void) fprintf(ftiming, "%.2f MB/sec/n", bs / MB);}
开发者ID:Toendex,项目名称:relay,代码行数:12,


示例16: nano

voidnano(char *s, uint64 n){    struct timeval td;    double  micro;    tvsub(&td, &stop_tv, &start_tv);    micro = td.tv_sec * 1000000 + td.tv_usec;    micro *= 1000;    if (!ftiming) ftiming = stderr;    fprintf(ftiming, "%s: %.0f nanoseconds/n", s, micro / n);}
开发者ID:Toendex,项目名称:relay,代码行数:12,


示例17: ptime

voidptime(uint64 n){    struct timeval td;    double  s;    tvsub(&td, &stop_tv, &start_tv);    s = td.tv_sec + td.tv_usec / 1000000.0;    if (!ftiming) ftiming = stderr;    fprintf(ftiming,            "%d in %.2f secs, %.0f microseconds each/n",            (int)n, s, s * 1000000 / n);}
开发者ID:Toendex,项目名称:relay,代码行数:13,


示例18: nano

voidnano(char *s, uint64 n){	struct timeval td;	double  micro;	tvsub(&td, &stop_tv, &start_tv);	micro = td.tv_sec * 1000000 + td.tv_usec;	micro *= 1000;	if (micro == 0.0) return;	if (!ftiming) ftiming = stderr;	fprintf(ftiming, "<name>%s</name><measurement units=/"nanoseconds/">%.2f</measurement>/n", s, micro / n);}
开发者ID:openbox00,项目名称:okl4_3.0,代码行数:13,


示例19: mb

voidmb(uint64 bytes){	struct timeval td;	double  s, bs;	tvsub(&td, &stop_tv, &start_tv);	s = td.tv_sec + td.tv_usec / 1000000.0;	bs = bytes / nz(s);	if (s == 0.0) return;	if (!ftiming) ftiming = stderr;	(void) fprintf(ftiming, "<measurement units=/"MB/sec/">%.2f</measurement>/n", bs / MB);}
开发者ID:openbox00,项目名称:okl4_3.0,代码行数:13,


示例20: milli

voidmilli(char *s, uint64 n){	struct timeval td;	uint64 milli;	tvsub(&td, &stop_tv, &start_tv);	milli = td.tv_sec * 1000 + td.tv_usec / 1000;	milli /= n;	if (milli == 0.0) return;	if (!ftiming) ftiming = stderr;	fprintf(ftiming, "<name>%s</name> <measurement units=/"milliseconds/">%d</measurement>/n", s, (int)milli);}
开发者ID:openbox00,项目名称:okl4_3.0,代码行数:13,


示例21: ping_timeout_p

intping_timeout_p (struct timeval *start_time, int timeout){  struct timeval now;  gettimeofday (&now, NULL);  if (timeout != -1)    {      tvsub (&now, start_time);      if (now.tv_sec >= timeout)        return 1;    }  return 0;}
开发者ID:millken,项目名称:zhuxianB30,代码行数:13,


示例22: context

voidcontext(uint64 xfers){    struct timeval td;    double  s;    tvsub(&td, &stop_tv, &start_tv);    s = td.tv_sec + td.tv_usec / 1000000.0;    if (!ftiming) ftiming = stderr;    fprintf(ftiming,            "%d context switches in %.2f secs, %.0f microsec/switch/n",            (int)xfers, s, s * 1000000 / xfers);}
开发者ID:Toendex,项目名称:relay,代码行数:13,


示例23: read_timer

/* *                    R E A D _ T I M E R */doubleread_timer (char *str, int len){  struct itimerval itimedol;  struct rusage ru1;  struct timeval td;  struct timeval tend, tstart;  char line[132];  getrusage (RUSAGE_SELF, &ru1);  fprintf(stdout, "final user time = %d sec and %d usec/n", ru1.ru_utime.tv_sec, ru1.ru_utime.tv_usec);  fprintf(stdout, "final sys time = %d sec and %d usec/n", ru1.ru_stime.tv_sec, ru1.ru_stime.tv_usec);  if (getitimer (ITIMER_REAL, &itimedol))    {      perror ("Getting 'itimer' REAL failed");      return (0.0);    }  fprintf(stdout, "End transaction time = %d sec and %d usec/n", itimedol.it_value.tv_sec, itimedol.it_value.tv_usec);  prusage (&ru0, &ru1, &itime0.it_value, &itimedol.it_value, line);  (void) strncpy (str, line, len);  /* Get real time */  tvsub (&td, &itime0.it_value, &itimedol.it_value);  realt = td.tv_sec + ((double) td.tv_usec) / 1000000;  /* Get CPU time (user+sys) */  tvadd (&tend, &ru1.ru_utime, &ru1.ru_stime);  tvadd (&tstart, &ru0.ru_utime, &ru0.ru_stime);  tvsub (&td, &tend, &tstart);  cput = td.tv_sec + ((double) td.tv_usec) / 1000000;  if (cput < 0.00001)    cput = 0.00001;  return (cput);}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:39,


示例24: main

int main(int argc, char* argv[]){	int i;	unsigned long prio;	struct timespec period, runtime, timeout;	struct timeval tv1, tv2, tv3;	if (argc != 3) {		printf("Error: invalid option/n");	}	prio = atoi(argv[1]);					/* priority. */	period = ms_to_timespec(atoi(argv[2]));	/* period. */	runtime = ms_to_timespec(1000);			/* execution time. */	timeout = ms_to_timespec(1000);			/* timeout. */	/* bannar. */	printf("sample program/n");	rt_init(); 	rt_set_period(period);	rt_set_runtime(runtime);	rt_set_scheduler(SCHED_FP); /* you can also set SCHED_EDF. */	rt_set_priority(prio);	rt_reserve_start(runtime, NULL); /* QoS is guaranteed. */	rt_run(timeout);	for (i = 0; i < 20; i++) {		gettimeofday(&tv1, NULL);		printf("start %lu:%06lu/n", tv1.tv_sec, tv1.tv_usec);		fflush(stdout);		do  {			gettimeofday(&tv2, NULL);			/* tv2 - tv1 = tv3 */			tvsub(&tv2, &tv1, &tv3);		} while (tv3.tv_sec < 2);		printf("finish %lu:%06lu/n", tv2.tv_sec, tv2.tv_usec);		fflush(stdout);		if (!rt_wait_period()) {			printf("deadline is missed!/n");		}	}	rt_reserve_stop();	rt_exit();		return 0;}
开发者ID:Aand1,项目名称:ROSCH,代码行数:47,


示例25: ptransfer

static voidptransfer(const char *direction, long bytes, 	  const struct timeval *t0, 	  const struct timeval *t1){	struct timeval td;	float s, bs;	if (verbose) {		tvsub(&td, t1, t0);		s = td.tv_sec + (td.tv_usec / 1000000.);#define	nz(x)	((x) == 0 ? 1 : (x))		bs = bytes / nz(s);		printf("%ld bytes %s in %.3g secs (%.2g Kbytes/sec)/n",		    bytes, direction, s, bs / 1024.0);	}}
开发者ID:bluerSky,项目名称:firstRepo,代码行数:17,


示例26: micromb

voidmicromb(uint64 sz, uint64 n){    struct timeval td;    double	mb, micro;    tvsub(&td, &stop_tv, &start_tv);    micro = td.tv_sec * 1000000 + td.tv_usec;    micro /= n;    mb = sz;    mb /= MB;    if (!ftiming) ftiming = stderr;    if (micro >= 10) {        fprintf(ftiming, "%.6f %.0f/n", mb, micro);    } else {        fprintf(ftiming, "%.6f %.3f/n", mb, micro);    }}
开发者ID:Toendex,项目名称:relay,代码行数:18,


示例27: store_pcm

void store_pcm(phmstream_t *s, char *buf, int len){  int lg;  g_mutex_lock(s->synclock);  if (len <= (PCM_TRACE_LEN - s->pcm_wr))  {    memcpy(s->pcm_sent + s->pcm_wr, buf, len);    s->pcm_wr += len;    if (s->pcm_wr == PCM_TRACE_LEN)      s->pcm_wr = 0;  }  else  {    lg = PCM_TRACE_LEN - s->pcm_wr;    memcpy(s->pcm_sent + s->pcm_wr, buf, lg);    memcpy(s->pcm_sent, buf+lg, len-lg);    s->pcm_wr = len-lg;  }  s->sent_cnt += len;	if(s->pcm_need_resync && s->sent_cnt > 0)	{		int skip=0;		struct timeval now;		// compute the time elapsed since the moment application got something		// from audio diver		gettimeofday(&now, 0);		AEC_MUTEX_LOCK(s);		tvsub(&now, &s->last_audio_read);	   	    skip = 8*2 * now.tv_usec/1000;   // number of bytes waiting in the system buffers		s->bytes_to_throw = skip;		s->pcm_need_resync = 0;		AEC_MUTEX_UNLOCK(s);		printf("EC:Resync OK %d bytes to throw/n", skip);  }  g_mutex_unlock(s->synclock);}
开发者ID:BackupTheBerlios,项目名称:sfsipua-svn,代码行数:44,


示例28: micro

voidmicro(char *s, uint64 n){    struct timeval td;    double	micro, mean, var;    tvsub(&td, &stop_tv, &start_tv);    micro = td.tv_sec * 1000000 + td.tv_usec;    micro /= n;    if (micro == 0.0) return;    mean = getmeantime();    var = getvariancetime();    if (!ftiming) ftiming = stderr;    fprintf(ftiming, "%s median=%.4f [mean=%.4f +/-%.4f] microseconds/n",            s, micro, mean,	ci_width(sqrt(var), TRIES));}
开发者ID:sktzwhj,项目名称:betrfs,代码行数:19,


示例29: delta

uint64delta(void){	static struct timeval last;	struct timeval t;	struct timeval diff;	uint64	m;	(void) gettimeofday(&t, (struct timezone *) 0);	if (last.tv_usec) {		tvsub(&diff, &t, &last);		last = t;		m = diff.tv_sec;		m *= 1000000;		m += diff.tv_usec;		return (m);	} else {		last = t;		return (0);	}}
开发者ID:lijing1989,项目名称:benchmark,代码行数:21,



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


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