我目前正在一些OJ系统上,并运行我的程序后,系统会发出时间和内存使用。 我知道有./time
,可以检查出使用时间,怎么样的记忆? 或者是有可能同时检查任何命令?
Answer 1:
使用valgrind
。
valgrind your_exec
当你的进程退出, valgrind
将输出的分配字节的总结/时的执行时间和多少空间释放刚刚退出前还在分配
输出示例:
==840==
==840== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 17 from 1)
==840== malloc/free: in use at exit: 88,940 bytes in 163 blocks.
==840== malloc/free: 376 allocs, 213 frees, 208,624 bytes allocated.
文章来源: linux - How to check out how much memory and time used after the program terminated?