---
milena/sandbox/ChangeLog | 5 +
.../{fastest_forall_p_browsing.cc => fastest.cc} | 175 ++++++++------------
2 files changed, 76 insertions(+), 104 deletions(-)
copy milena/sandbox/bench/{fastest_forall_p_browsing.cc => fastest.cc} (76%)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index ba20fec..5cb9a9c 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,8 @@
+2010-06-25 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * bench/fastest.cc: New. Add a bench for the best fastest
+ iteration.
+
2010-03-30 Guillaume Lazzara <z(a)lrde.epita.fr>
Improve the usability of AFP's GUI.
diff --git a/milena/sandbox/bench/fastest_forall_p_browsing.cc
b/milena/sandbox/bench/fastest.cc
similarity index 76%
copy from milena/sandbox/bench/fastest_forall_p_browsing.cc
copy to milena/sandbox/bench/fastest.cc
index 5560f70..c77b3c2 100644
--- a/milena/sandbox/bench/fastest_forall_p_browsing.cc
+++ b/milena/sandbox/bench/fastest.cc
@@ -26,7 +26,7 @@
#include <mln/core/image/image2d.hh>
#include <mln/util/timer.hh>
-
+#include <mln/core/box_runend_piter.hh>
# define loop(n) for (unsigned i = 0; i < n; ++i)
@@ -36,18 +36,6 @@ namespace mln
{
- // (r, c)
-
- template <typename I>
- void bench_00(I& ima)
- {
- const unsigned nr = ima.nrows(), nc = ima.ncols();
- for (int r = 0; r < nr; ++r)
- for (int c = 0; c < nc; ++c)
- ima.at_(r, c) = 0;
- }
-
-
// ptr
template <typename I>
@@ -161,7 +149,7 @@ namespace mln
}
- // box_runstart_piter -> (ptr, point)
+ // box_runstart_piter -> point
template <typename I>
void bench_6(I& ima)
@@ -203,6 +191,30 @@ namespace mln
}
+ // box_runend_piter -> point
+
+ template <typename I>
+ void bench_7(I& ima)
+ {
+ typedef mln_site(I) P;
+ const unsigned dim_1 = P::dim - 1;
+ mln_box_runend_piter(I) s(ima.domain());
+ const unsigned n = s.run_length();
+ for_all(s)
+ {
+ mln_value(I)* ptr = & ima(s);
+ P p = s;
+ for (unsigned i = 0; i < n; ++i)
+ {
+ *ptr-- = 0;
+ --p[dim_1];
+ }
+ }
+ }
+
+
+
+
// template <typename I>
// void bench_6_alt(I& ima1, const I& ima2)
// {
@@ -222,31 +234,6 @@ namespace mln
// }
-
- // box_runstart_piter -> (offset, point)
-
- template <typename I>
- void bench_7(I& ima)
- {
- typedef mln_site(I) P;
- const unsigned dim_1 = P::dim - 1;
- mln_box_runstart_piter(I) s(ima.domain());
- const unsigned n = s.run_length();
- for_all(s)
- {
- unsigned offset = ima.index_of_point(s);
- P p = s;
- for (unsigned i = 0; i < n; ++i)
- {
- ima.element(offset) = 0;
- ++offset;
- ++p[dim_1];
- }
- }
- }
-
-
-
} // end of namespace mln
@@ -262,24 +249,14 @@ int main()
util::timer t;
- // (r, c)
-
- {
- t.start();
- loop(n) bench_00(ima);
- float ts = t.stop();
- std::cout << "(r, c) " << ts << std::endl;
- }
-
-
- // ptr
+// // ptr
- {
- t.start();
- loop(n) bench_0(ima);
- float ts = t.stop();
- std::cout << "ptr " << ts << std::endl;
- }
+// {
+// t.start();
+// loop(n) bench_0(ima);
+// float ts = t.stop();
+// std::cout << "ptr " << ts << std::endl;
+// }
// {
// t.start();
@@ -289,23 +266,23 @@ int main()
// }
- // piter
+// // piter
- {
- t.start();
- loop(n) bench_1(ima);
- std::cout << "piter " << t.stop() << std::endl;
- }
+// {
+// t.start();
+// loop(n) bench_1(ima);
+// std::cout << "piter " << t.stop() << std::endl;
+// }
- // pixter
+// // pixter
- {
- t.start();
- loop(n) bench_2(ima);
- float ts = t.stop();
- std::cout << "pixter " << ts << std::endl;
- }
+// {
+// t.start();
+// loop(n) bench_2(ima);
+// float ts = t.stop();
+// std::cout << "pixter " << ts << std::endl;
+// }
// {
// t.start();
@@ -315,13 +292,13 @@ int main()
// }
- // pixter -> offset
+// // pixter -> offset
- {
- t.start();
- loop(n) bench_3(ima);
- std::cout << "pixter -> offset " << t.stop() <<
std::endl;
- }
+// {
+// t.start();
+// loop(n) bench_3(ima);
+// std::cout << t.stop() << std::endl;
+// }
// {
// t.start();
@@ -330,32 +307,32 @@ int main()
// }
- // pixter -> point
+// // pixter -> point
- {
- t.start();
- loop(n) bench_4(ima);
- std::cout << "pixter -> point " << t.stop() <<
std::endl;
- }
+// {
+// t.start();
+// loop(n) bench_4(ima);
+// std::cout << t.stop() << std::endl;
+// }
- // box_runstart_piter -> ptr
+// // box_runstart_piter -> ptr
- {
- t.start();
- loop(n) bench_5(ima);
- std::cout << "box_runstart_piter -> ptr " << t.stop()
<< std::endl;
- }
+// {
+// t.start();
+// loop(n) bench_5(ima);
+// std::cout << t.stop() << std::endl;
+// }
// box_runstart_piter -> (ptr, point)
- {
- t.start();
- loop(n) bench_6(ima);
- float ts = t.stop();
- std::cout << "runstart -> (ptr, point) " << ts <<
std::endl;
- }
+// {
+// t.start();
+// loop(n) bench_6(ima);
+// float ts = t.stop();
+// std::cout << "runstart -> (ptr, point) " << ts <<
std::endl;
+// }
// {
// t.start();
@@ -364,21 +341,11 @@ int main()
// std::cout << "runstart -> (2 ptrs, point) " << ts
<< std::endl;
// }
-
- // box_runstart_piter -> (offset, point)
-
{
t.start();
loop(n) bench_7(ima);
float ts = t.stop();
- std::cout << "runstart -> (offset, point) " << ts <<
std::endl;
+ std::cout << "runend -> (2 ptrs, point) " << ts <<
std::endl;
}
-// {
-// t.start();
-// loop(n) bench_7(ima, ima2);
-// float ts = t.stop();
-// std::cout << "runstart -> (2 offsets, point) " << ts
<< std::endl;
-// }
-
}
--
1.5.6.5
Show replies by date