How can I get the CPU time for a perl system call?

后端 未结 3 1884
梦毁少年i
梦毁少年i 2021-01-22 20:00

I have a perl script that calls external executables using system(). I would like to measure the CPU seconds taken by these external programs. Ideally, I would like

3条回答
  •  不思量自难忘°
    2021-01-22 20:52

    You've tested the command with bash, but you passed it to sh.

    system("time (ls)")
    

    is short for

    system("/bin/sh", "-c", "time (ls)")
    

    but you want

    system("/bin/bash", "-c", "time (ls)")
    

提交回复
热议问题