mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Cache: Rewrite based on lua-lru
Ought to be faster than our naive array-based approach. Especially for the glyph cache, which has a solid amount of elements, and is mostly cache hits. (There are few things worse for performance in Lua than table.remove @ !tail and table.insert @ !tail, which this was full of :/). DocCache: New module that's now an actual Cache instance instead of a weird hack. Replaces "Cache" (the instance) as used across Document & co. Only Cache instance with on-disk persistence. ImageCache: Update to new Cache. GlyphCache: Update to new Cache. Also, actually free glyph bbs on eviction.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
describe("Cache module", function()
|
||||
local DocumentRegistry, Cache
|
||||
local DocumentRegistry, DocCache
|
||||
local doc
|
||||
local max_page = 1
|
||||
setup(function()
|
||||
require("commonrequire")
|
||||
DocumentRegistry = require("document/documentregistry")
|
||||
Cache = require("cache")
|
||||
DocCache = require("document/doccache")
|
||||
|
||||
local sample_pdf = "spec/front/unit/data/sample.pdf"
|
||||
doc = DocumentRegistry:openDocument(sample_pdf)
|
||||
@@ -15,22 +15,22 @@ describe("Cache module", function()
|
||||
end)
|
||||
|
||||
it("should clear cache", function()
|
||||
Cache:clear()
|
||||
DocCache:clear()
|
||||
end)
|
||||
|
||||
it("should serialize blitbuffer", function()
|
||||
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
|
||||
doc:renderPage(pageno, nil, 1, 0, 1.0, 0)
|
||||
Cache:serialize()
|
||||
DocCache:serialize()
|
||||
end
|
||||
Cache:clear()
|
||||
DocCache:clear()
|
||||
end)
|
||||
|
||||
it("should deserialize blitbuffer", function()
|
||||
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
|
||||
doc:hintPage(pageno, 1, 0, 1.0, 0)
|
||||
end
|
||||
Cache:clear()
|
||||
DocCache:clear()
|
||||
end)
|
||||
|
||||
it("should serialize koptcontext", function()
|
||||
@@ -38,9 +38,9 @@ describe("Cache module", function()
|
||||
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
|
||||
doc:renderPage(pageno, nil, 1, 0, 1.0, 0)
|
||||
doc:getPageDimensions(pageno)
|
||||
Cache:serialize()
|
||||
DocCache:serialize()
|
||||
end
|
||||
Cache:clear()
|
||||
DocCache:clear()
|
||||
doc.configurable.text_wrap = 0
|
||||
end)
|
||||
|
||||
@@ -48,6 +48,6 @@ describe("Cache module", function()
|
||||
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
|
||||
doc:renderPage(pageno, nil, 1, 0, 1.0, 0)
|
||||
end
|
||||
Cache:clear()
|
||||
DocCache:clear()
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user