小编Pet*_*ter的帖子

有没有像 time 这样的命令,但用于内存使用?

有没有类似的命令time,但它会报告更多的统计信息?如果我能做这样的事情,那就太好了:

$ statistics some_command
time:
    real    0m3.002s
    user    0m0.000s
    sys     0m0.000s
memory:
    min     41K
    peak    2.5M
    mean    1.1M
. . .
Run Code Online (Sandbox Code Playgroud)

如果能走得更远,那就太好了。现在,为了调试,我要么全神贯注地盯着top(实际上glances),要么在我的代码中散布语句。

如果有什么我可以传递命令的东西,那就太棒了。

编辑

我可能已经找到了一个解决方案:perf在包linux-toolslinux-tools-commonUbuntu 12.04 上。

$ perf stat ./someprocess
Performance counter stats for './someprocess':

      12007.384578 task-clock                #    0.996 CPUs utilized          
             1,092 context-switches          #    0.000 M/sec                  
                16 CPU-migrations            #    0.000 M/sec                  
           295,102 page-faults               #    0.025 M/sec                  
    40,553,682,299 cycles                    #    3.377 GHz                     [83.33%]
    18,400,458,723 stalled-cycles-frontend   #   45.37% frontend …
Run Code Online (Sandbox Code Playgroud)

memory linux time profiling

49
推荐指数
3
解决办法
2万
查看次数

标签 统计

linux ×1

memory ×1

profiling ×1

time ×1