last-svn-commit-550-gfcea0a4 WIP: Generate a LaTeX table from some results of apps/bench/dilation-lena.

--- milena/apps/bench/Makefile.am | 2 + .../{dilation-lena.cc => dilation-lena-table.cc} | 91 +++++++++++++++++--- 2 files changed, 80 insertions(+), 13 deletions(-) copy milena/apps/bench/{dilation-lena.cc => dilation-lena-table.cc} (56%) diff --git a/milena/apps/bench/Makefile.am b/milena/apps/bench/Makefile.am index 40f0147..e27be3c 100644 --- a/milena/apps/bench/Makefile.am +++ b/milena/apps/bench/Makefile.am @@ -24,6 +24,7 @@ EXTRA_DIST = lena1024.pgm lena2048.pgm noinst_PROGRAMS = \ dilation-lena \ + dilation-lena-table \ gradient-lena \ gradient-spe-lena @@ -37,6 +38,7 @@ EXTRA_DIST += \ trait.hh dilation_lena_SOURCES = dilation-lena.cc dilation-lena.hh +dilation_lena_table_SOURCES = dilation-lena-table.cc dilation-lena.hh gradient_lena_SOURCES = gradient-lena.cc gradient_spe_lena_SOURCES = gradient-spe-lena.cc diff --git a/milena/apps/bench/dilation-lena.cc b/milena/apps/bench/dilation-lena-table.cc similarity index 56% copy from milena/apps/bench/dilation-lena.cc copy to milena/apps/bench/dilation-lena-table.cc index 82b4497..3057ce3 100644 --- a/milena/apps/bench/dilation-lena.cc +++ b/milena/apps/bench/dilation-lena-table.cc @@ -37,8 +37,7 @@ for (unsigned i = 0; i < niters; ++i) \ d = Namespace::dilation(d); \ t.stop(); \ - std::cout << Headline << t.read() << " s" << std::endl; \ - io::pgm::save(d, prefix + '-' + length + '-' + Suffix + ".pgm"); \ + times.push_back(t.read()); \ } \ while (0) @@ -50,14 +49,13 @@ for (unsigned i = 0; i < niters; ++i) \ d = Namespace::dilation(d, Win); \ t.stop(); \ - std::cout << Headline << t.read() << " s" << std::endl; \ - io::pgm::save(d, prefix + '-' + length + '-' + Suffix + ".pgm"); \ + times.push_back(t.read()); \ } \ while (0) -void -run(const std::string& filename, const std::string& length, unsigned niters) +std::vector<float> +run(const std::string& filename, unsigned niters) { using namespace mln; using value::int_u8; @@ -68,21 +66,25 @@ run(const std::string& filename, const std::string& length, unsigned niters) image2d<int_u8> d; util::timer t; - - std::string prefix = "dilation-lena-out"; - std::cout << "== " << filename << std::endl; + std::vector<float> times; DILATION_WITH_BUILTIN_WINDOW(nongen, "nongen", "nongen\t\t"); DILATION_WITH_BUILTIN_WINDOW(nongen_2ptr, "nongen_2ptr", "nongen_2ptr\t"); +# if 0 + // Disabled, not used in the paper's table. DILATION_WITH_BUILTIN_WINDOW(nongen_1ptr, "nongen_1ptr", "nongen_1ptr\t"); +#endif DILATION(gen, win_c4p(), "gen", "gen\t\t"); // FIXME: Introduce a new test case, gen_static, using a static window // and static_qiters. DILATION(fast, win_c4p(), "fast", "fast\t\t"); +# if 0 + // Disabled, not used in the paper's table. DILATION(fast_noaccu, win_c4p(), "fast_noaccu", "fast_noaccu\t"); DILATION(faster, win_c4p(), "faster", "faster\t\t"); DILATION(faster_noaccu, win_c4p(), "faster_noaccu", "faster_noaccu\t"); +#endif // Static windows and qixters. const unsigned n = 5; @@ -95,16 +97,79 @@ run(const std::string& filename, const std::string& length, unsigned niters) mln::static_window<mln::dpoint2d, n> static_win_c4p (sa); DILATION(fast_static, static_win_c4p, "fast_static", "fast_static\t"); +# if 0 + // Disabled, not used in the paper's table. DILATION(faster_static, static_win_c4p, "faster_static", "faster_static\t"); +#endif - std::cout << std::endl; + return times; } int main () { unsigned niters = 10; - run(MLN_IMG_DIR "/lena.pgm", "512", niters); - run(MLN_APPS_DIR "/bench/lena1024.pgm", "1024", niters); - run(MLN_APPS_DIR "/bench/lena2048.pgm", "2048", niters); + typedef std::vector<float> times_t; + + // Compute times. + times_t times_512 = run(MLN_IMG_DIR "/lena.pgm", niters); + times_t times_1024 = run(MLN_APPS_DIR "/bench/lena1024.pgm", niters); + times_t times_2048 = run(MLN_APPS_DIR "/bench/lena2048.pgm", niters); + + // Display times. + times_t::const_iterator i_512 = times_512.begin(); + times_t::const_iterator i_1024 = times_1024.begin(); + times_t::const_iterator i_2048 = times_2048.begin(); + std::cout << + "\\begin{table}[tbp]\n" + " \\centering\n" + " \\begin{tabular}{lrrr}\n" + " \\hline\n" + " Implementation & \\multicolumn{3}{c}{Execution times (s)} \\\\\n" + " & $512^2$ & $1024^2$ & $2048^2$ \\\\\n" + " \\hline\n" + " \\hline\n"; + + /* Increment each iterator only once in each output statement to + avoid non-determinism due to the successive uses of operator++ on + a given iterator. */ + + // nongen. + std::cout << + " Non generic (\\algref{lst:non-gen-dilation}) & " << + *i_512++ << " & " << *i_1024++ << " & " << *i_2048++ << " \\\\\n" + " \\hline\n"; + + // nongen_2ptr. + std::cout << + " Non generic, pointer-based\\footnotemark[1] & " << + *i_512++ << " & " << *i_1024++ << " & " << *i_2048++ << " \\\\\n" + " \\hline\n"; + + // gen. + std::cout << + " Generic (\\algref{lst:gen-dilation}) & " << + *i_512++ << " & " << *i_1024++ << " & " << *i_2048++ << " \\\\\n" + " \\hline\n"; + + // fast. + std::cout << + " Fast, partly generic (\\algref{lst:fast-dilation}) & " << + *i_512++ << " & " << *i_1024++ << " & " << *i_2048++ << " \\\\\n" + " \\hline\n"; + + // fast_static. + std::cout << + " Fast, partly generic with & " << + *i_512++ << " & " << *i_1024++ << " & " << *i_2048++ << " \\\\\n" + " static window (\\algref{lst:fast-static-dilation}) & & & \\\\\n" + " \\hline\n"; + + std::cout << + " \\end{tabular}\n" + " \\caption{Execution times of various dilation implementations.}\n" + " \\label{tab:results}\n" + "\\end{table}\n" + "\\footnotetext[1]{Implementation not shown in this paper for space\n" + " reasons.}\n" << std::flush; } -- 1.7.2.5
participants (1)
-
Roland Levillain