【问题标题】:measure execution time in linux在linux中测量执行时间
【发布时间】:2015-07-10 10:00:17
【问题描述】:

所以我在linux下用树莓派做一个质量保证任务,7个程序分别是preload、preload.c、run_test、run_test.c、runit_mainain、runit_preload、runit_test。

我所做的是运行 runit_preload,然后运行 ​​run_test,然后拔下树莓派,最后运行 runit_maintain。我需要记录每个程序的执行时间,但每次我尝试 time -p runit_preload 或 time -p ./preload.c 时,它从不显示时间,而是再次运行程序。

【问题讨论】:

标签: linux testing software-quality


【解决方案1】:

如果您已经在 C 中使用过 time API(在 C 中搜索 gettime 函数),这将更容易且更准确。您在 main 函数的开始和结束时获得时间值并运行您的程序。多次重复此过程以获得最差的运行时间。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-23
    • 1970-01-01
    • 1970-01-01
    • 2013-03-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多