Skip to main content

Collects resource usage of an executed script

Project description

PsProfile

A python process profiler. Watches a process tree and emits resource usage metrics. Uses the psutil library, so runs on a mac and linux (haven’t tested Windows, but theoretically it will work). You will get slightly different fields back depending on the operating system. Used by the Cosmos Workflow Management System.

Install

pip install psprofile

Usage

$ 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 wait for 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)

Example output:

$ 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
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

psprofile-0.1.11.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file psprofile-0.1.11.tar.gz.

File metadata

  • Download URL: psprofile-0.1.11.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for psprofile-0.1.11.tar.gz
Algorithm Hash digest
SHA256 24a58b64aee86a27061105d45f2a368ad3a9d3eef29a4b52a03952de71c910e1
MD5 e6027f30cea51d1b0e90aeb64d599ceb
BLAKE2b-256 f584934634cf761e795e066edf1fd2ac3dadb3308885bcdf4575f8a2a6993958

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page