#ifndef __COMMAND_H__
#define __COMMAND_H__
+#include <sys/time.h>
+
#define CMD_FLAG_GLOBAL ((int)0x80000000) /* don't iterate "args" */
typedef int (*cfunc_t)(int argc, char **argv);
extern int command_usage(const cmdinfo_t *ci);
extern int command(const cmdinfo_t *ci, int argc, char **argv);
+extern void report_io_times(const char *verb, struct timeval *t2,
+ long long offset, long long count,
+ long long total, int ops, int compact);
+
#endif /* __COMMAND_H__ */
long long count, total, tmp;
size_t fsblocksize, fssectsize;
struct timeval t1, t2;
- char s1[64], s2[64], ts[64];
char *sp;
int Cflag, qflag, uflag, vflag;
int eof = 0, direction = IO_FORWARD;
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));
- }
+ report_io_times("read", &t2, (long long)offset, count, total, c, Cflag);
return 0;
}
unsigned int zeed = 0, seed = 0xcdcdcdcd;
size_t fsblocksize, fssectsize;
struct timeval t1, t2;
- char s1[64], s2[64], ts[64];
char *sp, *infile = NULL;
int Cflag, qflag, uflag, dflag, wflag, Wflag;
int direction = IO_FORWARD;
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));
- }
+ report_io_times("wrote", &t2, (long long)offset, count, total, c,
+ Cflag);
done:
if (infile)
close(fd);
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;
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));
- }
+ report_io_times("sent", &t2, (long long)offset, count, total, c, Cflag);
done:
if (infile)
close(fd);
doneline(input, v);
}
}
+
+void
+report_io_times(
+ const char *verb,
+ struct timeval *t2,
+ long long offset,
+ long long count,
+ long long total,
+ int ops,
+ int compact)
+{
+ char s1[64], s2[64], ts[64];
+
+ timestr(t2, ts, sizeof(ts), compact ? VERBOSE_FIXED_TIME : 0);
+ if (!compact) {
+ cvtstr((double)total, s1, sizeof(s1));
+ cvtstr(tdiv((double)total, *t2), s2, sizeof(s2));
+ printf(_("%s %lld/%lld bytes at offset %lld\n"),
+ verb, total, count, (long long)offset);
+ printf(_("%s, %d ops; %s (%s/sec and %.4f ops/sec)\n"),
+ s1, ops, ts, s2, tdiv((double)ops, *t2));
+ } else {/* bytes,ops,time,bytes/sec,ops/sec */
+ printf("%lld,%d,%s,%.3f,%.3f\n",
+ total, ops, ts,
+ tdiv((double)total, *t2), tdiv((double)ops, *t2));
+ }
+}