mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
function to time cover loading
This commit is contained in:
parent
e7e8c340ad
commit
818c4249d2
@ -8,7 +8,7 @@ def db(path=None):
|
||||
return LibraryDatabase2(path if path else prefs['library_path'])
|
||||
|
||||
|
||||
def generate_test_db(library_path,
|
||||
def generate_test_db(library_path, # {{{
|
||||
num_of_records=20000,
|
||||
num_of_authors=6000,
|
||||
num_of_tags=10000,
|
||||
@ -58,4 +58,24 @@ def generate_test_db(library_path,
|
||||
t = time.time() - start
|
||||
print '\nGenerated', num_of_records, 'records in:', t, 'seconds'
|
||||
print 'Time per record:', t/float(num_of_records)
|
||||
# }}}
|
||||
|
||||
def cover_load_timing(path=None):
|
||||
from PyQt4.Qt import QApplication, QImage
|
||||
import os, time
|
||||
app = QApplication([])
|
||||
app
|
||||
d = db(path)
|
||||
paths = [d.cover(i, index_is_id=True, as_path=True) for i in
|
||||
d.data.iterallids()]
|
||||
paths = [p for p in paths if (p and os.path.exists(p) and os.path.isfile(p))]
|
||||
|
||||
start = time.time()
|
||||
|
||||
for p in paths:
|
||||
with open(p, 'rb') as f:
|
||||
img = QImage()
|
||||
img.loadFromData(f.read())
|
||||
|
||||
print 'Average load time:', (time.time() - start)/len(paths), 'seconds'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user