A profiling tool to peek and profile the memory or cpu usage of a process

Peekprof

Get the CPU and Memory usage of a single process, monitor it live, and extract it in CSV and HTML. Get the best out of your optimizations.

Usage

The profiling is designed to run until the running process terminates. If you wish to terminate the profiler sooner, just interrupt the process and it will safely terminate the program and write the results.

Usage: peekprof {-pid <pid>|-cmd <command>} [-html <filename>] [-csv <filename>] [-printoutput]
  [-refresh <integer>{ns|ms|s|m}] [-prc-output] [-parent] [-live] [-livehost <host>] [nooutput]

Output

  The output depends on if you've set the flag -pretty or not.

  With pretty:

  parent id: 5312                                           # (only if -parent is used)
  command id: 5312                                          # (only if -cmd is used)
  00:13:09        memory usage: 26 mb      cpu usage: 8.2%% # Loop
  peak memory: 2 mb                                         # Print peak memory
  20.852955893s                                             # Print profiling time

  Without pretty (csv friendly except two last lines):

  timestamp, rss kb, %%cpu                                           # Print csv heading
  2021-10-04 00:14:12.635316944 +0300 EEST m=+11.947601412,2956,0.0  # Loop
  peak memory: 2 mb                                                  # Print peak memory
  20.852955893s                                                      # Print profiling time


Flags

  -pid Track a running process

  -cmd Execute a command and track its memory usage

  -html Extract a chart into an HTML file

  -csv Extract timestamped memory data into a csv

  -refresh The interval at which it checks the memory usage of the process
       [default is 100ms]
  
  -live Combined with -html provides an html file that listens live updates for the process' stats.
       [default is true]

  -livehost Is the host at which the local running server is running. This is used with -live and -html.
       [default is localhost:8089]

  -pssoutput Print the corresponding output of the process to stdout & stderr
  
  -parent Track the parent of the provided PID. If no parent exists, an error is returned
      unless -force is provided. If -cmd is provided this is ignored.

  -pretty Print in a more human-friendly - non-csv format, and print the pid of the running process if -cmd or -parent is used.

  -nooutput Stop printing the profiler's output to console

Extract CSV and Chart

peekprof -pid 47123 -html out.html -csv out.csv

Get memory usage by PID

peekprof -pid 47123

Get memory usage from a running command

peekprof -cmd="go test -bench=. -benchtime 300x"

Change refresh rate

peekprof -pid 53432 -refresh 50ms # Refresh every 50 milliseconds

Profile the parent of a process by child pid

peekprof -pid 53432 -parent

Support

Current support is for Linux and OSX.

OSX differences

  • Swap is not currenty supported, thus it is not shown either in the extracted files.
  • -parent is supported only in Linux
  • In Linux, the process and process' children metrics are tracked. Currently this behavior is not implemented for OSX.

License

MIT © Apostolis Anastasiou

Owner
Apostolis A.
Software Engineer & Web Developer
Apostolis A.
Similar Resources

A simple Via CEP Wrapper to demonstrate GoLang tests usage

via-cep-wrapper A simple Via CEP Wrapper to demonstrate GoLang tests usage Purpose Demonstrate how struct services could make easy to build and test a

May 18, 2022

Simple 'UserKit' for Malware written in Go. Startup, Hidden Files, Critical Process and Registry Watcher

GoUserKit Simple UserKit for Malware written in Go Features Makes Process Critical (NtSetInformationProcess) Hides Files Simple Add to Startup (HKCU R

Jan 3, 2023

An experimental distribution of Temporal that runs as a single process

Temporalite ⚠️ This project is experimental and not suitable for production use. ⚠️ Temporalite is a distribution of Temporal that runs as a single pr

Dec 31, 2022

Coding Challenge for Fullstacklabs Hiring Process

Cuboids Challenge This API manages bags and cuboids. A cuboid is a three-dimensional rectangular box. Each face of a cuboid is a rectangle and adjacen

Mar 31, 2022

Helps exercise your memory by giving you random tokens and poems to memorize.

memory-enhancer Helps exercise your memory by giving you random tokens and poems to memorize. Using Every day when you first open your terminal you wi

Nov 9, 2021

A project that provides an in-memory key-value store as a REST API. Also, it's containerized and can be used as a microservice.

Easy to Use In-Memory Key-Value Store A project that provides an in-memory key-value store as a REST API. Also, it's containerized and can be used as

Mar 6, 2022

Implement a toy in-memory store information service for a delivery company

Implement a toy in-memory store information service for a delivery company

Nov 22, 2021

An in-memory, key-value store HTTP API service

This is an in-memory key-value store HTTP API service, with the following endpoints: /get/{key} : GET method. Returns the value of a previously set ke

May 23, 2022

Safira - In memory of my dog Safira

Safira - In memory of my dog Safira

In memory of my dog Safira. The tool safira replaces pattern_offset.rb and patte

Jan 11, 2022
:chart_with_upwards_trend: Monitors Go MemStats + System stats such as Memory, Swap and CPU and sends via UDP anywhere you want for logging etc...

Package stats Package stats allows for gathering of statistics regarding your Go application and system it is running on and sent them via UDP to a se

Nov 10, 2022
Search running process for a given dll/function. Exposes a bufio.Scanner-like interface for walking a process' PEB

Search running process for a given dll/function. Exposes a bufio.Scanner-like interface for walking a process' PEB

Apr 21, 2022
A tool suite for Redis profiling

Insecticide Insecticide is a tool suite for Redis profiling. It finds ambiguous values in your redis configuration.

Dec 13, 2021
Continuous profiling for long-term postmortem analysis

profefe, a continuous profiling system, collects profiling data from a fleet of running applications and provides API for querying profiling samples for postmortem performance analysis.

Dec 27, 2022
conprof - Continuous Profiling
 conprof - Continuous Profiling

conprof - Continuous Profiling Conprof is a continuous profiling project. Continuous profiling is the act of taking profiles of programs in a systemat

Feb 10, 2022
create temporary Firefox profile, install user.js and extensions, launch Firefox

tmpfox tmpfox is a Firefox wrapper that: Creates a temporary Firefox profile Installs user.js configuration file from Arkenfox for increased privacy a

Jul 27, 2022
Best-effort CPU-local sharded values for Go
Best-effort CPU-local sharded values for Go

percpu Percpu is a Go package to support best-effort CPU-local sharded values. This package is something of an experiment. See Go issue #18802 for dis

Nov 9, 2022
Script that sets your nzxt kraken temps based on cpu temps on linux

liquidctl-cpu-temp Script that monitors cpu temps and sets cpu cooler temps according to entered fan/pump curves. Only tested on NZXT kraken z63 requi

Nov 16, 2021
Operating system cpu scheduler algorithms

features first-come-first-serve algorithm. shortest-job-first algorithm. round-r

Dec 23, 2022
this is an example of hystrix-go usage in web dev

hystrix-go-example this is an example of hystrix-go usage in web dev Explanation this example contains 2 service: alpha as our main service, circuit b

Apr 22, 2022