(1)创建一个test.c文件
int main(int argc,char **argv)
{
int i;
int number;
//number测试次数
number = atoi(argv[1]);//atoi ASCI to int
for(i=0;i<number;i++)
{
system("./a.out");//默认测试文件./a.out
}
}
atoi :ASCI to int 将获取的ASIC 字符转换为int型
(2)gcc编译gcc test.c -o test
(3)编译待测试文件
eg:编写的线程文件 thread6.c
gcc thread6.c -pthread
(与test.c的运行文件命名匹配)
(4)
./test 5 >>result.txt &
另待测试文件运行5次,将测试结果输出到创建的result.txt文件中 ==&==不要忘记
回车得到进程id
也可通过
ps -aux|grep test 查询进程运行
kill -9 进程id号 消除进程
(5)打开txt文件查看测试结果