这篇教程C++ tsub函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中tsub函数的典型用法代码示例。如果您正苦于以下问题:C++ tsub函数的具体用法?C++ tsub怎么用?C++ tsub使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了tsub函数的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: record_livestatic void record_live(FILE *f, void* state, struct timeval *tm, char *buf, int len){ struct timeval tv, wall; gettimeofday(&wall, 0); tv=*tm; tadd(tv, *((struct timeval*)state)); tsub(tv, wall); if (tv.tv_sec>=0 && (tv.tv_sec || tv.tv_usec)) // can't go back in time select(0, 0, 0, 0, &tv); else tsub(*(struct timeval*)state, tv); // move the origin by the (negative) time skipped fwrite(buf, 1, len, f); fflush(f);}
开发者ID:milisarge,项目名称:termrec,代码行数:15,
示例2: aio_write_donestatic void aio_write_done(void *opaque, int ret){ struct aio_ctx *ctx = opaque; struct timeval t2; gettimeofday(&t2, NULL); if (ret < 0) { printf("aio_write failed: %s/n", strerror(-ret)); goto out; } if (ctx->qflag) { goto out; } /* Finally, report back -- -C gives a parsable format */ t2 = tsub(t2, ctx->t1); print_report("wrote", &t2, ctx->offset, ctx->qiov.size, ctx->qiov.size, 1, ctx->Cflag);out: qemu_io_free(ctx->buf); qemu_iovec_destroy(&ctx->qiov); g_free(ctx);}
开发者ID:AjayMashi,项目名称:x-tier,代码行数:26,
示例3: play_livestatic void play_live(FILE *f, void *(synch_init_wait)(struct timeval *ts, void *arg), void *(synch_wait)(struct timeval *tv, void *arg), void *(synch_print)(char *buf, int len, void *arg), void *arg, struct timeval *cont){ struct timeval tv, tp, tm; char buf[BUFFER_SIZE]; int len; if (cont) tp=*cont; else { gettimeofday(&tp, 0); synch_init_wait(&tp, arg); } // using read() not fread(), we need unbuffered IO while ((len=read(fileno(f), buf, BUFFER_SIZE))>0) { gettimeofday(&tv, 0); tm=tv; tsub(tm, tp); synch_wait(&tm, arg); tp=tv; synch_print(buf, len, arg); }}
开发者ID:milisarge,项目名称:termrec,代码行数:29,
示例4: aio_write_donestatic voidaio_write_done(void *opaque, int ret){ struct aio_ctx *ctx = opaque; struct timeval t2; gettimeofday(&t2, NULL); if (ret < 0) { printf("aio_write failed: %s/n", strerror(-ret)); goto out; } if (ctx->qflag) { goto out; } t2 = tsub(t2, ctx->t1); print_report("wrote", &t2, ctx->offset, ctx->qiov.size, ctx->qiov.size, 1, ctx->Cflag);out: qemu_io_free(ctx->buf); free(ctx);}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:26,
示例5: discard_fstatic int discard_f(int argc, char **argv){ struct timeval t1, t2; int Cflag = 0, qflag = 0; int c, ret; int64_t offset; int count; while ((c = getopt(argc, argv, "Cq")) != EOF) { switch (c) { case 'C': Cflag = 1; break; case 'q': qflag = 1; break; default: return command_usage(&discard_cmd); } } if (optind != argc - 2) { return command_usage(&discard_cmd); } offset = cvtnum(argv[optind]); if (offset < 0) { printf("non-numeric length argument -- %s/n", argv[optind]); return 0; } optind++; count = cvtnum(argv[optind]); if (count < 0) { printf("non-numeric length argument -- %s/n", argv[optind]); return 0; } gettimeofday(&t1, NULL); ret = bdrv_discard(bs, offset >> BDRV_SECTOR_BITS, count >> BDRV_SECTOR_BITS); gettimeofday(&t2, NULL); if (ret < 0) { printf("discard failed: %s/n", strerror(-ret)); goto out; } /* Finally, report back -- -C gives a parsable format */ if (!qflag) { t2 = tsub(t2, t1); print_report("discard", &t2, offset, count, count, 1, Cflag); }out: return 0;}
开发者ID:AjayMashi,项目名称:x-tier,代码行数:57,
示例6: record_live_initstatic void* record_live_init(FILE *f, struct timeval *tm){ struct timeval *tv; tv=malloc(sizeof(struct timeval)); gettimeofday(tv, 0); tsub(*tv, *tm); return tv;}
开发者ID:milisarge,项目名称:termrec,代码行数:10,
示例7: __pmAFunregisterint__pmAFunregister(int afid){ qelt *qp; qelt *priorp; struct timeval now; struct timeval interval; if (PM_MULTIPLE_THREADS(PM_SCOPE_AF)) return PM_ERR_THREAD; if (!block) AFhold(); for (qp = root, priorp = NULL; qp != NULL && qp->q_afid != afid; qp = qp->q_next) priorp = qp; if (qp == NULL) { if (!block) AFrelse(); return -1; } if (priorp == NULL) { root = qp->q_next; if (root != NULL) { /* * we removed the head of the queue, set itimer for the * new head of queue */ interval = root->q_when; __pmtimevalNow(&now); tsub(&interval, &now); if (interval.tv_sec == 0 && interval.tv_usec < MIN_ITIMER_USEC) /* use minimal delay (platform dependent) */ interval.tv_usec = MIN_ITIMER_USEC;#ifdef PCP_DEBUG if (pmDebug & DBG_TRACE_AF) { __pmPrintStamp(stderr, &now); fprintf(stderr, " AFsetitimer for delta "); printdelta(stderr, &interval); fputc('/n', stderr); }#endif AFsetitimer(&interval); } } else priorp->q_next = qp->q_next; free(qp); if (!block) AFrelse(); return 0;}
开发者ID:tongfw,项目名称:pcp,代码行数:55,
示例8: __pmAFregisterint__pmAFregister(const struct timeval *delta, void *data, void (*func)(int, void *)){ qelt *qp; struct timeval now; struct timeval interval; if (PM_MULTIPLE_THREADS(PM_SCOPE_AF)) return PM_ERR_THREAD; if (!block) AFhold(); if (afid == 0x8000 && !block) /* first time */ AFrearm(); if ((qp = (qelt *)malloc(sizeof(qelt))) == NULL) { return -oserror(); } qp->q_afid = ++afid; qp->q_data = data; qp->q_delta = *delta; qp->q_func = func; __pmtimevalNow(&qp->q_when); tadd(&qp->q_when, &qp->q_delta); enqueue(qp); if (root == qp) { /* we ended up at the head of the list, set itimer */ interval = qp->q_when; __pmtimevalNow(&now); tsub(&interval, &now); if (interval.tv_sec == 0 && interval.tv_usec < MIN_ITIMER_USEC) /* use minimal delay (platform dependent) */ interval.tv_usec = MIN_ITIMER_USEC;#ifdef PCP_DEBUG if (pmDebug & DBG_TRACE_AF) { __pmPrintStamp(stderr, &now); fprintf(stderr, " AFsetitimer for delta "); printdelta(stderr, &interval); fputc('/n', stderr); }#endif AFsetitimer(&interval); } if (!block) AFrelse(); return qp->q_afid;}
开发者ID:tongfw,项目名称:pcp,代码行数:50,
示例9: sleeptillstatic voidsleeptill(struct timeval sched){ int sts; struct timeval curr; /* current time */ struct timespec delay; /* interval to sleep */ struct timespec left; /* remaining sleep time */ __pmtimevalNow(&curr); tospec(tsub(sched, curr), &delay); for (;;) { /* loop to catch early wakeup by nanosleep */ sts = nanosleep(&delay, &left); if (sts == 0 || (sts < 0 && errno != EINTR)) break; delay = left; }}
开发者ID:tongfw,项目名称:pcp,代码行数:17,
示例10: aio_read_donestatic voidaio_read_done(void *opaque, int ret){ struct aio_ctx *ctx = opaque; struct timeval t2; gettimeofday(&t2, NULL); if (ret < 0) { printf("readv failed: %s/n", strerror(-ret)); goto out; } if (ctx->Pflag) { void *cmp_buf = malloc(ctx->qiov.size); memset(cmp_buf, ctx->pattern, ctx->qiov.size); if (memcmp(ctx->buf, cmp_buf, ctx->qiov.size)) { printf("Pattern verification failed at offset %" PRId64 ", %zd bytes/n", ctx->offset, ctx->qiov.size); } free(cmp_buf); } if (ctx->qflag) { goto out; } if (ctx->vflag) { dump_buffer(ctx->buf, ctx->offset, ctx->qiov.size); } /* Finally, report back -- -C gives a parsable format */ t2 = tsub(t2, ctx->t1); print_report("read", &t2, ctx->offset, ctx->qiov.size, ctx->qiov.size, 1, ctx->Cflag);out: qemu_io_free(ctx->buf); free(ctx);}
开发者ID:ChengyuSong,项目名称:ATrace,代码行数:41,
示例11: read_f//.........这里部分代码省略......... vflag = 1; break; default: return command_usage(&read_cmd); } } if (optind != argc - 2) { return command_usage(&read_cmd); } if (bflag && pflag) { printf("-b and -p cannot be specified at the same time/n"); return 0; } offset = cvtnum(argv[optind]); if (offset < 0) { printf("non-numeric length argument -- %s/n", argv[optind]); return 0; } optind++; count = cvtnum(argv[optind]); if (count < 0) { printf("non-numeric length argument -- %s/n", argv[optind]); return 0; } if (!Pflag && (lflag || sflag)) { return command_usage(&read_cmd); } if (!lflag) { pattern_count = count - pattern_offset; } if ((pattern_count < 0) || (pattern_count + pattern_offset > count)) { printf("pattern verification range exceeds end of read data/n"); return 0; } if (!pflag) { if (offset & 0x1ff) { printf("offset %" PRId64 " is not sector aligned/n", offset); return 0; } if (count & 0x1ff) { printf("count %d is not sector aligned/n", count); return 0; } } buf = qemu_io_alloc(count, 0xab); gettimeofday(&t1, NULL); if (pflag) { cnt = do_pread(buf, offset, count, &total); } else if (bflag) { cnt = do_load_vmstate(buf, offset, count, &total); } else { cnt = do_read(buf, offset, count, &total); } gettimeofday(&t2, NULL); if (cnt < 0) { printf("read failed: %s/n", strerror(-cnt)); goto out; } if (Pflag) { void *cmp_buf = g_malloc(pattern_count); memset(cmp_buf, pattern, pattern_count); if (memcmp(buf + pattern_offset, cmp_buf, pattern_count)) { printf("Pattern verification failed at offset %" PRId64 ", %d bytes/n", offset + pattern_offset, pattern_count); } g_free(cmp_buf); } if (qflag) { goto out; } if (vflag) { dump_buffer(buf, offset, count); } /* Finally, report back -- -C gives a parsable format */ t2 = tsub(t2, t1); print_report("read", &t2, offset, count, total, cnt, Cflag);out: qemu_io_free(buf); return 0;}
开发者ID:AjayMashi,项目名称:x-tier,代码行数:101,
示例12: sendfile_fstatic intsendfile_f( int argc, char **argv){ off64_t offset = 0; long long count, total; size_t blocksize, sectsize; struct timeval t1, t2; char s1[64], s2[64], ts[64]; char *infile = NULL; int Cflag, qflag; int c, fd = -1; Cflag = qflag = 0; init_cvtnum(&blocksize, §size); while ((c = getopt(argc, argv, "Cf:i:q")) != EOF) { switch (c) { case 'C': Cflag = 1; break; case 'q': qflag = 1; break; case 'f': fd = atoi(argv[1]); if (fd < 0 || fd >= filecount) { printf(_("value %d is out of range (0-%d)/n"), fd, filecount-1); return 0; } break; case 'i': infile = optarg; break; default: return command_usage(&sendfile_cmd); } } if (infile && fd != -1) return command_usage(&sendfile_cmd); if (!infile) fd = filetable[fd].fd; else if ((fd = openfile(infile, NULL, IO_READONLY, 0)) < 0) return 0; if (optind == argc - 2) { offset = cvtnum(blocksize, sectsize, argv[optind]); if (offset < 0) { printf(_("non-numeric offset argument -- %s/n"), argv[optind]); goto done; } optind++; count = cvtnum(blocksize, sectsize, argv[optind]); if (count < 0) { printf(_("non-numeric length argument -- %s/n"), argv[optind]); goto done; } } else { struct stat64 stat; if (fstat64(fd, &stat) < 0) { perror("fstat64"); goto done; } count = stat.st_size; } gettimeofday(&t1, NULL); c = send_buffer(offset, count, fd, &total); if (c < 0) goto done; if (qflag) goto done; gettimeofday(&t2, NULL); t2 = tsub(t2, t1); /* Finally, report back -- -C gives a parsable format */ timestr(&t2, ts, sizeof(ts), Cflag ? VERBOSE_FIXED_TIME : 0); if (!Cflag) { cvtstr((double)total, s1, sizeof(s1)); cvtstr(tdiv((double)total, t2), s2, sizeof(s2)); printf(_("sent %lld/%lld bytes from offset %lld/n"), total, count, (long long)offset); printf(_("%s, %d ops; %s (%s/sec and %.4f ops/sec)/n"), s1, c, ts, s2, tdiv((double)c, t2)); } else {/* bytes,ops,time,bytes/sec,ops/sec */ printf("%lld,%d,%s,%.3f,%.3f/n", total, c, ts, tdiv((double)total, t2), tdiv((double)c, t2)); }done: if (infile) close(fd); return 0;}
开发者ID:chandanr,项目名称:xfsprogs-dev,代码行数:99,
示例13: pread_f//.........这里部分代码省略......... break; case 'B': direction = IO_BACKWARD; break; case 'R': direction = IO_RANDOM; break; case 'q': qflag = 1; break; case 'u': uflag = 1; break; case 'v': vflag = 1; break;#ifdef HAVE_PREADV case 'V': vectors = strtoul(optarg, &sp, 0); if (!sp || sp == optarg) { printf(_("non-numeric vector count == %s/n"), optarg); return 0; } break;#endif case 'Z': zeed = strtoul(optarg, &sp, 0); if (!sp || sp == optarg) { printf(_("non-numeric seed -- %s/n"), optarg); return 0; } break; default: return command_usage(&pread_cmd); } } if (optind != argc - 2) return command_usage(&pread_cmd); offset = cvtnum(fsblocksize, fssectsize, argv[optind]); if (offset < 0 && (direction & (IO_RANDOM|IO_BACKWARD))) { eof = -1; /* read from EOF */ } else if (offset < 0) { printf(_("non-numeric length argument -- %s/n"), argv[optind]); return 0; } optind++; count = cvtnum(fsblocksize, fssectsize, argv[optind]); if (count < 0 && (direction & (IO_RANDOM|IO_FORWARD))) { eof = -1; /* read to EOF */ } else if (count < 0) { printf(_("non-numeric length argument -- %s/n"), argv[optind]); return 0; } if (alloc_buffer(bsize, uflag, 0xabababab) < 0) return 0; gettimeofday(&t1, NULL); switch (direction) { case IO_RANDOM: if (!zeed) /* srandom seed */ zeed = time(NULL); c = read_random(file->fd, offset, count, &total, zeed, eof); break; case IO_FORWARD: c = read_forward(file->fd, offset, count, &total, vflag, 0, eof); if (eof) count = total; break; case IO_BACKWARD: c = read_backward(file->fd, &offset, &count, &total, eof); break; default: ASSERT(0); } if (c < 0) return 0; if (qflag) return 0; gettimeofday(&t2, NULL); t2 = tsub(t2, t1); /* Finally, report back -- -C gives a parsable format */ timestr(&t2, ts, sizeof(ts), Cflag ? VERBOSE_FIXED_TIME : 0); if (!Cflag) { cvtstr((double)total, s1, sizeof(s1)); cvtstr(tdiv((double)total, t2), s2, sizeof(s2)); printf(_("read %lld/%lld bytes at offset %lld/n"), total, count, (long long)offset); printf(_("%s, %d ops; %s (%s/sec and %.4f ops/sec)/n"), s1, c, ts, s2, tdiv((double)c, t2)); } else {/* bytes,ops,time,bytes/sec,ops/sec */ printf("%lld,%d,%s,%.3f,%.3f/n", total, c, ts, tdiv((double)total, t2), tdiv((double)c, t2)); } return 0;}
开发者ID:chandanr,项目名称:xfsprogs-dev,代码行数:101,
示例14: getrusage_f/* * Report process resource utilisation. Formatting options: * "Shell" format: 0.000u 0.000s 0:00.00 0.0% 0+0k 0+0io 0pf+0w * Verbose format: * 0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 0maxresident)k * 0inputs+0outputs (0major+0minor)pagefaults 0swaps * Comma Separated Value format: 0.000,0.000,00:00:00.00,0.0,0,0,0,0,0,0 */static intgetrusage_f( int argc, char **argv){ struct timeval wallclk, timenow; struct rusage rusage; double usrtime, systime, elapsed, pct_cpu; char ts[64]; int Cflag, vflag; int c; Cflag = vflag = 0; while ((c = getopt(argc, argv, "Cv")) != EOF) { switch (c) { case 'C': Cflag = 1; break; case 'v': vflag = 1; break; default: return command_usage(&getrusage_cmd); } } if (optind != argc) return command_usage(&getrusage_cmd); if (getrusage(RUSAGE_SELF, &rusage) < 0) { perror("getrusage"); return 0; } gettimeofday(&timenow, NULL); wallclk = tsub(timenow, stopwatch); elapsed = (double)wallclk.tv_sec + ((double)wallclk.tv_usec / 1000000.0); usrtime = (double)rusage.ru_utime.tv_sec + ((double)rusage.ru_utime.tv_usec / 1000000.0); systime = (double)rusage.ru_stime.tv_sec + ((double)rusage.ru_stime.tv_usec / 1000000.0); if (elapsed < usrtime + systime) pct_cpu = 100.0; else pct_cpu = ((usrtime + systime) / elapsed) * 100; c = Cflag ? VERBOSE_FIXED_TIME : TERSE_FIXED_TIME; timestr(&wallclk, ts, sizeof(ts), c); if (Cflag) printf("%.3f,%.3f,%s,%.1f,%ld,%ld,%ld,%ld,%ld,%ld,%ld/n", usrtime, systime, ts, pct_cpu, rusage.ru_majflt, rusage.ru_minflt, rusage.ru_nswap, rusage.ru_inblock, rusage.ru_oublock, rusage.ru_nvcsw, rusage.ru_nivcsw); else if (vflag) printf("%.2fuser %.2fsystem %selapsed %.0f%%CPU " "(%ldavgtext+%ldavgdata %ldmaxresident)k/n" "%ldinputs+%ldoutputs " "(%ldmajor+%ldminor)pagefaults %ldswaps/n", usrtime, systime, ts, pct_cpu, rusage.ru_ixrss, rusage.ru_idrss, rusage.ru_maxrss, rusage.ru_inblock, rusage.ru_oublock, rusage.ru_majflt, rusage.ru_minflt, rusage.ru_nswap); else printf("%.3fu %.3fs %s %.1f%%/t" "%ld+%ldk %ld+%ldio %ldpf+%ldw/n", usrtime, systime, ts, pct_cpu, rusage.ru_maxrss, rusage.ru_ixrss, rusage.ru_inblock, rusage.ru_oublock, rusage.ru_majflt, rusage.ru_nswap); return 0;}
开发者ID:brkt,项目名称:fuse-xfs,代码行数:80,
示例15: reflink_fstatic intreflink_f( int argc, char **argv){ off64_t soffset = 0, doffset = 0; long long count = 0, total; char s1[64], s2[64], ts[64]; char *infile = NULL; int Cflag, qflag, wflag, Wflag; struct xfs_ioctl_clone_range_args args; size_t fsblocksize, fssectsize; struct timeval t1, t2; int c, fd = -1; Cflag = qflag = wflag = Wflag = 0; init_cvtnum(&fsblocksize, &fssectsize); while ((c = getopt(argc, argv, "CqwW")) != EOF) { switch (c) { case 'C': Cflag = 1; break; case 'q': qflag = 1; break; case 'w': wflag = 1; break; case 'W': Wflag = 1; break; default: return command_usage(&reflink_cmd); } } if (optind != argc - 4 && optind != argc - 1) return command_usage(&reflink_cmd); infile = argv[optind]; optind++; if (optind == argc) goto clone_all; soffset = cvtnum(fsblocksize, fssectsize, argv[optind]); if (soffset < 0) { printf(_("non-numeric src offset argument -- %s/n"), argv[optind]); return 0; } optind++; doffset = cvtnum(fsblocksize, fssectsize, argv[optind]); if (doffset < 0) { printf(_("non-numeric dest offset argument -- %s/n"), argv[optind]); return 0; } optind++; count = cvtnum(fsblocksize, fssectsize, argv[optind]); if (count < 1) { printf(_("non-positive length argument -- %s/n"), argv[optind]); return 0; }clone_all: c = IO_READONLY; fd = openfile(infile, NULL, c, 0); if (fd < 0) return 0; gettimeofday(&t1, NULL); if (count) { args.src_fd = fd; args.src_offset = soffset; args.src_length = count; args.dest_offset = doffset; c = ioctl(file->fd, XFS_IOC_CLONE_RANGE, &args); } else { c = ioctl(file->fd, XFS_IOC_CLONE, fd); } if (c < 0) { perror(_("reflink")); goto done; } total = count; c = 1; if (Wflag) fsync(file->fd); if (wflag) fdatasync(file->fd); if (qflag) goto done; gettimeofday(&t2, NULL); t2 = tsub(t2, t1); /* Finally, report back -- -C gives a parsable format */ timestr(&t2, ts, sizeof(ts), Cflag ? VERBOSE_FIXED_TIME : 0); if (!Cflag) { cvtstr((double)total, s1, sizeof(s1)); cvtstr(tdiv((double)total, t2), s2, sizeof(s2)); printf(_("linked %lld/%lld bytes at offset %lld/n"), total, count, (long long)doffset); printf(_("%s, %d ops; %s (%s/sec and %.4f ops/sec)/n"), s1, c, ts, s2, tdiv((double)c, t2));//.........这里部分代码省略.........
开发者ID:chandanr,项目名称:xfsprogs-dev,代码行数:101,
示例16: pwrite_f//.........这里部分代码省略......... case 'S': seed = strtoul(optarg, &sp, 0); if (!sp || sp == optarg) { printf(_("non-numeric seed -- %s/n"), optarg); return 0; } break; case 'q': qflag = 1; break; case 'u': uflag = 1; break; case 'w': wflag = 1; break; case 'W': Wflag = 1; break; case 'Z': zeed = strtoul(optarg, &sp, 0); if (!sp || sp == optarg) { printf(_("non-numeric seed -- %s/n"), optarg); return 0; } break; default: return command_usage(&pwrite_cmd); } } if (((skip || dflag) && !infile) || (optind != argc - 2)) return command_usage(&pwrite_cmd); if (infile && direction != IO_FORWARD) return command_usage(&pwrite_cmd); offset = cvtnum(fsblocksize, fssectsize, argv[optind]); if (offset < 0) { printf(_("non-numeric offset argument -- %s/n"), argv[optind]); return 0; } optind++; count = cvtnum(fsblocksize, fssectsize, argv[optind]); if (count < 0) { printf(_("non-numeric length argument -- %s/n"), argv[optind]); return 0; } if (alloc_buffer(bsize, uflag, seed) < 0) return 0; c = IO_READONLY | (dflag ? IO_DIRECT : 0); if (infile && ((fd = openfile(infile, NULL, c, 0)) < 0)) return 0; gettimeofday(&t1, NULL); switch (direction) { case IO_RANDOM: if (!zeed) /* srandom seed */ zeed = time(NULL); c = write_random(offset, count, zeed, &total); break; case IO_FORWARD: c = write_buffer(offset, count, bsize, fd, skip, &total); break; case IO_BACKWARD: c = write_backward(offset, &count, &total); break; default: total = 0; ASSERT(0); } if (c < 0) goto done; if (Wflag) fsync(file->fd); if (wflag) fdatasync(file->fd); if (qflag) goto done; gettimeofday(&t2, NULL); t2 = tsub(t2, t1); /* Finally, report back -- -C gives a parsable format */ timestr(&t2, ts, sizeof(ts), Cflag ? VERBOSE_FIXED_TIME : 0); if (!Cflag) { cvtstr((double)total, s1, sizeof(s1)); cvtstr(tdiv((double)total, t2), s2, sizeof(s2)); printf(_("wrote %lld/%lld bytes at offset %lld/n"), total, count, (long long)offset); printf(_("%s, %d ops; %s (%s/sec and %.4f ops/sec)/n"), s1, c, ts, s2, tdiv((double)c, t2)); } else {/* bytes,ops,time,bytes/sec,ops/sec */ printf("%lld,%d,%s,%.3f,%.3f/n", total, c, ts, tdiv((double)total, t2), tdiv((double)c, t2)); }done: if (infile) close(fd); return 0;}
开发者ID:Claruarius,项目名称:stblinux-2.6.37,代码行数:101,
示例17: pread_f//.........这里部分代码省略......... case 'b': tmp = cvtnum(fsblocksize, fssectsize, optarg); if (tmp < 0) { printf(_("non-numeric bsize -- %s/n"), optarg); return 0; } bsize = tmp; break; case 'C': Cflag = 1; break; case 'F': direction = IO_FORWARD; break; case 'B': direction = IO_BACKWARD; break; case 'R': direction = IO_RANDOM; break; case 'q': qflag = 1; break; case 'u': uflag = 1; break; case 'v': vflag = 1; break;#ifdef HAVE_PREADV case 'V': vectors = strtoul(optarg, &sp, 0); if (!sp || sp == optarg) { printf(_("non-numeric vector count == %s/n"), optarg); return 0; } break;#endif case 'Z': zeed = strtoul(optarg, &sp, 0); if (!sp || sp == optarg) { printf(_("non-numeric seed -- %s/n"), optarg); return 0; } break; default: return command_usage(&pread_cmd); } } if (optind != argc - 2) return command_usage(&pread_cmd); offset = cvtnum(fsblocksize, fssectsize, argv[optind]); if (offset < 0 && (direction & (IO_RANDOM|IO_BACKWARD))) { eof = -1; /* read from EOF */ } else if (offset < 0) { printf(_("non-numeric length argument -- %s/n"), argv[optind]); return 0; } optind++; count = cvtnum(fsblocksize, fssectsize, argv[optind]); if (count < 0 && (direction & (IO_RANDOM|IO_FORWARD))) { eof = -1; /* read to EOF */ } else if (count < 0) { printf(_("non-numeric length argument -- %s/n"), argv[optind]); return 0; } if (alloc_buffer(bsize, uflag, 0xabababab) < 0) return 0; gettimeofday(&t1, NULL); switch (direction) { case IO_RANDOM: if (!zeed) /* srandom seed */ zeed = time(NULL); c = read_random(file->fd, offset, count, &total, zeed, eof); break; case IO_FORWARD: c = read_forward(file->fd, offset, count, &total, vflag, 0, eof); if (eof) count = total; break; case IO_BACKWARD: c = read_backward(file->fd, &offset, &count, &total, eof); break; default: ASSERT(0); } if (c < 0) return 0; if (qflag) return 0; gettimeofday(&t2, NULL); t2 = tsub(t2, t1); report_io_times("read", &t2, (long long)offset, count, total, c, Cflag); return 0;}
开发者ID:djwong,项目名称:xfsprogs,代码行数:101,
示例18: main//.........这里部分代码省略......... fprintf(stderr, "main: Could not get timezone from host %s/n", pmcd_host); }#endif pmFreeResult(resp); } } /* do ParseTimeWindow stuff for -T */ if (runtime) { struct timeval res_end; /* time window end */ struct timeval start; struct timeval end; struct timeval last_delta; char *err_msg; /* parsing error message */ time_t now; struct timeval now_tv; time(&now); now_tv.tv_sec = now; now_tv.tv_usec = 0; start = now_tv; end.tv_sec = INT_MAX; end.tv_usec = INT_MAX; sts = __pmParseTime(runtime, &start, &end, &res_end, &err_msg); if (sts < 0) { fprintf(stderr, "%s: illegal -T argument/n%s", pmProgname, err_msg); exit(1); } last_delta = res_end; tsub(&last_delta, &now_tv); __pmAFregister(&last_delta, NULL, run_done_callback); last_stamp = res_end; } fprintf(stderr, "Archive basename: %s/n", archBase);#ifndef IS_MINGW /* detach yourself from the launching process */ if (isdaemon) setpgid(getpid(), 0);#endif /* set up control port */ init_ports(); __pmFD_ZERO(&fds); for (i = 0; i < CFD_NUM; ++i) { if (ctlfds[i] >= 0) __pmFD_SET(ctlfds[i], &fds); }#ifndef IS_MINGW __pmFD_SET(pmcdfd, &fds);#endif if (rsc_fd != -1) __pmFD_SET(rsc_fd, &fds); numfds = maxfd() + 1; if ((sts = do_preamble()) < 0) fprintf(stderr, "Warning: problem writing archive preamble: %s/n", pmErrStr(sts)); sts = 0; /* default exit status */
开发者ID:andyvand,项目名称:cygpcpfans,代码行数:67,
示例19: writev_fstatic int writev_f(int argc, char **argv){ struct timeval t1, t2; int Cflag = 0, qflag = 0; int c, cnt; char *buf; int64_t offset; /* Some compilers get confused and warn if this is not initialized. */ int total = 0; int nr_iov; int pattern = 0xcd; QEMUIOVector qiov; while ((c = getopt(argc, argv, "CqP:")) != EOF) { switch (c) { case 'C': Cflag = 1; break; case 'q': qflag = 1; break; case 'P': pattern = parse_pattern(optarg); if (pattern < 0) { return 0; } break; default: return command_usage(&writev_cmd); } } if (optind > argc - 2) { return command_usage(&writev_cmd); } offset = cvtnum(argv[optind]); if (offset < 0) { printf("non-numeric length argument -- %s/n", argv[optind]); return 0; } optind++; if (offset & 0x1ff) { printf("offset %" PRId64 " is not sector aligned/n", offset); return 0; } nr_iov = argc - optind; buf = create_iovec(&qiov, &argv[optind], nr_iov, pattern); if (buf == NULL) { return 0; } gettimeofday(&t1, NULL); cnt = do_aio_writev(&qiov, offset, &total); gettimeofday(&t2, NULL); if (cnt < 0) { printf("writev failed: %s/n", strerror(-cnt)); goto out; } if (qflag) { goto out; } /* Finally, report back -- -C gives a parsable format */ t2 = tsub(t2, t1); print_report("wrote", &t2, offset, qiov.size, total, cnt, Cflag);out: qemu_iovec_destroy(&qiov); qemu_io_free(buf); return 0;}
开发者ID:AjayMashi,项目名称:x-tier,代码行数:76,
示例20: readv_fstatic int readv_f(int argc, char **argv){ struct timeval t1, t2; int Cflag = 0, qflag = 0, vflag = 0; int c, cnt; char *buf; int64_t offset; /* Some compilers get confused and warn if this is not initialized. */ int total = 0; int nr_iov; QEMUIOVector qiov; int pattern = 0; int Pflag = 0; while ((c = getopt(argc, argv, "CP:qv")) != EOF) { switch (c) { case 'C': Cflag = 1; break; case 'P': Pflag = 1; pattern = parse_pattern(optarg); if (pattern < 0) { return 0; } break; case 'q': qflag = 1; break; case 'v': vflag = 1; break; default: return command_usage(&readv_cmd); } } if (optind > argc - 2) { return command_usage(&readv_cmd); } offset = cvtnum(argv[optind]); if (offset < 0) { printf("non-numeric length argument -- %s/n", argv[optind]); return 0; } optind++; if (offset & 0x1ff) { printf("offset %" PRId64 " is not sector aligned/n", offset); return 0; } nr_iov = argc - optind; buf = create_iovec(&qiov, &argv[optind], nr_iov, 0xab); if (buf == NULL) { return 0; } gettimeofday(&t1, NULL); cnt = do_aio_readv(&qiov, offset, &total); gettimeofday(&t2, NULL); if (cnt < 0) { printf("readv failed: %s/n", strerror(-cnt)); goto out; } if (Pflag) { void *cmp_buf = g_malloc(qiov.size); memset(cmp_buf, pattern, qiov.size); if (memcmp(buf, cmp_buf, qiov.size)) { printf("Pattern verification failed at offset %" PRId64 ", %zd bytes/n", offset, qiov.size); } g_free(cmp_buf); } if (qflag) { goto out; } if (vflag) { dump_buffer(buf, offset, qiov.size); } /* Finally, report back -- -C gives a parsable format */ t2 = tsub(t2, t1); print_report("read", &t2, offset, qiov.size, total, cnt, Cflag);out: qemu_iovec_destroy(&qiov); qemu_io_free(buf); return 0;}
开发者ID:AjayMashi,项目名称:x-tier,代码行数:97,
示例21: write_f//.........这里部分代码省略......... case 'p': pflag = 1; break; case 'P': Pflag = 1; pattern = parse_pattern(optarg); if (pattern < 0) { return 0; } break; case 'q': qflag = 1; break; case 'z': zflag = 1; break; default: return command_usage(&write_cmd); } } if (optind != argc - 2) { return command_usage(&write_cmd); } if (bflag + pflag + zflag > 1) { printf("-b, -p, or -z cannot be specified at the same time/n"); return 0; } if (zflag && Pflag) { printf("-z and -P cannot be specified at the same time/n"); return 0; } offset = cvtnum(argv[optind]); if (offset < 0) { printf("non-numeric length argument -- %s/n", argv[optind]); return 0; } optind++; count = cvtnum(argv[optind]); if (count < 0) { printf("non-numeric length argument -- %s/n", argv[optind]); return 0; } if (!pflag) { if (offset & 0x1ff) { printf("offset %" PRId64 " is not sector aligned/n", offset); return 0; } if (count & 0x1ff) { printf("count %d is not sector aligned/n", count); return 0; } } if (!zflag) { buf = qemu_io_alloc(count, pattern); } gettimeofday(&t1, NULL); if (pflag) { cnt = do_pwrite(buf, offset, count, &total); } else if (bflag) { cnt = do_save_vmstate(buf, offset, count, &total); } else if (zflag) { cnt = do_co_write_zeroes(offset, count, &total); } else if (cflag) { cnt = do_write_compressed(buf, offset, count, &total); } else { cnt = do_write(buf, offset, count, &total); } gettimeofday(&t2, NULL); if (cnt < 0) { printf("write failed: %s/n", strerror(-cnt)); goto out; } if (qflag) { goto out; } /* Finally, report back -- -C gives a parsable format */ t2 = tsub(t2, t1); print_report("wrote", &t2, offset, count, total, cnt, Cflag);out: if (!zflag) { qemu_io_free(buf); } return 0;}
开发者ID:AjayMashi,项目名称:x-tier,代码行数:101,
示例22: write_fstatic intwrite_f(int argc, char **argv){ struct timeval t1, t2; int Cflag = 0, pflag = 0, qflag = 0, bflag = 0; int c, cnt; char *buf; int64_t offset; int count; int total = 0; int pattern = 0xcd; while ((c = getopt(argc, argv, "bCpP:q")) != EOF) { switch (c) { case 'b': bflag = 1; break; case 'C': Cflag = 1; break; case 'p': pflag = 1; break; case 'P': pattern = parse_pattern(optarg); if (pattern < 0) return 0; break; case 'q': qflag = 1; break; default: return command_usage(&write_cmd); } } if (optind != argc - 2) return command_usage(&write_cmd); if (bflag && pflag) { printf("-b and -p cannot be specified at the same time/n"); return 0; } offset = cvtnum(argv[optind]); if (offset < 0) { printf("non-numeric length argument -- %s/n", argv[optind]); return 0; } optind++; count = cvtnum(argv[optind]); if (count < 0) { printf("non-numeric length argument -- %s/n", argv[optind]); return 0; } if (!pflag) { if (offset & 0x1ff) { printf("offset %" PRId64 " is not sector aligned/n", offset); return 0; } if (count & 0x1ff) { printf("count %d is not sector aligned/n", count); return 0; } } buf = qemu_io_alloc(count, pattern); gettimeofday(&t1, NULL); if (pflag) cnt = do_pwrite(buf, offset, count, &total); else if (bflag) cnt = do_save_vmstate(buf, offset, count, &total); else cnt = do_write(buf, offset, count, &total); gettimeofday(&t2, NULL); if (cnt < 0) { printf("write failed: %s/n", strerror(-cnt)); goto out; } if (qflag) goto out; t2 = tsub(t2, t1); print_report("wrote", &t2, offset, count, total, cnt, Cflag);out: qemu_io_free(buf); return 0;}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:100,
示例23: multiwrite_f//.........这里部分代码省略......... if (pattern < 0) { return 0; } break; default: return command_usage(&writev_cmd); } } if (optind > argc - 2) { return command_usage(&writev_cmd); } nr_reqs = 1; for (i = optind; i < argc; i++) { if (!strcmp(argv[i], ";")) { nr_reqs++; } } reqs = g_malloc0(nr_reqs * sizeof(*reqs)); buf = g_malloc0(nr_reqs * sizeof(*buf)); qiovs = g_malloc(nr_reqs * sizeof(*qiovs)); for (i = 0; i < nr_reqs && optind < argc; i++) { int j; /* Read the offset of the request */ offset = cvtnum(argv[optind]); if (offset < 0) { printf("non-numeric offset argument -- %s/n", argv[optind]); goto out; } optind++; if (offset & 0x1ff) { printf("offset %lld is not sector aligned/n", (long long)offset); goto out; } if (i == 0) { first_offset = offset; } /* Read lengths for qiov entries */ for (j = optind; j < argc; j++) { if (!strcmp(argv[j], ";")) { break; } } nr_iov = j - optind; /* Build request */ buf[i] = create_iovec(&qiovs[i], &argv[optind], nr_iov, pattern); if (buf[i] == NULL) { goto out; } reqs[i].qiov = &qiovs[i]; reqs[i].sector = offset >> 9; reqs[i].nb_sectors = reqs[i].qiov->size >> 9; optind = j + 1; pattern++; } /* If there were empty requests at the end, ignore them */ nr_reqs = i; gettimeofday(&t1, NULL); cnt = do_aio_multiwrite(reqs, nr_reqs, &total); gettimeofday(&t2, NULL); if (cnt < 0) { printf("aio_multiwrite failed: %s/n", strerror(-cnt)); goto out; } if (qflag) { goto out; } /* Finally, report back -- -C gives a parsable format */ t2 = tsub(t2, t1); print_report("wrote", &t2, first_offset, total, total, cnt, Cflag);out: for (i = 0; i < nr_reqs; i++) { qemu_io_free(buf[i]); if (reqs[i].qiov != NULL) { qemu_iovec_destroy(&qiovs[i]); } } g_free(buf); g_free(reqs); g_free(qiovs); return 0;}
开发者ID:AjayMashi,项目名称:x-tier,代码行数:101,
示例24: multiwrite_f//.........这里部分代码省略......... while ((c = getopt(argc, argv, "CqP:")) != EOF) { switch (c) { case 'C': Cflag = 1; break; case 'q': qflag = 1; break; case 'P': pattern = parse_pattern(optarg); if (pattern < 0) return 0; break; default: return command_usage(&writev_cmd); } } if (optind > argc - 2) return command_usage(&writev_cmd); nr_reqs = 1; for (i = optind; i < argc; i++) { if (!strcmp(argv[i], ";")) { nr_reqs++; } } reqs = qemu_malloc(nr_reqs * sizeof(*reqs)); buf = qemu_malloc(nr_reqs * sizeof(*buf)); qiovs = qemu_malloc(nr_reqs * sizeof(*qiovs)); for (i = 0; i < nr_reqs; i++) { int j; offset = cvtnum(argv[optind]); if (offset < 0) { printf("non-numeric offset argument -- %s/n", argv[optind]); return 0; } optind++; if (offset & 0x1ff) { printf("offset %lld is not sector aligned/n", (long long)offset); return 0; } if (i == 0) { first_offset = offset; } for (j = optind; j < argc; j++) { if (!strcmp(argv[j], ";")) { break; } } nr_iov = j - optind; reqs[i].qiov = &qiovs[i]; buf[i] = create_iovec(reqs[i].qiov, &argv[optind], nr_iov, pattern); reqs[i].sector = offset >> 9; reqs[i].nb_sectors = reqs[i].qiov->size >> 9; optind = j + 1; offset += reqs[i].qiov->size; pattern++; } gettimeofday(&t1, NULL); cnt = do_aio_multiwrite(reqs, nr_reqs, &total); gettimeofday(&t2, NULL); if (cnt < 0) { printf("aio_multiwrite failed: %s/n", strerror(-cnt)); goto out; } if (qflag) goto out; t2 = tsub(t2, t1); print_report("wrote", &t2, first_offset, total, total, cnt, Cflag);out: for (i = 0; i < nr_reqs; i++) { qemu_io_free(buf[i]); qemu_iovec_destroy(&qiovs[i]); } qemu_free(buf); qemu_free(reqs); qemu_free(qiovs); return 0;}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:101,
注:本文中的tsub函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ tsvalue函数代码示例 C++ tstring_from_utf8函数代码示例 |