我正在运行以下命令并将标准输出存储到文本文件中。我需要将 unix 时间戳添加到每行输出文件以确定每个操作的开始和结束时间。
$ ./bin/ycsb load mongodb -s -P workloads/workloada -p mongodb.url=mongodb://172.28.128.5:27017 -p mongodb.database=ycsb > outputLoad.txt
输出结果如下:
$ cat outputLoad.txt
mongo client connection created with mongodb://172.28.128.5:27017
[OVERALL], RunTime(ms), 65348.0
[OVERALL], Throughput(ops/sec), 1530.2687151863868
[CLEANUP], Operations, 1.0
[CLEANUP], AverageLatency(us), 9732.0
[CLEANUP], MinLatency(us), 9728.0
[CLEANUP], MaxLatency(us), 9735.0
[CLEANUP], 95thPercentileLatency(us), 9735.0
[CLEANUP], 99thPercentileLatency(us), 9735.0
[INSERT], Operations, 100000.0
[INSERT], AverageLatency(us), 634.39211
[INSERT], MinLatency(us), 83.0
[INSERT], MaxLatency(us), 434175.0
[INSERT], 95thPercentileLatency(us), 769.0
[INSERT], 99thPercentileLatency(us), 3417.0
[INSERT], Return=0, 100000
谢谢!
答案1
正如@mschuett提到的,只需将%s添加到命令中如下:
$ ./bin/ycsb load mongodb -s -P workloads/workloada -p mongodb.url=mongodb://172.28.128.5:27017 -p mongodb.database=ycsb | ts [%s] > outpuLoad.txt
输出结果如下:
$ cat outputLoad.txt
[1443106507] [INSERT], Operations, 10000.0
[1443106507] [INSERT], AverageLatency(us), 1114.4243
[1443106507] [INSERT], MinLatency(us), 379.0
[1443106507] [INSERT], MaxLatency(us), 550399.0
[1443106507] [INSERT], 95thPercentileLatency(us), 1288.0
[1443106507] [INSERT], 99thPercentileLatency(us), 8679.0
[1443106507] [INSERT], Return=0, 10000