Skip to content

Instantly share code, notes, and snippets.

@mbstadler
Created August 23, 2022 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbstadler/3f5131b5aa88f87196d030a82081e1ea to your computer and use it in GitHub Desktop.
Save mbstadler/3f5131b5aa88f87196d030a82081e1ea to your computer and use it in GitHub Desktop.
path file for snakemake v7.8.3 (return the values of read_chars and write_chars from psutil, in addition to the default read_bytes and write_bytes)
diff -u -r -P -N snakemake-7.8.3/snakemake/benchmark.py snakemake-7.8.3-fmi/snakemake/benchmark.py
--- snakemake-7.8.3/snakemake/benchmark.py 2022-06-20 12:52:22.000000000 +0200
+++ snakemake-7.8.3-fmi/snakemake/benchmark.py 2022-06-27 17:55:04.896298826 +0200
@@ -36,6 +36,8 @@
"max_pss",
"io_in",
"io_out",
+ "io_char_in",
+ "io_char_out",
"mean_load",
"cpu_time",
)
@@ -50,6 +52,8 @@
max_pss=None,
io_in=None,
io_out=None,
+ io_char_in=None,
+ io_char_out=None,
cpu_usages=None,
cpu_time=None,
):
@@ -67,6 +71,10 @@
self.io_in = io_in
#: I/O written in bytes
self.io_out = io_out
+ #: I/O read in characters (independent of cache etc.)
+ self.io_char_in = io_char_in
+ #: I/O written in characters (independent of cache etc.)
+ self.io_char_out = io_char_out
#: Count of CPU seconds, divide by running time to get mean load estimate
self.cpu_usages = cpu_usages or 0
#: CPU usage (user and system) in seconds
@@ -113,6 +121,8 @@
self.max_pss,
self.io_in,
self.io_out,
+ self.io_char_in,
+ self.io_char_out,
self.cpu_usages / self.running_time,
self.cpu_time,
),
@@ -219,7 +229,7 @@
# Memory measurements
rss, vms, uss, pss = 0, 0, 0, 0
# I/O measurements
- io_in, io_out = 0, 0
+ io_in, io_out, io_char_in, io_char_out = 0, 0, 0, 0
check_io = True
# CPU seconds
cpu_usages = 0
@@ -248,6 +258,8 @@
ioinfo = proc.io_counters()
io_in += ioinfo.read_bytes
io_out += ioinfo.write_bytes
+ io_char_in += ioinfo.read_chars
+ io_char_out += ioinfo.write_chars
except NotImplementedError as nie:
# OS doesn't track IO
check_io = False
@@ -267,9 +279,13 @@
if check_io:
io_in /= 1024 * 1024
io_out /= 1024 * 1024
+ io_char_in /= 1024 * 1024
+ io_char_out /= 1024 * 1024
else:
io_in = None
io_out = None
+ io_char_in = None
+ io_char_out = None
except psutil.Error as e:
return
@@ -282,6 +298,8 @@
self.bench_record.io_in = io_in
self.bench_record.io_out = io_out
+ self.bench_record.io_char_in = io_char_in
+ self.bench_record.io_char_out = io_char_out
self.bench_record.cpu_usages += cpu_usages
self.bench_record.cpu_time = cpu_time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment