[Lemon-commits] [lemon_svn] alpar: r963 - hugo/trunk/src/benchmark

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:42:27 CET 2006


Author: alpar
Date: Tue Jul 20 11:50:11 2004
New Revision: 963

Added:
   hugo/trunk/src/benchmark/bench_tools.h
Modified:
   hugo/trunk/src/benchmark/Makefile.am
   hugo/trunk/src/benchmark/graph-bench.cc
   hugo/trunk/src/benchmark/hcube.cc

Log:
Some tools of common usage was put to bench_tool.h


Modified: hugo/trunk/src/benchmark/Makefile.am
==============================================================================
--- hugo/trunk/src/benchmark/Makefile.am	(original)
+++ hugo/trunk/src/benchmark/Makefile.am	Tue Jul 20 11:50:11 2004
@@ -2,6 +2,6 @@
 
 noinst_PROGRAMS = graph-bench hcube
 
-graph_bench_SOURCES = graph-bench.cc
+graph_bench_SOURCES = graph-bench.cc bench_tools.h
 
-hcube_SOURCES = hcube.cc
+hcube_SOURCES = hcube.cc bench_tools.h

Added: hugo/trunk/src/benchmark/bench_tools.h
==============================================================================
--- (empty file)
+++ hugo/trunk/src/benchmark/bench_tools.h	Tue Jul 20 11:50:11 2004
@@ -0,0 +1,73 @@
+// -*- mode:C++ -*-
+#ifndef HUGO_BENCH_TEST_H
+#define HUGO_BENCH_TEST_H
+
+#include<vector>
+
+///An experimental typedef factory
+#define GRAPH_TYPEDEF_FACTORY(Graph) \
+   typedef typename Graph::   Node      Node;\
+   typedef typename Graph::   NodeIt    NodeIn;\
+   typedef typename Graph::   Edge      Edge;\
+   typedef typename Graph::   EdgeIt    EdgeIt;\
+   typedef typename Graph:: InEdgeIt  InEdgeIt;\
+   typedef typename Graph::OutEdgeIt OutEdgeIt;
+
+#define GRAPH_TYPEDEF_FACTORY_NOTYPENAME(Graph) \
+   typedef Graph::   Node      Node;\
+   typedef Graph::   NodeIt    NodeIn;\
+   typedef Graph::   Edge      Edge;\
+   typedef Graph::   EdgeIt    EdgeIt;\
+   typedef Graph:: InEdgeIt  InEdgeIt;\
+   typedef Graph::OutEdgeIt OutEdgeIt;
+ 
+
+///A primitive primtest
+bool isPrim(int n)
+{
+  if(n%2) {
+    for(int k=3;n/k>=k;k+=2)
+      if(!(n%k)) return false;
+    return true;
+  }
+  return false;
+}
+
+///Finds the smallest prime not less then \c n.
+int nextPrim(int n)
+{
+  for(n+=!(n%2);!isPrim(n);n+=2) ;
+  return n;
+}
+
+
+/// Class to generate consecutive primes
+class Primes 
+{
+  std::vector<int> primes;
+  int n;
+  
+  bool isPrime(int m) 
+  {
+    for(int i=0;m<primes[i]*primes[i];i++) if(!(m%primes[i])) return false;
+    return true;
+  }
+public:
+  Primes() : n(1) {}
+  
+  int operator() ()
+    {
+      if(primes.size()==0) {
+	primes.push_back(2);
+	return 2;
+      }
+      else {
+	do n+=2; while(!isPrime(n));
+	primes.push_back(n);
+	return n;
+      }
+    }
+};
+
+
+#endif

Modified: hugo/trunk/src/benchmark/graph-bench.cc
==============================================================================
--- hugo/trunk/src/benchmark/graph-bench.cc	(original)
+++ hugo/trunk/src/benchmark/graph-bench.cc	Tue Jul 20 11:50:11 2004
@@ -2,38 +2,10 @@
 #include<hugo/list_graph.h>
 #include<hugo/time_measure.h>
 #include<iostream>
-#include<sage_graph.h>
-#include<vector>
 
-using namespace hugo;
-
-///An experimental typedef factory
-#define GRAPH_TYPEDEF_FACTORY(Graph) \
-   typedef typename Graph::   Node      Node;\
-   typedef typename Graph::   NodeIt    NodeIn;\
-   typedef typename Graph::   Edge      Edge;\
-   typedef typename Graph::   EdgeIt    EdgeIt;\
-   typedef typename Graph:: InEdgeIt  InEdgeIt;\
-   typedef typename Graph::OutEdgeIt OutEdgeIt;
- 
+#include"bench_tools.h"
 
-///A primitive primtest
-bool isPrim(int n)
-{
-  if(n%2) {
-    for(int k=3;n/k>=k;k+=2)
-      if(!(n%k)) return false;
-    return true;
-  }
-  return false;
-}
-
-///Finds the smallest prime not less then \c n.
-int nextPrim(int n)
-{
-  for(n+=!(n%2);!isPrim(n);n+=2) ;
-  return n;
-}
+using namespace hugo;
 
 ///Makes a full graph by adding and deleting a lot of edges;
 

Modified: hugo/trunk/src/benchmark/hcube.cc
==============================================================================
--- hugo/trunk/src/benchmark/hcube.cc	(original)
+++ hugo/trunk/src/benchmark/hcube.cc	Tue Jul 20 11:50:11 2004
@@ -6,56 +6,12 @@
 #include<hugo/dijkstra.h>
 #include<hugo/time_measure.h>
 #include<iostream>
-#include<../work/jacint/max_flow.h>
+//#include<../work/jacint/max_flow.h>
+#include"bench_tools.h"
 
 using namespace std;
 using namespace hugo;
 
-///An experimental typedef factory
-#define GRAPH_TYPEDEF_FACTORY(Graph) \
-   typedef typename Graph::   Node      Node;\
-   typedef typename Graph::   NodeIt    NodeIn;\
-   typedef typename Graph::   Edge      Edge;\
-   typedef typename Graph::   EdgeIt    EdgeIt;\
-   typedef typename Graph:: InEdgeIt  InEdgeIt;\
-   typedef typename Graph::OutEdgeIt OutEdgeIt;
-
-#define GRAPH_TYPEDEF_FACTORY_NOTYPENAME(Graph) \
-   typedef Graph::   Node      Node;\
-   typedef Graph::   NodeIt    NodeIn;\
-   typedef Graph::   Edge      Edge;\
-   typedef Graph::   EdgeIt    EdgeIt;\
-   typedef Graph:: InEdgeIt  InEdgeIt;\
-   typedef Graph::OutEdgeIt OutEdgeIt;
-
-
-class Primes 
-{
-  vector<int> primes;
-  int n;
-  
-  bool isPrime(int m) 
-  {
-    for(int i=0;m<primes[i]*primes[i];i++) if(!(m%primes[i])) return false;
-    return true;
-  }
-public:
-  Primes() : n(1) {}
-  
-  int operator() ()
-    {
-      if(primes.size()==0) {
-	primes.push_back(2);
-	return 2;
-      }
-      else {
-	do n+=2; while(!isPrime(n));
-	primes.push_back(n);
-	return n;
-      }
-    }
-};
-
 template<class Graph>
 void addHiperCube(Graph &G,int dim,vector<typename Graph::Node> &nodes)
 {



More information about the Lemon-commits mailing list