[MOAB-dev] r2533 - MOAB/trunk/test/perf

kraftche at mcs.anl.gov kraftche at mcs.anl.gov
Mon Jan 12 14:00:44 CST 2009


Author: kraftche
Date: 2009-01-12 14:00:44 -0600 (Mon, 12 Jan 2009)
New Revision: 2533

Added:
   MOAB/trunk/test/perf/adj_time.cpp
Modified:
   MOAB/trunk/test/perf/Makefile.am
Log:
add simple performance tests of adjacency queries

Modified: MOAB/trunk/test/perf/Makefile.am
===================================================================
--- MOAB/trunk/test/perf/Makefile.am	2009-01-12 20:00:25 UTC (rev 2532)
+++ MOAB/trunk/test/perf/Makefile.am	2009-01-12 20:00:44 UTC (rev 2533)
@@ -7,8 +7,9 @@
             
 LDADD = $(top_builddir)/libMOAB.la
 
-check_PROGRAMS = perf seqperf 
+check_PROGRAMS = perf seqperf adj_time
 
 perf_SOURCES = perf.cpp
 seqperf_SOURCES = seqperf.cpp
+adj_time_SOURCES = adj_time.cpp
 

Added: MOAB/trunk/test/perf/adj_time.cpp
===================================================================
--- MOAB/trunk/test/perf/adj_time.cpp	                        (rev 0)
+++ MOAB/trunk/test/perf/adj_time.cpp	2009-01-12 20:00:44 UTC (rev 2533)
@@ -0,0 +1,74 @@
+#include "MBCore.hpp"
+#include "MBRange.hpp"
+#include <iostream>
+#include <assert.h>
+#include <time.h>
+
+#define STRINGIFY_(X) #X
+#define STRINGIFY(X) STRINGIFY_(X)
+#ifndef SRCDIR
+# define SRCDIR .
+#endif
+
+const char* default_input_file = "../mb_big_test.g";
+
+int main()
+{
+  MBErrorCode rval;
+  MBCore moab;
+  MBInterface& mb = moab;
+  
+    // load test file
+  MBEntityHandle set;
+  rval = mb.load_file( default_input_file, set );
+  if (MB_SUCCESS != rval) {
+    std::cerr << default_input_file <<": failed to load file." << std::endl;
+    return 1;
+  }
+  
+    // get all region elements
+  MBRange vols;
+  rval = mb.get_entities_by_dimension( 0, 3, vols );
+  if (MB_SUCCESS != rval)
+    return 2;
+  if (vols.empty())
+    return 1;
+  
+    // create internal face elements
+  MBRange faces;
+  rval = mb.get_adjacencies( vols, 2, true, faces, MBInterface::UNION );
+  if (MB_SUCCESS != rval)
+    return 2;
+  assert(faces.size() > vols.size());
+  
+    // time query of all adjacent volumes
+  std::vector<MBEntityHandle> adj;
+  clock_t t_0 = clock();
+  for (MBRange::iterator i = faces.begin(); i != faces.end(); ++i) {
+    adj.clear();
+    rval = mb.get_adjacencies( &*i, 1, 3, false, adj );
+    if (MB_SUCCESS != rval)
+      return 2;
+    assert( adj.size() == 1 || adj.size() == 2 );
+  }
+  clock_t t_up = clock() - t_0;
+  std::cout << "Querying of volumes for " << faces.size() << " faces: "
+            << t_up/(double)CLOCKS_PER_SEC << " seconds" << std::endl;
+  
+    // time downward adjacency query from volumes to faces
+  t_0 = clock();
+  for (MBRange::iterator i = vols.begin(); i != vols.end(); ++i) {
+    adj.clear();
+    rval = mb.get_adjacencies( &*i, 1, 1, false, adj );
+    if (MB_SUCCESS != rval)
+      return 2;
+    assert( adj.size() > 3 );
+  }
+  clock_t t_down = clock() - t_0;
+  std::cout << "Querying of faces for " << vols.size() << " volumes: "
+            << t_down/(double)CLOCKS_PER_SEC << " seconds" << std::endl;
+  
+  
+  return 0;
+}
+




More information about the moab-dev mailing list