]> gcc.gnu.org Git - gcc.git/blobdiff - libstdc++-v3/testsuite/testsuite_performance.h
Ugh, copied the wrong date from previous test case.
[gcc.git] / libstdc++-v3 / testsuite / testsuite_performance.h
index 9aea757445833e8c43e84c0a6df2d88b3ee1ee7e..9ec2f865191372ec549a4b363de8d4e0d5ebf77f 100644 (file)
 // invalidate any other reasons why the executable file might be covered by
 // the GNU General Public License.
 
-#ifndef _GLIBCPP_PERFORMANCE_H
-#define _GLIBCPP_PERFORMANCE_H
+#ifndef _GLIBCXX_PERFORMANCE_H
+#define _GLIBCXX_PERFORMANCE_H
 
 #include <sys/times.h>
 #include <sys/resource.h>
-#ifdef __FreeBSD__
-#include <stdlib.h>
-#else
-#include <malloc.h>
-#endif
+#include <cstdlib>
 #include <string>
 #include <fstream>
 #include <iomanip>
 
-namespace __gnu_cxx_test
+#ifdef __linux__
+#include <malloc.h>
+#elif defined (__FreeBSD__)
+extern "C"
+{
+  struct mallinfo { int uordblks; };
+  struct mallinfo mallinfo(void)
+    { struct mallinfo m = { (((size_t) sbrk (0) + 1023) / 1024) }; return m; }
+}
+#else
+extern "C"
+{
+  struct mallinfo { int uordblks; };
+  struct mallinfo empty = { 0 };
+  struct mallinfo mallinfo(void) { return empty; }
+}
+#endif
+
+namespace __gnu_test
 {
   class time_counter
   {
@@ -85,11 +99,6 @@ namespace __gnu_cxx_test
     { return tms_end.tms_stime - tms_begin.tms_stime; }
   };
 
-#ifdef __FreeBSD__
-  struct mallinfo { int arena; };
-  int mallinfo (void) { return 0; }
-#endif
-
   class resource_counter
   {
     int                who;
@@ -116,7 +125,8 @@ namespace __gnu_cxx_test
     { 
       if (getrusage(who, &rusage_begin) != 0 )
        memset(&rusage_begin, 0, sizeof(rusage_begin));
-      // allocation_begin = mallinfo();
+      malloc(0); // Needed for some implementations.
+      allocation_begin = mallinfo();
     }
     
     void
@@ -124,12 +134,12 @@ namespace __gnu_cxx_test
     { 
       if (getrusage(who, &rusage_end) != 0 )
        memset(&rusage_end, 0, sizeof(rusage_end));
-      // allocation_end = mallinfo();
+      allocation_end = mallinfo();
     }
 
     int
     allocated_memory() const
-    { return allocation_end.arena - allocation_begin.arena; }
+    { return allocation_end.uordblks - allocation_begin.uordblks; }
     
     long 
     hard_page_fault() const
@@ -167,7 +177,7 @@ namespace __gnu_cxx_test
   {
     const char space = ' ';
     const char tab = '\t';
-    const char* name = "libstdc++-v3.performance";
+    const char* name = "libstdc++-performance.sum";
     std::string::const_iterator i = file.begin() + file.find_last_of('/') + 1;
     std::string testname(i, file.end());
 
@@ -181,13 +191,13 @@ namespace __gnu_cxx_test
     out << std::setw(4) << t.real_time() << "r" << space;
     out << std::setw(4) << t.user_time() << "u" << space;
     out << std::setw(4) << t.system_time() << "s" << space;
-    //    out << std::setw(4) << r.allocated_memory() << "mem" << space;
+    out << std::setw(4) << r.allocated_memory() << "mem" << space;
     out << std::setw(4) << r.hard_page_fault() << "pf" << space;
     
     out << std::endl;
     out.close();
   }
-}; // namespace __gnu_cxx_test
+}; // namespace __gnu_test
 
-#endif // _GLIBCPP_PERFORMANCE_H
+#endif // _GLIBCXX_PERFORMANCE_H
 
This page took 0.0292 seconds and 5 git commands to generate.