我使用 pgbench 运行了一堆测试,记录了结果:
run-params: 1 1 1
transaction type: SELECT only
scaling factor: 1
query mode: simple
number of clients: 1
number of threads: 1
duration: 90 s
number of transactions actually processed: 280465
tps = 3116.254233 (including connections establishing)
tps = 3116.936248 (excluding connections establishing)
run-params: 1 1 2
transaction type: SELECT only
scaling factor: 1
query mode: simple
number of clients: 1
number of threads: 1
duration: 90 s
number of transactions actually processed: 505943
tps = 5621.570463 (including connections establishing)
tps = 5622.811538 (excluding connections establishing)
run-params: 10000 10 3
transaction type: SELECT only
scaling factor: 10000
query mode: simple
number of clients: 10
number of threads: 1
duration: 90 s
number of transactions actually processed: 10
tps = 0.012268 (including connections establishing)
tps = 0.012270 (excluding connections establishing)
我想提取图形的值。同时尝试学习AWK。这是我的 AWK 程序:
/run-params/ { scaling = $2 ; clients = $3 ; attempt = $4 }
/^tps.*excluding/ { print $scaling "," $clients "," $attempt "," $3 }
当我运行它时,我得到以下输出:
$ awk -f b.awk -- b.log
tps,tps,tps,3116.936248
tps,tps,=,5622.811538
,,0.012270,0.012270
这不是我想要的。
我明白什么时候scaling = 1
,1 引用字段 1,在这种情况下恰好是 tps。当 scaling = 10000 时,因为行上没有 10000 个字段,所以返回 null。我确实尝试使用 分配缩放和朋友"" $2
,但无济于事。
如何在后续操作块中使用/报告数值?