Skip to content

Commit 793dbfc

Browse files
committed
Refactored to use psutil crate for macos support
1 parent fbcf6dc commit 793dbfc

File tree

6 files changed

+148
-187
lines changed

6 files changed

+148
-187
lines changed

Cargo.lock

+76-101
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "procrec"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
authors = ["Lars Baumgaertner"]
55
description = "Record/Plot cpu and memory usage of processes"
66
edition = "2018"
@@ -15,6 +15,6 @@ readme = "README.md"
1515

1616
[dependencies]
1717
clap = { git = "https://github.com/clap-rs/clap/" }
18-
procfs = "0.7.7"
1918
tempfile = "3.1.0"
2019
ctrlc = "3.1.4"
20+
psutil = { version = "3.0.1", default-features = false, features = ["process"] }

README.md

+15-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
A simple recorder for cpu and memory usage of processes.
44

5-
Currently, limited to linux but support for macOS might come in the future. Results are outputted in machine parsable format to stdout or can be directly plotted using gnuplot (must be in `$PATH`).
5+
Currently, linux as well as macos are supported. Results are outputted in machine parsable format to stdout or can be directly plotted using gnuplot (must be in `$PATH`).
66

77
## Installation
88

@@ -48,24 +48,27 @@ OPTIONS:
4848

4949
Interactive recording of specific process:
5050
```
51-
$ pgrep chrome
51+
$ pgrep iTerm
5252
4730
5353
4742
5454
4748
5555
4769
5656
4772
5757
5858
$ procrec -p 4730 -g -i 1 -v
59-
0.00 PID 4730 CPU% 1.00 RSS 283265 VSIZE 3794771968 THREADS 33
60-
1.00 PID 4730 CPU% 3.00 RSS 283263 VSIZE 3794771968 THREADS 33
61-
2.00 PID 4730 CPU% 1.33 RSS 283263 VSIZE 3794771968 THREADS 33
62-
3.01 PID 4730 CPU% 1.00 RSS 283265 VSIZE 3794771968 THREADS 33
63-
4.01 PID 4730 CPU% 0.80 RSS 283265 VSIZE 3794771968 THREADS 33
64-
5.01 PID 4730 CPU% 2.00 RSS 283265 VSIZE 3794771968 THREADS 34
65-
6.01 PID 4730 CPU% 1.00 RSS 283265 VSIZE 3794771968 THREADS 34
66-
7.02 PID 4730 CPU% 2.67 RSS 283288 VSIZE 3794771968 THREADS 34
67-
8.02 PID 4730 CPU% 0.80 RSS 283288 VSIZE 3794771968 THREADS 34
68-
^C9.02 PID 4730 CPU% 1.33 RSS 283288 VSIZE 3794771968 THREADS 34
59+
0.00 PID 1119 CPU% 4.32 RSS 549793 VSIZE 10123419
60+
1.00 PID 1119 CPU% 7.84 RSS 549863 VSIZE 10123137
61+
2.01 PID 1119 CPU% 2.96 RSS 549830 VSIZE 10119688
62+
3.01 PID 1119 CPU% 2.47 RSS 547377 VSIZE 10087645
63+
4.01 PID 1119 CPU% 3.65 RSS 547340 VSIZE 10091315
64+
5.01 PID 1119 CPU% 3.31 RSS 547340 VSIZE 10091315
65+
6.01 PID 1119 CPU% 2.63 RSS 547377 VSIZE 10087645
66+
7.01 PID 1119 CPU% 3.87 RSS 539983 VSIZE 10074480
67+
8.01 PID 1119 CPU% 3.34 RSS 539992 VSIZE 10074480
68+
9.02 PID 1119 CPU% 2.68 RSS 540028 VSIZE 10070810
69+
10.02 PID 1119 CPU% 3.75 RSS 539992 VSIZE 10074480
70+
11.02 PID 1119 CPU% 3.43 RSS 539451 VSIZE 10073919
71+
^C12.03 PID 1119 CPU% 8.01 RSS 272269 VSIZE 9775452
6972
7073
```
7174

img/gnuplot.png

84.1 KB
Loading

recording.plot

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
set autoscale
22

3-
set ylabel "CPU %" tc lt 3
4-
set y2label "Memory (kB)" tc lt 4
5-
set xlabel "Times (s)"
3+
set ylabel "CPU %" tc lt 1 font ",12"
4+
set y2label "Memory (kB)" tc lt 20 font ",12" offset 1,0
5+
set xlabel "Times (s)" font ",12"
66

77
set ytic auto
88
set y2tic auto
@@ -13,5 +13,5 @@ set xtics auto
1313

1414
set key right center # legend placement
1515
unset key
16-
plot filename using 1:5 title "CPU" with l lt 3 lw 2, \
17-
"" using 1:7 title "RSS" with l lt 4 lw 2 axes x1y2
16+
plot filename using 1:5 title "CPU" with l lt 1 lw 2, \
17+
"" using 1:7 title "RSS" with l lt 20 lw 2 axes x1y2

0 commit comments

Comments
 (0)