ext: Monkeypatch os.waitpid to extract CPU time from subprocess
authorRichard Cooper <richard.cooper@arm.com>
Fri, 14 Aug 2020 11:19:55 +0000 (12:19 +0100)
committerGiacomo Travaglini <giacomo.travaglini@arm.com>
Fri, 25 Sep 2020 14:12:09 +0000 (14:12 +0000)
commitfe2817270ea9630c2fbc868bb093581b8a6b8a09
tree6e765b023f1e79ca60d6c080a424e5914c04eb91
parent63e96992568d8a8a0dccac477b8b7f1370ac7e98
ext: Monkeypatch os.waitpid to extract CPU time from subprocess

Added utility class `TimedWaitPID` which monkey-patches os.waitpid()
with a functor that has the same signature, but calls os.wait4()
instead. This allows the process's user and system CPU time to be
obtained from the OS when using APIs (such as subprocess) which use
os.waitpid() internally.

The process CPU time is stored within the functor and can be read back
later by calling TimedWaitPID.get_time_for_pid().

JIRA: https://gem5.atlassian.net/browse/GEM5-548

Change-Id: I9ebe9ca1241a4f28c90ad31f672f32ac52786664
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/32652
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
ext/testlib/helper.py