Recompute CPU usage
This commit is contained in:
parent
2381523f5f
commit
c7ed704eb0
72
time-1.7-Recompute-CPU-usage-at-microsecond-level.patch
Normal file
72
time-1.7-Recompute-CPU-usage-at-microsecond-level.patch
Normal file
@ -0,0 +1,72 @@
|
||||
From 0d743a7d946fe176a07baf2586a6af0e867fd89c Mon Sep 17 00:00:00 2001
|
||||
From: H.J. Lu <hongjiu.lu@intel.com>
|
||||
Date: Wed, 11 May 2011 16:19:55 +0200
|
||||
Subject: [PATCH] Recompute CPU usage at microsecond level
|
||||
|
||||
If job finishes quickly, miliseconds arithmetic rounds to zero. If
|
||||
that happens, recalculate CPU usage ratio with microsecond accuracy
|
||||
to raise chance to get non-zero values.
|
||||
---
|
||||
resuse.h | 2 ++
|
||||
time.c | 15 +++++++++++++++
|
||||
2 files changed, 17 insertions(+), 0 deletions(-)
|
||||
|
||||
diff --git a/resuse.h b/resuse.h
|
||||
index 992143f..7a3ee66 100644
|
||||
--- a/resuse.h
|
||||
+++ b/resuse.h
|
||||
@@ -33,9 +33,11 @@ struct timeval
|
||||
#if HAVE_SYS_RUSAGE_H
|
||||
/* This rusage structure measures nanoseconds instead of microseconds. */
|
||||
# define TV_MSEC tv_nsec / 1000000
|
||||
+# define TV_USEC tv_nsec / 1000
|
||||
# include <sys/rusage.h>
|
||||
#else
|
||||
# define TV_MSEC tv_usec / 1000
|
||||
+# define TV_USEC tv_usec
|
||||
# if HAVE_WAIT3
|
||||
# include <sys/resource.h>
|
||||
# else
|
||||
diff --git a/time.c b/time.c
|
||||
index 43aec0b..96cfdde 100644
|
||||
--- a/time.c
|
||||
+++ b/time.c
|
||||
@@ -326,6 +326,8 @@ summarize (fp, fmt, command, resp)
|
||||
{
|
||||
unsigned long r; /* Elapsed real milliseconds. */
|
||||
unsigned long v; /* Elapsed virtual (CPU) milliseconds. */
|
||||
+ unsigned long ru; /* Elapsed real microseconds. */
|
||||
+ unsigned long vu; /* Elapsed virtual (CPU) microseconds. */
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
@@ -350,6 +352,17 @@ summarize (fp, fmt, command, resp)
|
||||
v = resp->ru.ru_utime.tv_sec * 1000 + resp->ru.ru_utime.TV_MSEC +
|
||||
resp->ru.ru_stime.tv_sec * 1000 + resp->ru.ru_stime.TV_MSEC;
|
||||
|
||||
+ if (r == 0 && v == 0)
|
||||
+ {
|
||||
+ ru = resp->elapsed.tv_usec;
|
||||
+ vu = resp->ru.ru_utime.TV_USEC + resp->ru.ru_stime.TV_USEC;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ ru = 0;
|
||||
+ vu = 0;
|
||||
+ }
|
||||
+
|
||||
while (*fmt)
|
||||
{
|
||||
switch (*fmt)
|
||||
@@ -408,6 +421,8 @@ summarize (fp, fmt, command, resp)
|
||||
/* % cpu is (total cpu time)/(elapsed time). */
|
||||
if (r > 0)
|
||||
fprintf (fp, "%lu%%", (v * 100 / r));
|
||||
+ else if (ru > 0)
|
||||
+ fprintf (fp, "%lu%%", (vu * 100 / ru));
|
||||
else
|
||||
fprintf (fp, "?%%");
|
||||
break;
|
||||
--
|
||||
1.7.4.4
|
||||
|
||||
@ -9,6 +9,8 @@ Source: ftp://prep.ai.mit.edu/pub/gnu/%{name}/%{name}-%{version}.tar.gz
|
||||
Patch0: time-1.7-destdir.patch
|
||||
Patch1: time-1.7-verbose.patch
|
||||
Patch2: time-1.7-ru_maxrss-is-in-kilobytes-on-Linux.patch
|
||||
# Bug #527276
|
||||
Patch3: time-1.7-Recompute-CPU-usage-at-microsecond-level.patch
|
||||
Requires(post): /sbin/install-info
|
||||
Requires(preun): /sbin/install-info
|
||||
|
||||
@ -22,6 +24,7 @@ the results.
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
%patch2 -p1 -b .ru_maxrss
|
||||
%patch3 -p1 -b .recompute_cpu
|
||||
|
||||
%build
|
||||
echo "ac_cv_func_wait3=\${ac_cv_func_wait3='yes'}" >> config.cache
|
||||
@ -50,6 +53,7 @@ fi
|
||||
* Wed May 11 2011 Petr Pisar <ppisar@redhat.com> - 1.7-39
|
||||
- Fix maximal RSS report (bug #702826)
|
||||
- Clean spec file
|
||||
- Recompute CPU usage at finer level (bug #527276)
|
||||
|
||||
* Wed Feb 09 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.7-38
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
|
||||
|
||||
Loading…
Reference in New Issue
Block a user