(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檔案檢視測試結果