[opengtl-commits] [565] add a tool to run benchmark of the GTL's memory manager

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 565
Author:   cyrille
Date:     2009-02-27 17:56:10 +0100 (Fri, 27 Feb 2009)

Log Message:
-----------
add a tool to run benchmark of the GTL's memory manager

Modified Paths:
--------------
    trunk/OpenGTL/OpenGTL/tools/CMakeLists.txt

Added Paths:
-----------
    trunk/OpenGTL/OpenGTL/tools/mmbenchmark/
    trunk/OpenGTL/OpenGTL/tools/mmbenchmark/CMakeLists.txt
    trunk/OpenGTL/OpenGTL/tools/mmbenchmark/MMBenchmark.cpp


Modified: trunk/OpenGTL/OpenGTL/tools/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenGTL/tools/CMakeLists.txt	2009-02-27 15:57:21 UTC (rev 564)
+++ trunk/OpenGTL/OpenGTL/tools/CMakeLists.txt	2009-02-27 16:56:10 UTC (rev 565)
@@ -1,2 +1,3 @@
 add_subdirectory(convert)
-add_subdirectory(imagecompare)
\ No newline at end of file
+add_subdirectory(imagecompare)
+add_subdirectory(mmbenchmark)
\ No newline at end of file

Added: trunk/OpenGTL/OpenGTL/tools/mmbenchmark/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenGTL/tools/mmbenchmark/CMakeLists.txt	                        (rev 0)
+++ trunk/OpenGTL/OpenGTL/tools/mmbenchmark/CMakeLists.txt	2009-02-27 16:56:10 UTC (rev 565)
@@ -0,0 +1,9 @@
+include_directories( ${CMAKE_SOURCE_DIR} )
+
+set( mmbenchmark_SRCS
+     MMBenchmark.cpp )
+
+add_executable(mmbenchmark ${mmbenchmark_SRCS})
+
+target_link_libraries(mmbenchmark GTLCore )
+

Added: trunk/OpenGTL/OpenGTL/tools/mmbenchmark/MMBenchmark.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/tools/mmbenchmark/MMBenchmark.cpp	                        (rev 0)
+++ trunk/OpenGTL/OpenGTL/tools/mmbenchmark/MMBenchmark.cpp	2009-02-27 16:56:10 UTC (rev 565)
@@ -0,0 +1,62 @@
+/*
+ *  Copyright (c) 2009 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <GTLCore/MemoryManager_p.h>
+
+#include <iostream>
+#include <cstdlib>
+
+// GTLCore Headers
+#include <GTLCore/String.h>
+
+void printHelp()
+{
+  std::cout << "Usage : mmbenchmark [memorymanager]" << std::endl;
+  std::cout << std::endl;
+  std::cout << "memorymanager: gtlmm osmm" << std::endl;
+}
+
+#define _COUNT_LOOP_ 1000000
+#define _OBJECT_SIZE_ 10
+
+int main(int argc, char** argv)
+{
+  if( argc != 2)
+  {
+    printHelp();
+  } else {
+    GTLCore::String mode = argv[1]; 
+    if( mode == "gtlmm" ) {
+      for(int i = 0; i < _COUNT_LOOP_; ++i)
+      {
+        void* ptr = GTLCore::MemoryManager::allocate(_OBJECT_SIZE_);
+        GTLCore::MemoryManager::desallocate(ptr);
+      }
+    } else if( mode == "osmm" ) {
+      for(int i = 0; i < _COUNT_LOOP_; ++i)
+      {
+        void *ptr = malloc(_OBJECT_SIZE_);
+        free(ptr);
+      }
+    } else {
+      printHelp();
+    }
+  }
+}
+


Property changes on: trunk/OpenGTL/OpenGTL/tools/mmbenchmark/MMBenchmark.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/