[netperf-dev] netperf4 commit notice r136 -
branches/glib_migration/src
raj at netperf.org
raj at netperf.org
Thu Apr 6 18:34:09 PDT 2006
Author: raj
Date: 2006-04-06 18:34:08 -0700 (Thu, 06 Apr 2006)
New Revision: 136
Modified:
branches/glib_migration/src/netperf.c
branches/glib_migration/src/netsysstats_linux.c
branches/glib_migration/src/netsysstats_none.c
Log:
Fixes for CPU utilization under Linux, and make the netsysstats_none always
show a CPU utilization of 100%
Modified: branches/glib_migration/src/netperf.c
===================================================================
--- branches/glib_migration/src/netperf.c 2006-04-06 21:43:27 UTC (rev 135)
+++ branches/glib_migration/src/netperf.c 2006-04-07 01:34:08 UTC (rev 136)
@@ -939,7 +939,7 @@
/* wait for test to initialize */
while (test->state == TEST_PREINIT) {
NETPERF_MUTEX_UNLOCK(h->hash_lock);
- if (debug) {
+ if (debug > 1) {
fprintf(where,
"resolve_dependency: waiting on test %s thread %d\n",
(char *)id,
Modified: branches/glib_migration/src/netsysstats_linux.c
===================================================================
--- branches/glib_migration/src/netsysstats_linux.c 2006-04-06 21:43:27 UTC (rev 135)
+++ branches/glib_migration/src/netsysstats_linux.c 2006-04-07 01:34:08 UTC (rev 136)
@@ -145,7 +145,7 @@
void
get_cpu_time_counters(cpu_time_counters_t *res,
- struct timeval *time,
+ struct timeval *timestamp,
test_t *test)
{
@@ -154,14 +154,18 @@
char cpunam[64];
uint64_t nicetime;
netsysstat_data_t *tsd = GET_TEST_DATA(test);
+ double elapsed; /* well, it isn't really "elapsed" */
NETPERF_DEBUG_ENTRY(test->debug,test->where);
+ gettimeofday(timestamp,NULL);
+ elapsed = (double)timestamp->tv_sec +
+ ((double)timestamp->tv_usec / (double)1000000);
if (test->debug) {
fprintf(test->where,
"__func__ res %p timeptr %p test %p tsd %p\n",
res,
- time,
+ timestamp,
test,
tsd);
fflush(test->where);
@@ -185,12 +189,21 @@
&nicetime,
&(res[i].kernel),
&(res[i].idle));
+ res[i].calibrate = (uint64_t)(elapsed * (double)sysconf(_SC_CLK_TCK));
res[i].user += nicetime;
- res[i].other = 0;
res[i].interrupt = 0;
+ res[i].other = res[i].calibrate;
+ res[i].other -= res[i].idle;
+ res[i].other -= res[i].user;
+ res[i].other -= res[i].kernel;
+ res[i].other -= res[i].interrupt;
- if(test->debug) {
+ if (test->debug) {
fprintf(test->where,
+ "\tcalibrate[%d] = 0x%"PRIx64" ",
+ i,
+ res[i].calibrate);
+ fprintf(test->where,
"\tidle[%d] = 0x%"PRIx64" ",
i,
res[i].idle);
Modified: branches/glib_migration/src/netsysstats_none.c
===================================================================
--- branches/glib_migration/src/netsysstats_none.c 2006-04-06 21:43:27 UTC (rev 135)
+++ branches/glib_migration/src/netsysstats_none.c 2006-04-07 01:34:08 UTC (rev 136)
@@ -51,14 +51,42 @@
return NPE_SUCCESS;
}
+/* slightly kludgy to get the CPU util to come-out as 100% */
+static uint64_t user,kernel,other,interrupt,idle = 0;
+
void
get_cpu_time_counters(cpu_time_counters_t *res,
- struct timeval *time,
+ struct timeval *timestamp,
test_t *test)
{
+ int i;
+ netsysstat_data_t *tsd = GET_TEST_DATA(test);
+
NETPERF_DEBUG_ENTRY(test->debug,test->where);
+ gettimeofday(timestamp,NULL);
+
+ /* this should result in the CPU util being forever reported as
+ 100% */
+
+ user += 10000;
+ kernel += 10000;
+ interrupt += 10000;
+ idle += 1;
+
+ for (i = 0; i < tsd->num_cpus; i++) {
+ res[i].user = user;
+ res[i].kernel = kernel;
+ res[i].interrupt = interrupt;
+ res[i].idle = idle;
+ res[i].calibrate = res[i].user +
+ res[i].kernel +
+ res[i].interrupt +
+ res[i].idle;
+ res[i].other = 0;
+ }
+
NETPERF_DEBUG_EXIT(test->debug, test->where);
}
More information about the netperf-dev
mailing list