1.1 --- a/benchmark/Makefile.am Tue Oct 17 10:31:20 2006 +0000
1.2 +++ b/benchmark/Makefile.am Tue Oct 17 10:32:12 2006 +0000
1.3 @@ -13,6 +13,7 @@
1.4 benchmark/bfs-bench \
1.5 benchmark/radix_sort-bench \
1.6 benchmark/swap_bipartite_bench \
1.7 + benchmark/random_bench \
1.8 benchmark/edge_lookup
1.9
1.10 endif WANT_BENCHMARK
1.11 @@ -27,4 +28,6 @@
1.12
1.13 benchmark_swap_bipartite_bench_SOURCES = benchmark/swap_bipartite_bench.cc
1.14
1.15 +benchmark_random_bench_SOURCES = benchmark/random_bench.cc
1.16 +
1.17 benchmark_edge_lookup_SOURCES = benchmark/edge_lookup.cc
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/benchmark/random_bench.cc Tue Oct 17 10:32:12 2006 +0000
2.3 @@ -0,0 +1,133 @@
2.4 +#include<stdlib.h>
2.5 +#include<lemon/random.h>
2.6 +#include<lemon/time_measure.h>
2.7 +
2.8 +using namespace lemon;
2.9 +
2.10 +void f_no()
2.11 +{
2.12 +}
2.13 +
2.14 +inline void f_noi()
2.15 +{
2.16 +}
2.17 +
2.18 +inline void f_i()
2.19 +{
2.20 + static int r;
2.21 + r=5;
2.22 +}
2.23 +
2.24 +inline void f_l()
2.25 +{
2.26 + static long int r;
2.27 + r=5;
2.28 +}
2.29 +
2.30 +inline void f_d()
2.31 +{
2.32 + static double r;
2.33 + r=5;
2.34 +}
2.35 +
2.36 +inline void f_rand()
2.37 +{
2.38 + static int r;
2.39 + r=rand();
2.40 +}
2.41 +
2.42 +inline void f_random()
2.43 +{
2.44 + static long int r;
2.45 + r=random();
2.46 +}
2.47 +
2.48 +inline void f_drand48()
2.49 +{
2.50 + static double r;
2.51 + r=drand48();
2.52 +}
2.53 +
2.54 +inline void f_rnd_d()
2.55 +{
2.56 + static double r;
2.57 + r=rnd();
2.58 +}
2.59 +inline void f_rnd_int1000()
2.60 +{
2.61 + static int r;
2.62 + r=rnd[1000];
2.63 +}
2.64 +inline void f_rnd_bool()
2.65 +{
2.66 + static bool r;
2.67 + r=rnd.boolean();
2.68 +}
2.69 +
2.70 +// inline void f_()
2.71 +// {
2.72 +// static double r;
2.73 +// r=;
2.74 +// }
2.75 +
2.76 +int main()
2.77 +{
2.78 + TimeStamp full;
2.79 + TimeStamp t;
2.80 + unsigned int n;
2.81 +
2.82 + const double TEST_DURATION=10;
2.83 +
2.84 + t=runningTimeTest(f_no,2,&n,&full);
2.85 +
2.86 + t=runningTimeTest(f_no,TEST_DURATION,&n,&full);
2.87 + std::cout << "EMPTY: ";
2.88 + std::cout << t.userTime() << " (" << n << " tests)\n";
2.89 +
2.90 + t=runningTimeTest(f_noi,TEST_DURATION,&n,&full);
2.91 + std::cout << "INLINED EMPTY: ";
2.92 + std::cout << t.userTime() << " (" << n << " tests)\n";
2.93 +
2.94 + TimeStamp ti=t=runningTimeTest(f_i,TEST_DURATION,&n,&full);
2.95 + std::cout << "INT COPY: ";
2.96 + std::cout << t.userTime() << " (" << n << " tests)\n";
2.97 +
2.98 + TimeStamp tl=t=runningTimeTest(f_l,TEST_DURATION,&n,&full);
2.99 + std::cout << "LONG COPY: ";
2.100 + std::cout << t.userTime() << " (" << n << " tests)\n";
2.101 +
2.102 + TimeStamp td=t=runningTimeTest(f_d,TEST_DURATION,&n,&full);
2.103 + std::cout << "DOUBLE COPY: ";
2.104 + std::cout << t.userTime() << " (" << n << " tests)\n";
2.105 +
2.106 + t=runningTimeTest(f_rand,TEST_DURATION,&n,&full);
2.107 + std::cout << "rand(): ";
2.108 + std::cout << (t-ti).userTime() << " (" << n << " tests)\n";
2.109 +
2.110 + t=runningTimeTest(f_random,TEST_DURATION,&n,&full);
2.111 + std::cout << "random(): ";
2.112 + std::cout << (t-tl).userTime() << " (" << n << " tests)\n";
2.113 +
2.114 + t=runningTimeTest(f_drand48,TEST_DURATION,&n,&full);
2.115 + std::cout << "drand48(): ";
2.116 + std::cout << (t-td).userTime() << " (" << n << " tests)\n";
2.117 +
2.118 + t=runningTimeTest(f_rnd_d,TEST_DURATION,&n,&full);
2.119 + std::cout << "rnd(): ";
2.120 + std::cout << (t-td).userTime() << " (" << n << " tests)\n";
2.121 +
2.122 + t=runningTimeTest(f_rnd_int1000,TEST_DURATION,&n,&full);
2.123 + std::cout << "rnd[1000]: ";
2.124 + std::cout << (t-ti).userTime() << " (" << n << " tests)\n";
2.125 +
2.126 + t=runningTimeTest(f_rnd_bool,TEST_DURATION,&n,&full);
2.127 + std::cout << "rnd.boolean(): ";
2.128 + std::cout << (t-ti).userTime() << " (" << n << " tests)\n";
2.129 +
2.130 +// t=runningTimeTest(f_,TEST_DURATION,&n,&full);
2.131 +// std::cout << "\n";
2.132 +// std::cout << t << " (" << n << " tests)\n";
2.133 +// std::cout << "Total: " << full << "\n\n";
2.134 +
2.135 + return 0;
2.136 +}