View Single Post
Old 12-10-2021, 05:54 AM   #200
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,207
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
Wouldn't measuring the time elapsed (in template tester) provide some kind of rough measure, by which you can compare different templates? e.g.

Code:
program:
	start = format_date(today(), 'to_number');
	strcat('a');
	format_date(today(), 'to_number') - start
Edit: A custom function called (time_it) can do the same

Code:
def evaluate(self, formatter, kwargs, mi, locals, template):
    from calibre.utils.date import now
    start = now()
    template_output = formatter.__class__().safe_format(template, mi, 'TEMPLATE_ERROR', mi)
    diff = now() - start
    return diff.total_seconds()
Code:
program: time_it("program: strcat('a')")

Last edited by capink; 12-10-2021 at 06:24 AM.
capink is offline   Reply With Quote