Changeset 2242:16523135943d in lemon-0.x for benchmark
- Timestamp:
- 10/14/06 17:26:05 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2991
- Location:
- benchmark
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/edge_lookup.cc
r2240 r2242 3 3 #include<vector> 4 4 #include<lemon/time_measure.h> 5 #include<lemon/random.h> 5 6 6 7 using namespace lemon; … … 101 102 std::vector<Node> v; 102 103 for(int i=0;i<N;i++) v.push_back(g.addNode()); 103 for(int i=0;i<M;i++) g.addEdge(v[ int(drand48()*N)],v[int(drand48()*N)]);104 for(int i=0;i<M;i++) g.addEdge(v[rnd[N]],v[rnd[N]]); 104 105 105 106 // { -
benchmark/radix_sort-bench.cc
r1956 r2242 27 27 #include <lemon/radix_sort.h> 28 28 29 #include <lemon/random.h> 30 29 31 #include <vector> 30 32 #include <algorithm> … … 38 40 vector<int> data(n); 39 41 for (int i = 0; i < n; ++i) { 40 data[i] = (int)(1000 * (rand() / (RAND_MAX + 1.0)))- 500;42 data[i] = rnd[1000] - 500; 41 43 } 42 44 radixSort(data.begin(), data.end()); … … 48 50 vector<int> data(n); 49 51 for (int i = 0; i < n; ++i) { 50 data[i] = (int)(1000 * (rand() / (RAND_MAX + 1.0)))- 500;52 data[i] = rnd[1000] - 500; 51 53 } 52 54 counterSort(data.begin(), data.end()); … … 57 59 vector<int> data(n); 58 60 for (int i = 0; i < n; ++i) { 59 data[i] = (int)(1000 * (rand() / (RAND_MAX + 1.0)))- 500;61 data[i] = rnd[1000] - 500; 60 62 } 61 63 sort(data.begin(), data.end()); … … 66 68 vector<int> data(n); 67 69 for (int i = 0; i < n; ++i) { 68 data[i] = (int)(1000 * (rand() / (RAND_MAX + 1.0)))- 500;70 data[i] = rnd[1000] - 500; 69 71 } 70 72 stable_sort(data.begin(), data.end()); -
benchmark/swap_bipartite_bench.cc
r2239 r2242 13 13 14 14 #include <lemon/time_measure.h> 15 #include <lemon/random.h> 15 16 16 17 using namespace std; … … 21 22 BPUGRAPH_TYPEDEFS(Graph); 22 23 23 int _urandom_init() {24 int seed = time(0);25 srand(seed);26 return seed;27 }28 29 int urandom(int n) {30 static int seed = _urandom_init();31 ignore_unused_variable_warning(seed);32 return (int)(rand() / (1.0 + RAND_MAX) * n);33 }34 24 35 25 int main() { … … 67 57 for (int i = 0; i < e; ++i) { 68 58 int a,b; 69 Node aNode = aNodes[a= urandom(n)];70 Node bNode = bNodes[b= urandom(m)];59 Node aNode = aNodes[a=rnd[n]]; 60 Node bNode = bNodes[b=rnd[m]]; 71 61 graph.addEdge(aNode, bNode); 72 62 LGraph::Node laNode = laNodes[a];
Note: See TracChangeset
for help on using the changeset viewer.