我有一个带有逗号分隔值的CSV,因为我使用JMeter的CMDRunner.jar进行性能测试,提供一段时间内的延迟/请求。
2017/02/03 11:15:41.593,15,End-to-end request-response,15
2017/02/03 11:15:41.609,6,Request body is proxied successfully to the backend,6
2017/02/03 11:15:41.616,5,x-junction-path validator,5
2017/02/03 11:15:41.622,9,Invalid content type sent by client ,9
2017/02/03 11:15:41.634,3,Invalid content type requested by client ,3
2017/02/03 11:15:42.595,10,End-to-end request-response,10
2017/02/03 11:15:42.606,10,Request body is proxied successfully to the backend,10
2017/02/03 11:15:42.616,9,x-junction-path validator,9
2017/02/03 11:15:42.625,8,Invalid content type sent by client ,8
2017/02/03 11:15:42.635,5,Invalid content type requested by client ,4
2017/02/03 11:15:43.599,3,End-to-end request-response,3
2017/02/03 11:15:43.603,6,Request body is proxied successfully to the backend,6
2017/02/03 11:15:43.609,7,x-junction-path validator,7
2017/02/03 11:15:43.617,4,Invalid content type sent by client ,4
2017/02/03 11:15:43.622,7,Invalid content type requested by client ,7我想汇总每个请求的延迟,这意味着每个请求只有一个条目,以及相应的聚合延迟。第3列和第4列。有没有一个jmeter插件来获得这个结果,或者我如何在BASH中做到这一点?
预期输出(例如):
注意:由于这是一个聚合,所以时间戳和经过时间(第2列)是不相关的。
End-to-end request-response,12.31
equest body is proxied successfully to the backend,6.1
x-junction-path validator,5.0
Invalid content type sent by client, 3.12
Invalid content type requested by client ,3.01发布于 2017-02-03 20:24:26
Awk可以帮助你做到这一点,
awk 'BEGIN{FS=OFS=","}{unique[$3]+=$4; count[$3]++;}END{for (i in unique) print i, unique[i]/count[i]}' file
x-junction-path validator,7
Invalid content type requested by client ,4.66667
Invalid content type sent by client ,7
Request body is proxied successfully to the backend,7.33333
End-to-end request-response,9.33333也可以使用浮点算术上具有.2度精度的printf,如
awk 'BEGIN{FS=","}{unique[$3]+=$4; count[$3]++;}END{for (i in unique) printf "%s,%0.2f\n", i, unique[i]/count[i]}' file
x-junction-path validator,7.00
Invalid content type requested by client ,4.67
Invalid content type sent by client ,7.00
Request body is proxied successfully to the backend,7.33
End-to-end request-response,9.33https://stackoverflow.com/questions/42023859
复制相似问题