Index: olena/ChangeLog
from Nicolas Burrus <burrus_n(a)lrde.epita.fr>
* oln/utils/timer.hh: Improve. Can give the elapsed time since the
last resume.
* tests/utils/tests/timer: Adjust consequently.
* tests/morpho/tests/overall_benchs: New test.
* tests/core/tests/benchs: New test.
+2003-11-07 Nicolas Burrus <burrus_n(a)lrde.epita.fr>
+
* oln/arith/internal/opdecls.hh: Add missing default functors.
* oln/level/cc.hh: Use default arithmetic functor.
Index: olena/oln/utils/timer.hh
--- olena/oln/utils/timer.hh Thu, 07 Aug 2003 02:37:23 +0200 burrus_n (oln/8_timer.hh 1.7
640)
+++ olena/oln/utils/timer.hh Fri, 07 Nov 2003 17:34:52 +0100 burrus_n (oln/8_timer.hh 1.8
640)
@@ -50,6 +50,7 @@
{
assertion(status_ != e_running);
total_time_ = 0;
+ stop_time_ = 0;
status_ = e_running;
start_time_ = clock();
}
@@ -58,7 +59,7 @@
restart()
{
assertion(status_ != e_unknown);
- float val = value();
+ float val = total_time();
start();
return val;
}
@@ -75,13 +76,25 @@
stop()
{
assertion(status_ == e_running);
- total_time_ += (clock() - start_time_);
+ stop_time_ = clock();
+ total_time_ += (stop_time_ - start_time_);
status_ = e_stopped;
- return value();
+ return total_time();
}
+ // Time since the last resume() or start()
float
- value()
+ last_time() const
+ {
+ assertion(status_ != e_unknown);
+ return
+ status_ == e_stopped ?
+ float(stop_time_ - start_time_) / CLOCKS_PER_SEC :
+ float((clock() - start_time_)) / CLOCKS_PER_SEC;
+ }
+
+ float
+ total_time() const
{
assertion(status_ != e_unknown);
return
@@ -99,6 +112,7 @@
} status_;
clock_t total_time_;
clock_t start_time_;
+ clock_t stop_time_;
};
} // end of namespace utils
Index: olena/tests/morpho/tests/reconstruction
--- olena/tests/morpho/tests/reconstruction Wed, 08 Oct 2003 11:15:11 +0200 burrus_n
(oln/e/34_reconstruc 1.11 640)
+++ olena/tests/morpho/tests/reconstruction Fri, 07 Nov 2003 17:34:52 +0100 burrus_n
(oln/e/34_reconstruc 1.12 640)
@@ -24,6 +24,10 @@
fail = true; \
}
+// FIXME: reference images are several times computed twice, this
+// should be factorized! For example,
+// morpho::sure::regional_minima(lena, ...) is computed twice.
+
bool
check()
{
Index: olena/tests/utils/tests/timer
--- olena/tests/utils/tests/timer Thu, 07 Aug 2003 02:37:23 +0200 burrus_n
(oln/u/29_timer.cc 1.3 600)
+++ olena/tests/utils/tests/timer Fri, 07 Nov 2003 17:34:52 +0100 burrus_n
(oln/u/29_timer.cc 1.4 600)
@@ -30,14 +30,14 @@
t.stop();
- float b = t.value();
+ float b = t.total_time();
t.resume();
for (int i = 0; i < 1000000000; )
++i;
- b = t.value() - b;
+ b = t.total_time() - b;
if (b >= 0)
OK_OR_FAIL;
Index: olena/tests/morpho/tests/overall_benchs
--- olena/tests/morpho/tests/overall_benchs Fri, 07 Nov 2003 17:38:50 +0100 burrus_n ()
+++ olena/tests/morpho/tests/overall_benchs Fri, 07 Nov 2003 17:34:52 +0100 burrus_n
(oln/v/36_overall_be 1.1 640)
@@ -0,0 +1,99 @@
+// -*- c++ -*-
+
+#include <oln/basics2d.hh>
+#include <oln/morpho/watershed.hh>
+#include <oln/morpho/extrema_killer.hh>
+#include <oln/morpho/opening.hh>
+#include <oln/morpho/geodesic_dilation.hh>
+#include <oln/morpho/geodesic_erosion.hh>
+#include <oln/morpho/reconstruction.hh>
+#include <oln/morpho/extrema.hh>
+#include <oln/utils/timer.hh>
+
+#include <ntg/all.hh>
+
+#include "check.hh"
+#include "data.hh"
+
+#include <iostream>
+
+using namespace oln;
+using namespace oln::morpho;
+using namespace ntg;
+
+void bench_extrema()
+{
+ image2d<int_u8> lena = load(rdata("lena128.pgm"));
+
+ unsigned size = 20;
+ sure_minima_killer(lena, size, neighb_c4());
+ fast_minima_killer(lena, size, neighb_c4());
+ sure_maxima_killer(lena, size, neighb_c4());
+ fast_maxima_killer(lena, size, neighb_c4());
+}
+
+void bench_reconstruction()
+{
+ image2d<int_u8> lena = load(rdata("lena128.pgm"));
+ image2d<int_u8> lena_open = morpho::opening(lena, win_c4p());
+ image2d<ntg::bin> minima_map(lena.size());
+ image2d<int_u8> max_map(lena.size());
+
+ level::fill (minima_map, false);
+ level::fill (max_map, 255);
+ minima_map(10,10) = true;
+ minima_map(100,100) = true;
+
+ morpho::sure::regional_minima(lena, neighb_c4());
+ morpho::sequential::regional_minima(lena, neighb_c4());
+ morpho::hybrid::regional_minima(lena, neighb_c4());
+
+ morpho::sure::minima_imposition(lena, minima_map, neighb_c4());
+ morpho::geodesic_erosion(lena, lena_open, neighb_c4());
+ morpho::sure::geodesic_dilation(lena_open, lena, neighb_c4());
+
+ morpho::sequential::geodesic_reconstruction_erosion
+ (max_map, lena_open, neighb_c4());
+ morpho::sure::geodesic_reconstruction_dilation
+ (lena_open, lena, neighb_c4());
+}
+
+void bench_watershed()
+{
+ image2d<int_u8> lena = load(rdata("lena128.pgm"));
+
+ for (int i = 0; i < 200; ++i)
+ watershed_seg<int_u16>(lena, neighb_c4());
+}
+
+void print_info(const oln::utils::timer& t, std::string name)
+{
+ std::cout << t.total_time() << "\t\t(" << name <<
": "
+ << t.last_time() << ")" << std::endl;
+}
+
+bool check()
+{
+ bool fail = false;
+
+ oln::utils::timer t;
+
+ bench_extrema();
+
+ t.start();
+ bench_extrema();
+ print_info(t, "extrema killers");
+ t.stop();
+
+ t.resume();
+ bench_watershed();
+ print_info(t, "wastershed");
+ t.stop();
+
+ t.resume();
+ bench_reconstruction();
+ print_info(t, "reconstructions");
+ t.stop();
+
+ return fail;
+}
Index: olena/tests/core/tests/benchs
--- olena/tests/core/tests/benchs Fri, 07 Nov 2003 17:38:50 +0100 burrus_n ()
+++ olena/tests/core/tests/benchs Fri, 07 Nov 2003 17:34:52 +0100 burrus_n
(oln/v/37_benchs 1.1 600)
@@ -0,0 +1,44 @@
+// -*- c++ -*-
+
+#include <iostream>
+
+#include <oln/basics1d.hh>
+#include <oln/basics2d.hh>
+#include <oln/basics3d.hh>
+
+#include <oln/utils/timer.hh>
+
+#include <ntg/all.hh>
+
+using namespace oln;
+using namespace ntg;
+
+template <class I>
+void abstract_fill_image(abstract::image<I>& ima)
+{
+ oln_iter_type(I) p (ima.exact());
+ for_all(p)
+ ima[p] = p.row() + p.col();
+}
+
+template <class I>
+void concrete_fill_image(I& ima)
+{
+ oln_iter_type(I) p (ima);
+ for_all(p)
+ ima[p] = p.row() + p.col();
+}
+
+int main()
+{
+ oln::image2d<int_u32> ima(10000, 10000);
+ oln::utils::timer t;
+ t.start();
+ abstract_fill_image(ima);
+ t.stop();
+ std::cout << "With abstract: " << t.total_time() <<
std::endl;
+ t.restart();
+ concrete_fill_image(ima);
+ t.stop();
+ std::cout << "With concrete: " << t.total_time() <<
std::endl;
+}