mirror of https://github.com/koreader/koreader
Merge pull request #2217 from chrox/benchmark_tool
fix k2pdfopt performance degradationpull/2220/head
commit
61b6896391
@ -1 +1 @@
|
|||||||
Subproject commit 07b6442b4cc52bfe41b64e2b5e0f528bbb11089f
|
Subproject commit d33be25e6ad412bb98a6fa2ac3edf5f26d36c8ca
|
@ -0,0 +1,55 @@
|
|||||||
|
-- performance benchmark utility
|
||||||
|
-- usage: ./luajit tools/benchmark.lua test/sample.pdf
|
||||||
|
|
||||||
|
require "defaults"
|
||||||
|
package.path = "common/?.lua;rocks/share/lua/5.1/?.lua;frontend/?.lua;" .. package.path
|
||||||
|
package.cpath = "common/?.so;common/?.dll;/usr/lib/lua/?.so;rocks/lib/lua/5.1/?.so;" .. package.cpath
|
||||||
|
|
||||||
|
local DataStorage = require("datastorage")
|
||||||
|
--G_reader_settings = require("docsettings"):open(".reader")
|
||||||
|
G_reader_settings = require("luasettings"):open(
|
||||||
|
DataStorage:getDataDir().."/settings.reader.lua")
|
||||||
|
|
||||||
|
-- global einkfb for Screen (do not show SDL window)
|
||||||
|
einkfb = require("ffi/framebuffer")
|
||||||
|
einkfb.dummy = true
|
||||||
|
|
||||||
|
local DocumentRegistry = require("document/documentregistry")
|
||||||
|
local Koptinterface = require("document/koptinterface")
|
||||||
|
local util = require("ffi/util")
|
||||||
|
local DEBUG = require("dbg")
|
||||||
|
DEBUG:turnOn()
|
||||||
|
|
||||||
|
DEBUG("args", arg)
|
||||||
|
|
||||||
|
function logDuration(filename, pageno, dur)
|
||||||
|
local file = io.open(filename, "a+")
|
||||||
|
if file then
|
||||||
|
file:write(string.format("%s\t%s\n", pageno, dur))
|
||||||
|
file:close()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function doAutoBBox(doc, page)
|
||||||
|
Koptinterface:getAutoBBox(doc, page)
|
||||||
|
end
|
||||||
|
|
||||||
|
function doReflow(doc, page)
|
||||||
|
Koptinterface:getCachedContext(doc, page)
|
||||||
|
end
|
||||||
|
|
||||||
|
function benchmark(filename, doForOnePage)
|
||||||
|
local doc = DocumentRegistry:openDocument(filename)
|
||||||
|
for i = 1, doc:getPageCount() do
|
||||||
|
local secs, usecs = util.gettime()
|
||||||
|
doForOnePage(doc, i)
|
||||||
|
local nsecs, nusecs = util.gettime()
|
||||||
|
local dur = nsecs - secs + (nusecs - usecs) / 1000000
|
||||||
|
DEBUG("duration for page", i, dur)
|
||||||
|
logDuration("benchmark.txt", i, dur)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--benchmark(arg[1], doAutoBBox)
|
||||||
|
benchmark(arg[1], doReflow)
|
||||||
|
|
@ -1,19 +1,18 @@
|
|||||||
-- touch probe utility
|
-- touch probe utility
|
||||||
-- usage: ./luajit util/kobo_touch_probe.lua
|
-- usage: ./luajit tools/kobo_touch_probe.lua
|
||||||
|
|
||||||
require "defaults"
|
require "defaults"
|
||||||
package.path = "common/?.lua;rocks/share/lua/5.1/?.lua;frontend/?.lua;" .. package.path
|
package.path = "common/?.lua;rocks/share/lua/5.1/?.lua;frontend/?.lua;" .. package.path
|
||||||
package.cpath = "common/?.so;common/?.dll;/usr/lib/lua/?.so;rocks/lib/lua/5.1/?.so;" .. package.cpath
|
package.cpath = "common/?.so;common/?.dll;/usr/lib/lua/?.so;rocks/lib/lua/5.1/?.so;" .. package.cpath
|
||||||
|
|
||||||
local DocSettings = require("docsettings")
|
local DataStorage = require("datastorage")
|
||||||
local _ = require("gettext")
|
local _ = require("gettext")
|
||||||
|
|
||||||
-- read settings and check for language override
|
-- read settings and check for language override
|
||||||
-- has to be done before requiring other files because
|
-- has to be done before requiring other files because
|
||||||
-- they might call gettext on load
|
-- they might call gettext on load
|
||||||
if G_reader_settings == nil then
|
G_reader_settings = require("luasettings"):open(
|
||||||
G_reader_settings = DocSettings:open(".reader")
|
DataStorage:getDataDir().."/settings.reader.lua")
|
||||||
end
|
|
||||||
local lang_locale = G_reader_settings:readSetting("language")
|
local lang_locale = G_reader_settings:readSetting("language")
|
||||||
if lang_locale then
|
if lang_locale then
|
||||||
_.changeLang(lang_locale)
|
_.changeLang(lang_locale)
|
@ -1,5 +1,5 @@
|
|||||||
-- trace package loading flow with require call
|
-- trace package loading flow with require call
|
||||||
-- usage: ./luajit -lutils/trace_require reader.lua ../../test
|
-- usage: ./luajit -ltools/trace_require reader.lua ../../test
|
||||||
|
|
||||||
local math = require("math")
|
local math = require("math")
|
||||||
local _require = require
|
local _require = require
|
@ -1,5 +1,5 @@
|
|||||||
-- widget test utility
|
-- widget test utility
|
||||||
-- usage: ./luajit util/wtest.lua
|
-- usage: ./luajit tools/wtest.lua
|
||||||
|
|
||||||
require "defaults"
|
require "defaults"
|
||||||
print(package.path)
|
print(package.path)
|
Loading…
Reference in New Issue