// this is to compare the time it takes to layout a whole ebook file // using different text measurement method (since the time is mostly // dominated by text measure) void BenchEbookLayout(const WCHAR *filePath) { bool deleteLog = false; if (!gLog) { gLog = new slog::StderrLogger(); deleteLog = true; } logbench(L"Starting: %s", filePath); if (!file::Exists(filePath)) { logbench(L"Error: file doesn't exist"); return; } if (!Doc::IsSupportedFile(filePath)) { logbench(L"Error: not an ebook file"); return; } Timer t; Doc doc = Doc::CreateFromFile(filePath); if (doc.LoadingFailed()) { logbench(L"Error: failed to load the file as doc"); doc.Delete(); return; } double timeMs = t.Stop(); logbench(L"load: %.2f ms", timeMs); int nPages = TimeOneMethod(doc, TextRenderMethodGdi, L"gdi "); TimeOneMethod(doc, TextRenderMethodGdiplus, L"gdi+ "); TimeOneMethod(doc, TextRenderMethodGdiplusQuick, L"gdi+ quick"); // do it twice because the first run is very unfair to the first version that runs // (probably because of font caching) TimeOneMethod(doc, TextRenderMethodGdi, L"gdi "); TimeOneMethod(doc, TextRenderMethodGdiplus, L"gdi+ "); TimeOneMethod(doc, TextRenderMethodGdiplusQuick, L"gdi+ quick"); doc.Delete(); logbench(L"pages: %d", nPages); if (deleteLog) { delete gLog; } }