[netperf-dev] netperf2 commit notice r254 - in trunk: . src

raj at netperf.org raj at netperf.org
Mon Mar 10 10:47:38 PDT 2008


Author: raj
Date: 2008-03-10 10:47:38 -0700 (Mon, 10 Mar 2008)
New Revision: 254

Modified:
   trunk/config.h.in
   trunk/src/netsys_hpux11i.c
Log:
use rounded doubles rather than integer math when calculating cpu frequency in megahertz

Modified: trunk/config.h.in
===================================================================
--- trunk/config.h.in	2008-03-07 23:46:34 UTC (rev 253)
+++ trunk/config.h.in	2008-03-10 17:47:38 UTC (rev 254)
@@ -271,7 +271,8 @@
 /* Use Linux's ethtool interface to determine driver information. */
 #undef USE_ETHTOOL
 
-/* Use Linux's ethtool interface to determine driver information. */
+/* Use HP-UX's sysinfo and pstat interfaces to determine system information.
+   */
 #undef USE_HPUX
 
 /* Use Solaris's kstat interface to measure CPU util. */

Modified: trunk/src/netsys_hpux11i.c
===================================================================
--- trunk/src/netsys_hpux11i.c	2008-03-07 23:46:34 UTC (rev 253)
+++ trunk/src/netsys_hpux11i.c	2008-03-10 17:47:38 UTC (rev 254)
@@ -1,6 +1,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <string.h>
+#include <math.h>
 #include <sys/pstat.h>
 
 /* tusc can be a very useful thing... */
@@ -35,13 +36,17 @@
 
   if (ret > 0) {
 #ifdef PAP_MAX_CACHE_LEVELS
-    /* we can get it "directly" */
-    *cpu_frequency = processor_info.psp_cpu_frequency / 1000000;
+    /* we can get it "directly" but to help make things reconcile with
+       what other tools/platforms support, we shouldn't do a simple
+       integer divide - instead, we should do our division in floating
+       point and then round */
+    *cpu_frequency = rint((double)processor_info.psp_cpu_frequency / 
+			  1000000.0);
 #else
     /* older OSes were "known" to be on CPUs where the itick was
        1to1 here */
-    *cpu_frequency = 
-      (processor_info.psp_iticksperclktick * sysconf(_SC_CLK_TCK)) / 1000000;
+    *cpu_frequency = rint(((double)processor_info.psp_iticksperclktick * 
+			   (double)sysconf(_SC_CLK_TCK)) / 1000000.0);
 #endif 
   }
   else



More information about the netperf-dev mailing list