简体   繁体   English

Linux上的基准程序

[英]Benchmarking programs on Linux

for an assignment we need to benchmark our implementations with different optimizations and parameters. 对于任务,我们需要使用不同的优化和参数对我们的实现进行基准测试。 Is there a feasible way of benchmarking little programs on the linux command line (I know of time) with different parameters which gives me the time data as CSV or something similiar? 有没有一种可行的方法来对linux命令行(我知道时间)上的小程序进行基准测试,使用不同的参数,这样可以将时间数据作为CSV或类似的东西? Output could be something like: 输出可能是这样的:

Implementation      Time     
A                    23s
B with -O3 2Threads  15s 
B with -O3 4Threads  10s 

I'm pretty sure that I've seen something like that on some professors slides but I cant remember who or when it was... 我很确定我在一些教授幻灯片上看到过类似的东西,但是我不记得是谁或者什么时候......

Why not using time command inside a bash script, something like : 为什么不在bash脚本中使用time命令,例如:

#!/bin/bash

NPROG=`cat proglist | wc -l`
for i in `seq 1 ${NPROG}`
do
    PROG=`sed -n "${i}p" proglist`
    ARG=`sed -n "${i}p" arglist`
    TIME=`{ time ${PROG} ${ARG}; } 2>&1 | grep real | awk '{print $2}'`
    echo "${TIME} ${PROG} ${ARG}"
done

where proglist is a text file containing the programs to execute 其中proglist是包含要执行的程序的文本文件

A
B
B

and arglist is a text file containing the arguments, something like : arglist是一个包含参数的文本文件,如:

-a 1 -b 2
-f "foo"
-f "bar"

The output of the script will look-like : 脚本的输出看起来像:

 0m32.000s A -a 1 -b 2
 1m12.000s B -f "foo"
 5m38.000s B -f "bar"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM