1.1 --- a/src/benchmark/bfs-bench.cc Wed Aug 04 18:43:51 2004 +0000
1.2 +++ b/src/benchmark/bfs-bench.cc Wed Aug 04 18:51:51 2004 +0000
1.3 @@ -38,7 +38,7 @@
1.4
1.5 using namespace std;
1.6
1.7 - typename Graph::NodeMap<bool> visited(G,false);
1.8 + typename Graph::template NodeMap<bool> visited(G,false);
1.9
1.10 queue<typename Graph::Node> Q;
1.11
1.12 @@ -63,7 +63,7 @@
1.13
1.14 using namespace std;
1.15
1.16 - typename Graph::NodeMap<bool> visited(G,false);
1.17 + typename Graph::template NodeMap<bool> visited(G,false);
1.18
1.19 int N=G.nodeNum();
1.20 vector<typename Graph::Node> Q(N);
1.21 @@ -84,6 +84,18 @@
1.22 } while(Qt!=Qh);
1.23 }
1.24
1.25 +template<class Graph>
1.26 +void iteratorBench(Graph &G)
1.27 +{
1.28 + GRAPH_TYPEDEF_FACTORY(Graph);
1.29 +
1.30 + int i=0;
1.31 +
1.32 + for(NodeIt n(G);G.valid(n);G.next(n))
1.33 + for(OutEdgeIt e(G,n);G.valid(e);G.next(e))
1.34 + i++;
1.35 +}
1.36 +
1.37 int main(int argc, char *argv[])
1.38 {
1.39 // typedef ListGraph Graph;
1.40 @@ -96,12 +108,13 @@
1.41
1.42 Timer T;
1.43
1.44 - if(argc!=2) {
1.45 - cout << "Usage: " << argv[0] << " dim\n";
1.46 + if(argc!=3) {
1.47 + cout << "Usage: " << argv[0] << " dim mul\n";
1.48 return 1;
1.49 }
1.50
1.51 int dim=atoi(argv[1]);
1.52 + int mul=atoi(argv[2]);
1.53
1.54 // cout << "Creating Hipercube ("<< (1<<dim) << " nodes, "
1.55 // << dim*(1<<dim) << " edges):";
1.56 @@ -114,14 +127,22 @@
1.57
1.58 T.reset();
1.59 {
1.60 - for(int i=0;i<50000;i++)
1.61 + for(int i=0;i<mul;i++)
1.62 bfsStlQueue(G,nodes[0]);
1.63 }
1.64 PrintTime("BFS-STL",T);
1.65 T.reset();
1.66 {
1.67 - for(int i=0;i<50000;i++)
1.68 + for(int i=0;i<mul;i++)
1.69 bfsOwnQueue(G,nodes[0]);
1.70 }
1.71 PrintTime("BFS-OWN",T);
1.72 + T.reset();
1.73 + {
1.74 + for(int i=0;i<mul;i++)
1.75 + iteratorBench(G);
1.76 + }
1.77 + PrintTime("ITERATE",T);
1.78 +
1.79 +
1.80 }