2014-10-07 05:06:06 +00:00
|
|
|
require("commonrequire")
|
2014-05-18 13:26:18 +00:00
|
|
|
local DocumentRegistry = require("document/documentregistry")
|
2014-05-30 15:16:40 +00:00
|
|
|
local util = require("ffi/util")
|
2014-05-18 13:26:18 +00:00
|
|
|
|
2017-08-08 20:35:40 +00:00
|
|
|
local function logDuration(filename, pageno, dur)
|
2014-05-18 13:26:18 +00:00
|
|
|
local file = io.open(filename, "a+")
|
|
|
|
if file then
|
|
|
|
if file:seek("end") == 0 then -- write the header only once
|
|
|
|
file:write("PAGE\tDUR\n")
|
|
|
|
end
|
|
|
|
file:write(string.format("%s\t%s\n", pageno, dur))
|
|
|
|
file:close()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe("PDF rendering benchmark", function()
|
|
|
|
local sample_pdf = "spec/front/unit/data/sample.pdf"
|
|
|
|
local doc = DocumentRegistry:openDocument(sample_pdf)
|
2014-05-30 15:16:40 +00:00
|
|
|
for pageno = 1, math.min(10, doc.info.number_of_pages) do
|
2014-05-18 13:26:18 +00:00
|
|
|
local secs, usecs = util.gettime()
|
|
|
|
assert.truthy(doc:renderPage(pageno, nil, 1, 0, 1.0, 0))
|
|
|
|
local nsecs, nusecs = util.gettime()
|
|
|
|
local dur = nsecs - secs + (nusecs - usecs) / 1000000
|
|
|
|
logDuration("pdf_rendering.log", pageno, dur)
|
|
|
|
end
|
|
|
|
doc:close()
|
|
|
|
end)
|
|
|
|
|
2014-05-30 15:16:40 +00:00
|
|
|
describe("PDF reflowing benchmark", function()
|
|
|
|
local sample_pdf = "spec/front/unit/data/sample.pdf"
|
|
|
|
local doc = DocumentRegistry:openDocument(sample_pdf)
|
|
|
|
doc.configurable.text_wrap = 1
|
|
|
|
for pageno = 1, math.min(10, doc.info.number_of_pages) do
|
|
|
|
local secs, usecs = util.gettime()
|
|
|
|
assert.truthy(doc:renderPage(pageno, nil, 1, 0, 1.0, 0))
|
|
|
|
local nsecs, nusecs = util.gettime()
|
|
|
|
local dur = nsecs - secs + (nusecs - usecs) / 1000000
|
|
|
|
logDuration("pdf_reflowing.log", pageno, dur)
|
|
|
|
end
|
|
|
|
doc:close()
|
2016-04-19 06:50:36 +00:00
|
|
|
doc.configurable.text_wrap = 0
|
2014-05-30 15:16:40 +00:00
|
|
|
end)
|
|
|
|
|