// 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>
-#include <malloc.h>
+#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
{
{
if (getrusage(who, &rusage_begin) != 0 )
memset(&rusage_begin, 0, sizeof(rusage_begin));
+ malloc(0); // Needed for some implementations.
allocation_begin = mallinfo();
}
int
allocated_memory() const
- { return allocation_end.arena - allocation_begin.arena; }
+ { return allocation_end.uordblks - allocation_begin.uordblks; }
long
hard_page_fault() const
{
const char space = ' ';
const char tab = '\t';
- const char* name = "libstdc++-v3.performance";
+ const char* name = "libstdc++-v3-performance.sum";
std::string::const_iterator i = file.begin() + file.find_last_of('/') + 1;
std::string testname(i, file.end());
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