summaryrefslogtreecommitdiff
path: root/libreofficekit
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2014-10-01 22:14:49 +0100
committerMichael Meeks <michael.meeks@collabora.com>2014-10-02 00:23:06 +0100
commit87fad21582fceb200e3630e9ec10a873f7d7a3ed (patch)
tree65d82d1304c940c554be68894fc1dbf695a9e29c /libreofficekit
parent213be0be8e41480e0036c0e30a8be93369aa743a (diff)
LOK: Add a tiled rendering testbench.
Change-Id: I631c0506f427d974c3dd4c75484aa25603100895
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/Executable_tilebench.mk32
-rw-r--r--libreofficekit/Module_libreofficekit.mk4
-rw-r--r--libreofficekit/qa/tilebench/tilebench.cxx90
3 files changed, 126 insertions, 0 deletions
diff --git a/libreofficekit/Executable_tilebench.mk b/libreofficekit/Executable_tilebench.mk
new file mode 100644
index 000000000000..11e73dead0bd
--- /dev/null
+++ b/libreofficekit/Executable_tilebench.mk
@@ -0,0 +1,32 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Executable_Executable,tilebench))
+
+$(eval $(call gb_Executable_set_include,tilebench,\
+ $$(INCLUDE) \
+ -I$(SRCDIR)/desktop/inc \
+))
+
+$(eval $(call gb_Executable_use_libraries,tilebench,\
+ libreofficekitgtk \
+ sal \
+))
+
+$(eval $(call gb_Executable_add_libs,tilebench,\
+ -lm \
+ -ldl \
+ -lpthread \
+))
+
+$(eval $(call gb_Executable_add_exception_objects,tilebench,\
+ libreofficekit/qa/tilebench/tilebench \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/libreofficekit/Module_libreofficekit.mk b/libreofficekit/Module_libreofficekit.mk
index a5b9cb06348c..716ff48512fa 100644
--- a/libreofficekit/Module_libreofficekit.mk
+++ b/libreofficekit/Module_libreofficekit.mk
@@ -22,6 +22,10 @@ $(eval $(call gb_Module_add_targets,libreofficekit,\
))
endif # ($(ENABLE_GTK),)
+$(eval $(call gb_Module_add_targets,libreofficekit,\
+ Executable_tilebench \
+))
+
endif # ($(OS),LINUX)
# vim: set ts=4 sw=4 et:
diff --git a/libreofficekit/qa/tilebench/tilebench.cxx b/libreofficekit/qa/tilebench/tilebench.cxx
new file mode 100644
index 000000000000..80d5c1654db7
--- /dev/null
+++ b/libreofficekit/qa/tilebench/tilebench.cxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <vector>
+#include <osl/time.h>
+#include <LibreOfficeKit/LibreOfficeKitInit.h>
+#include <LibreOfficeKit/LibreOfficeKit.hxx>
+
+using namespace lok;
+
+static int help()
+{
+ fprintf( stderr, "Usage: tilebench <absolute-path-to-libreoffice-install> [path to document]\n" );
+ fprintf( stderr, "renders a selection of small tiles from the document, checksums them and times the process\n" );
+ return 1;
+}
+
+static double getTimeNow()
+{
+ TimeValue aValue;
+ osl_getSystemTime(&aValue);
+ return (double)aValue.Seconds +
+ (double)aValue.Nanosec / (1000*1000*1000);
+}
+
+int main( int argc, char* argv[] )
+{
+ struct TimeRecord {
+ const char *mpName;
+ double mfTime;
+
+ TimeRecord() : mpName(NULL), mfTime(getTimeNow()) { }
+ explicit TimeRecord(const char *pName) :
+ mpName(pName ), mfTime(getTimeNow()) { }
+ explicit TimeRecord(const TimeRecord *pSrc) :
+ mpName(pSrc->mpName), mfTime(pSrc->mfTime) { }
+ };
+ std::vector< TimeRecord > aTimes;
+ if( argc < 2 ||
+ ( argc > 1 && ( !strcmp( argv[1], "--help" ) || !strcmp( argv[1], "-h" ) ) ) )
+ return help();
+
+ if ( argv[1][0] != '/' )
+ {
+ fprintf(stderr, "Absolute path required to libreoffice install\n");
+ return 1;
+ }
+
+ aTimes.push_back(TimeRecord("initialization"));
+ Office *pOffice = lok_cpp_init(argv[1]);
+ aTimes.push_back(TimeRecord());
+
+ if (argv[2] != NULL)
+ {
+ aTimes.push_back(TimeRecord("load document"));
+ Document *pDocument(pOffice->documentLoad(argv[2]));
+ aTimes.push_back(TimeRecord());
+
+ aTimes.push_back(TimeRecord("destroy document"));
+ delete pDocument;
+ aTimes.push_back(TimeRecord());
+ }
+
+ delete pOffice;
+
+ double nTotal = 0.0;
+ fprintf (stderr, "profile run:\n");
+ for (size_t i = 0; i < aTimes.size() - 1; i++)
+ {
+ double nDelta = aTimes[i+1].mfTime - aTimes[i].mfTime;
+ fprintf (stderr, " %s - %2.4f(ms)\n", aTimes[i].mpName, nDelta * 1000.0);
+ if (aTimes[i+1].mpName == NULL)
+ i++; // skip it.
+ nTotal += nDelta;
+ }
+ fprintf (stderr, "Total: %2.4f(s)\n", nTotal);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */