This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH (libstdc++-v3): Port testsuite/testsuite_performance.h


>Frankly, I'd rather unconditionally kill it.  This is in test code not
>run by most non-developers at this point. 

I think you should just do it in a way that works for BSD. As you say,
let's not get overly wrapped-up in making this work everywhere.

> I think we are looking for
>a semi- to fully- POSIX way to learn "amount of memory owned by this
>process".  Anyone?  (I'd know how to do it for various systems in a
>non-standard way.)

At some point, these wrapper classes could be extended for TAU, or other
performance orientated libraries (Perfometer?). The thought was that
here's something that should work, and if people feel like plugging in
something more exotic, well, all they have to do is replace a header
file and run, without re-instrumenting the whole testsuite.

Anyway. Here's another patch for this.

-benjamin

2003-06-24  Benjamin Kosnik  <bkoz@redhat.com>
            Ulrich Drepper  <drepper@redhat.com>

	* testsuite/testsuite_performance.h: Tweak mallinfo.

Index: testsuite/testsuite_performance.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/testsuite_performance.h,v
retrieving revision 1.3
diff -c -p -r1.3 testsuite_performance.h
*** testsuite/testsuite_performance.h	24 Jun 2003 06:41:38 -0000	1.3
--- testsuite/testsuite_performance.h	24 Jun 2003 19:25:52 -0000
***************
*** 33,47 ****
  
  #include <sys/times.h>
  #include <sys/resource.h>
! #ifdef __FreeBSD__
! #include <stdlib.h>
! #else
! #include <malloc.h>
! #endif
  #include <string>
  #include <fstream>
  #include <iomanip>
  
  namespace __gnu_cxx_test
  {
    class time_counter
--- 33,54 ----
  
  #include <sys/times.h>
  #include <sys/resource.h>
! #include <cstdlib>
  #include <string>
  #include <fstream>
  #include <iomanip>
  
+ #ifdef __linux__
+ #include <malloc.h>
+ #else
+ extern "C"
+ {
+   struct mallinfo { int uordblks; };
+   struct mallinfo empty = { 0 };
+   struct mallinfo mallinfo(void) { return empty; }
+ }
+ #endif
+ 
  namespace __gnu_cxx_test
  {
    class time_counter
*************** namespace __gnu_cxx_test
*** 85,95 ****
      { 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;
--- 92,97 ----
*************** namespace __gnu_cxx_test
*** 116,122 ****
      { 
        if (getrusage(who, &rusage_begin) != 0 )
  	memset(&rusage_begin, 0, sizeof(rusage_begin));
!       // allocation_begin = mallinfo();
      }
      
      void
--- 118,125 ----
      { 
        if (getrusage(who, &rusage_begin) != 0 )
  	memset(&rusage_begin, 0, sizeof(rusage_begin));
!       malloc(0); // Needed for some implementations.
!       allocation_begin = mallinfo();
      }
      
      void
*************** namespace __gnu_cxx_test
*** 124,135 ****
      { 
        if (getrusage(who, &rusage_end) != 0 )
  	memset(&rusage_end, 0, sizeof(rusage_end));
!       // allocation_end = mallinfo();
      }
  
      int
      allocated_memory() const
!     { return allocation_end.arena - allocation_begin.arena; }
      
      long 
      hard_page_fault() const
--- 127,138 ----
      { 
        if (getrusage(who, &rusage_end) != 0 )
  	memset(&rusage_end, 0, sizeof(rusage_end));
!       allocation_end = mallinfo();
      }
  
      int
      allocated_memory() const
!     { return allocation_end.uordblks - allocation_begin.uordblks; }
      
      long 
      hard_page_fault() const
*************** namespace __gnu_cxx_test
*** 181,187 ****
      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.hard_page_fault() << "pf" << space;
      
      out << std::endl;
--- 184,190 ----
      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.hard_page_fault() << "pf" << space;
      
      out << std::endl;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]