![]() |
#1 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,336
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Changes in template evaluation in V0.8.43
I have made some changes in how templates are evaluated to improve performance.
1) Improvements in the base functions that fetch the metadata used by templates. The performance improvement varies from 10 to 15%. For example, on my 20,000-book test library with three custom columns (int, text/tags-like, and composite), and sorting on the composite column (worst case), startup time went from 21 seconds to 19 seconds. 2) Compilation of general program mode templates. Calibre now tries to convert general program mode templates to python to improve their performance. The performance improvement depends on the complexity of the template. For simple templates (one function), it doesn't help much. For more complex templates, it can help a lot. For example, if the composite column in the 20,000-book library being sorted contains the following template: Code:
program: # fs = formats_sizes(); fs = ""; v = select(fs, 'PRC'); v = add(v, select(fs, 'EPUB')); v = add(v, select(fs, 'MOBI')); v = add(v, select(fs, 'TXT')); v = add(v, select(fs, "\'LIT")); v = format_number(v, '{0:5.0f}'); human_readable(v) Code:
Calibre 0.8.42: 21.1 seconds New version w/o compilation: 19.1 seconds New version w/compilation: 14.6 seconds Either, startup sorting on title: 7.0 seconds Performance of single-function- and template-program-mode templates are improved by the changes described in 1) above. They are not compiled, so do not benefit from the changes described in 2). Converting complicated template-program-mode templates to GPM will improve performance. I added a new template function to assist with this: finish_formatting. This function formats the value and adds a prefix and/or a suffix in the same way that the {||} syntax does in non-GPM templates. For example, the template Code:
{series:re(([^\s])[^\s]+(\s|$),\1)}{series_index:0>2s| - | - }{title} Code:
program: strcat( re(field('series'), '([^\s])[^\s]+(\s|$)', '\1'), finish_formatting(field('series_index'), '0>2s', ' - ', ' - '), field('title') ) |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,336
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
First bug. Sigh... It is the little things that go wrong.
Incorrect code is generated if the last character of the GPM template is a semicolon. Fixed in the next release. The workaround: remove that last semicolon. ![]() |
![]() |
![]() |
Advert | |
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
E-book app evaluation on the HTC Touch Pro 2 | Steven Lyle Jordan | Alternative Devices | 36 | 09-28-2010 11:17 AM |
Difference between evaluation vs registered version of bookwise librarian? | askyn | Fictionwise eBookwise | 2 | 10-09-2008 05:26 PM |
Best for Microsoft Word - potential University evaluation | tomliversidge | Which one should I buy? | 24 | 07-03-2008 07:46 AM |
An e-ink competitor ready to step up? SiPix Offers 'Evaluation Package' | NatCh | News | 2 | 10-27-2006 10:59 PM |