收集已执行脚本的资源使用情况

psprofile的Python项目详细描述


psprofile

python进程分析器。监视进程树并发出资源使用度量。使用psutil库,因此在Mac和Linux上运行(尚未测试Windows, 但理论上是可行的)。根据操作系统的不同,您将得到略有不同的字段。 由Cosmos Workflow Management System使用。

安装

pip安装psprofile

用法

$ psprofile -h
usage: psprofile [-h][-o OUTPUT_FILE][-i POLL_INTERVAL][-w WAIT] ...

Profile resource usage of a command

positional arguments:
  command               The command to run.

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPUT_FILE, --output_file OUTPUT_FILE
                        File to store output of profile to.
  -i POLL_INTERVAL, --poll_interval POLL_INTERVAL
                        How often to poll the resource usage information in
                        /proc, in seconds (default 1).
  -w WAIT, --wait WAIT  time to waitfor executable to exist

$ psprofile ls $HOME
$ psprofile python test.py
$ psprofile "echo hi; sleep ls"# note that:
$ psprofile echo hi > tmp/test  #  (psprofile's output is redirected)
# is not the same as:
$ psprofile "echo hi > /tmp/test"#  (echo's output is redirected)

示例输出:

$ psprofile /path/to/bash.script
{"avg_num_threads":1,"cpu_time":0,"avg_vms_mem_kb":11427840,"io_read_kb":4096,"io_write_kb":0,"max_num_threads":1,"system_time":0,"max_rss_mem_kb":1470464,"percent_cpu":0,"max_vms_mem_kb":11427840,"wall_time":2,"ctx_switch_voluntary":12,"user_time":0,"avg_num_fds":4,"num_polls":1,"max_num_fds":4,"io_write_count":0,"avg_rss_mem_kb":1470464,"ctx_switch_involuntary":3,"io_read_count":12,"exit_status":0}

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何表示1。。Java中的n关系   java在安卓应用程序中添加polaris viewer   Java字符串::replaceAll仅替换第一个出现(可能不正确的正则表达式)   java Tomcat/JBoss部署后脚本   如何在Heroku Java应用程序中运行发出web请求的周期进程   java如何以纳秒为单位证明算法的时间   Solaris上的java自定义ListCellRenderer(使用jre5)   java试图为我的播放器类测试块实现播放器重力(RealtutsGml平台教程)   c#消耗一个。带有java的net web服务未显示预期结果   java在KOI8\R中检索html   基于java图形的搜索与基于随机的搜索   java如何检查安卓设备上的可用空间?在SD卡上?