If my test runs are indicative of the average timings, then you might
as well junk all the stages apart from the last, since they only take
up a few seconds of the preprocessing time. Of course, that then
I can confirm this for most cases. But I've had other experiences too
AFAIK; Could you please do a batch run with some files in --verbose mode,
using the attached patch and output all to a logfile?
leaves the issue with the last stage stalling at 81%: it's not much
use as a progress indicator if 82 - 100% only takes a few seconds.
That is about the font loading, I think; I'll take a look on it later.
Regards,
Michael
>From 9e8766b370e907b9ebb1a626dcc386104680c29e Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Michael=20K=C3=A4ppler?= <xmichae...@web.de>
Date: Thu, 24 Sep 2009 18:26:32 +0200
Subject: [PATCH] Implement a progress indicator for the grob-preprocessing stages.
---
lily/include/misc.hh | 2 +
lily/misc.cc | 18 ++++++--
lily/system.cc | 115 +++++++++++++++++++++++++++++++++++++++++++------
scm/lily.scm | 6 +++
4 files changed, 122 insertions(+), 19 deletions(-)
diff --git a/lily/include/misc.hh b/lily/include/misc.hh
index 12392c0..45af373 100644
--- a/lily/include/misc.hh
+++ b/lily/include/misc.hh
@@ -48,5 +48,7 @@ Real peak_around (Real epsilon, Real threshold, Real x);
Real convex_amplifier (Real standard_x, Real increase_factor, Real x);
string camel_case_to_lisp_identifier (string in);
+int array_sum (const int values[], int max);
+
#endif
diff --git a/lily/misc.cc b/lily/misc.cc
index ee55a00..792a4db 100644
--- a/lily/misc.cc
+++ b/lily/misc.cc
@@ -57,32 +57,40 @@ peak_around (Real epsilon, Real threshold, Real x)
}
/*
- 0 at 0, 1 at standard_x, and increasing thereafter.
+ 0 at 0, 1 at standard_x, and increasing thereafter.
*/
Real
convex_amplifier (Real standard_x, Real increase_factor, Real x)
{
- return (exp (increase_factor * x / standard_x) - 1.0) / (exp (increase_factor) - 1.0);
+ return (exp (increase_factor * x / standard_x) - 1.0) / (exp (increase_factor) - 1.0);
}
string
camel_case_to_lisp_identifier (string in)
{
vector<char> out;
-
+
/* don't add '-' before first character */
out.push_back (char (tolower (in[0])));
-
+
for (size_t inpos = 1; inpos < in.size (); inpos++)
{
if (isupper (in[inpos]))
out.push_back ('-');
out.push_back ( char(tolower (in[inpos])));
}
-
+
string result (&out[0], out.size ());
replace_all (&result, '_', '-');
return result;
}
+int
+array_sum (const int values[], const int max)
+{
+ int sum = 0;
+ for (int i = 0; i < max; i++)
+ sum += values[i];
+ return sum;
+}
diff --git a/lily/system.cc b/lily/system.cc
index a43c1b4..0635601 100644
--- a/lily/system.cc
+++ b/lily/system.cc
@@ -11,20 +11,24 @@
#include "align-interface.hh"
#include "all-font-metrics.hh"
#include "axis-group-interface.hh"
+#include "cpu-timer.hh"
#include "grob-array.hh"
#include "hara-kiri-group-spanner.hh"
#include "international.hh"
#include "lookup.hh"
#include "main.hh"
+#include "misc.hh"
#include "output-def.hh"
#include "page-layout-problem.hh"
#include "paper-column.hh"
#include "paper-score.hh"
#include "paper-system.hh"
#include "pointer-group-interface.hh"
+#include "program-option.hh"
#include "skyline-pair.hh"
#include "staff-symbol-referencer.hh"
#include "warn.hh"
+#include <sstream>
System::System (System const &src)
: Spanner (src)
@@ -244,7 +248,7 @@ System::break_into_pieces (vector<Column_x_positions> const &breaking)
system_labels = scm_append (scm_list_2 (col_labels, system_labels));
}
system->set_property ("labels", system_labels);
-
+
set_loose_columns (system, &breaking[i]);
broken_intos_.push_back (system);
}
@@ -269,35 +273,118 @@ System::add_column (Paper_column *p)
}
void
+progress_output (int progress)
+{
+ string backspaces;
+ ostringstream poutput;
+ poutput << " (" << progress << " %)";
+ for (unsigned bs = 0; bs < poutput.str ().size (); bs++)
+ backspaces+= "\b";
+ progress_indication (poutput.str () + backspaces);
+}
+
+void
System::pre_processing ()
{
- for (vsize i = 0; i < all_elements_->size (); i++)
- all_elements_->grob (i)->discretionary_processing ();
+ const unsigned min_process_grobs = robust_scm2int (ly_get_option
+ (ly_symbol2scm ("min-grobs-indicator")), 0);
+
+ bool show_progress = (all_elements_->size () >= min_process_grobs);
+ SCM stages_weight_scm = ly_get_option (ly_symbol2scm ("preprocessing-stages-weight"));
+ int stages_weight[5];
+
+ if (scm_list_p (stages_weight_scm) == SCM_BOOL_T)
+ {
+ for (int i = 0; i < 5 ; i++)
+ stages_weight[i] = robust_scm2int (scm_list_ref (stages_weight_scm,
+ scm_from_int (i+1)), 0);
+ }
+ else
+ {
+ show_progress = false;
+ programming_error
+ ("improper weight list for grob preprocessing stages, disabled progress indicator");
+ }
if (be_verbose_global)
message (_f ("Grob count %d", element_count ()));
+ unsigned progress = 0;
+ int stage = 0;
+ float times[5];
+
+ Cpu_timer timer;
+
+ for (vsize i = 0; i < all_elements_->size (); i++)
+ {
+ all_elements_->grob (i)->discretionary_processing ();
+ if ((i * stages_weight[stage] / all_elements_->size () >= progress) &&
+ show_progress)
+ progress_output (++progress);
+ }
+
+ times[stage] = float (timer.read ());
+ timer.restart ();
+ stage++;
+
/*
order is significant: broken grobs are added to the end of the
array, and should be processed before the original is potentially
killed.
*/
for (vsize i = all_elements_->size (); i--;)
- all_elements_->grob (i)->handle_prebroken_dependencies ();
+ {
+ all_elements_->grob (i)->handle_prebroken_dependencies ();
+ if (((all_elements_->size () - i) * stages_weight[stage] /
+ all_elements_->size () >= progress - array_sum (stages_weight,
+ stage)) && show_progress)
+ progress_output (++progress);
+ }
- fixup_refpoints (all_elements_->array ());
+ times[stage] = float (timer.read ());
+ timer.restart ();
+ stage++;
+
+ for (vsize i = all_elements_->size (); i--;)
+ {
+ all_elements_->grob (i)->fixup_refpoint ();
+ if (((all_elements_->size () - i) * stages_weight[stage] /
+ all_elements_->size () >= progress - array_sum (stages_weight, stage))
+ && show_progress)
+ progress_output (++progress);
+ }
+
+ times[stage] = float (timer.read ());
+ timer.restart ();
+ stage++;
for (vsize i = 0; i < all_elements_->size (); i++)
{
Grob *g = all_elements_->grob (i);
(void) g->get_property ("before-line-breaking");
+ if ((i * stages_weight[stage] / all_elements_->size () >= progress -
+ array_sum (stages_weight, stage)) && show_progress)
+ progress_output (++progress);
}
+ times[stage] = float (timer.read ());
+ timer.restart ();
+ stage++;
+
for (vsize i = 0; i < all_elements_->size (); i++)
{
Grob *e = all_elements_->grob (i);
(void) e->get_property ("springs-and-rods");
+ if ((i * stages_weight[stage] / all_elements_->size () >= progress -
+ array_sum (stages_weight, stage)) && show_progress)
+ progress_output (++progress);
}
+
+ times[stage] = float (timer.read ());
+
+ if (be_verbose_global)
+ message (_f ("Needed %.2f | %.2f | %.2f | %.2f | %.2f seconds", times[0],
+ times[1], times[2], times[3], times[4]));
}
void
@@ -352,8 +439,8 @@ System::get_paper_system ()
Layer_entry e;
e.grob_ = all_elements_->grob (j);
e.layer_ = robust_scm2int (e.grob_->get_property ("layer"), 1);
-
- entries.push_back (e);
+
+ entries.push_back (e);
}
vector_sort (entries, std::less<Layer_entry> ());
@@ -364,7 +451,7 @@ System::get_paper_system ()
if (st.expr () == SCM_EOL)
continue;
-
+
Offset o;
for (int a = X_AXIS; a < NO_AXES; a++)
o[Axis (a)] = g->relative_coordinate (this, Axis (a));
@@ -424,7 +511,7 @@ System::get_paper_system ()
staff_refpoints.add_point (staves[i]->relative_coordinate (this, Y_AXIS));
pl->set_property ("staff-refpoint-extent", ly_interval2scm (staff_refpoints));
- pl->set_property ("system-grob", this->self_scm ());
+ pl->set_property ("system-grob", this->self_scm ());
return pl->unprotect ();
}
@@ -437,7 +524,7 @@ System::broken_col_range (Item const *left, Item const *right) const
left = left->get_column ();
right = right->get_column ();
-
+
extract_grob_set (this, "columns", cols);
vsize i = Paper_column::get_rank (left);
@@ -489,7 +576,7 @@ System::column (vsize which) const
extract_grob_set (this, "columns", columns);
if (which >= columns.size ())
return 0;
-
+
return dynamic_cast<Paper_column*> (columns[which]);
}
@@ -506,14 +593,14 @@ System::get_rank () const
}
System *
-get_root_system (Grob *me)
+get_root_system (Grob *me)
{
Grob *system_grob = me;
-
+
while (system_grob->get_parent (Y_AXIS))
system_grob = system_grob->get_parent (Y_AXIS);
- return dynamic_cast<System*> (system_grob);
+ return dynamic_cast<System*> (system_grob);
}
Grob *
diff --git a/scm/lily.scm b/scm/lily.scm
index 1e07dfa..c07671b 100644
--- a/scm/lily.scm
+++ b/scm/lily.scm
@@ -101,6 +101,9 @@ output to log file `FOO.log'.")
"midi")
"Set the default file extension for MIDI output
file to given string.")
+ (min-grobs-indicator 1000
+"Number of grobs above which a progress indicator
+is printed during preprocessing.")
(old-relative #f
"Make \\relative mode for simultaneous music work
similar to chord syntax.")
@@ -110,6 +113,9 @@ similar to chord syntax.")
"Set default paper size.")
(pixmap-format "png16m"
"Set GhostScript's output format for pixel images.")
+ (preprocessing-stages-weight (list 20 20 20 20 20)
+"Relative weight of grob preprocessing stages for
+progress indication.")
(preview #f
"Create PNG and EPS preview images also.")
(print-pages #t
--
1.6.0.2
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel