This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] testsuite_performance tweaks
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 24 Jun 2003 15:37:26 -0400 (EDT)
- Subject: [v3] testsuite_performance tweaks
tested x86/linux w/ nods to BSD codepath
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;