我发现我可以使用以下命令来测量Windows上的执行时间:

Measure-Command {start-process python .\script.py -Wait}

而且效果很好。不幸的是,当我尝试运行带有一些(位置和可选)自变量的脚本时,收到一条错误消息,其中包含
Measure-Command {start-process python .\script.py file.txt 100 -Wait}

我得到了错误:



没有Measure-Command,一切正常。

我究竟做错了什么?如何衡量带有参数的脚本的执行时间?

最佳答案

尝试

Measure-Command {start-process python -ArgumentList (".\script.py", "file.txt", 100) -Wait}

10-08 02:40