[Libreoffice-commits] core.git: 2 commits - android/mobile-config.py libreofficekit/Executable_tilebench.mk libreofficekit/Module_libreofficekit.mk libreofficekit/qa Repository.mk

Michael Meeks michael.meeks at collabora.com
Wed Oct 1 16:24:28 PDT 2014


 Repository.mk                             |    1 
 android/mobile-config.py                  |   99 +++++++++++++++++
 libreofficekit/Executable_tilebench.mk    |   32 +++++
 libreofficekit/Module_libreofficekit.mk   |    4 
 libreofficekit/qa/tilebench/tilebench.cxx |  172 ++++++++++++++++++++++++++++++
 5 files changed, 308 insertions(+)

New commits:
commit a131feddd07bcb75112b1f80a16b8733458338e4
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Oct 2 00:21:30 2014 +0100

    LOK: Excercise tiled-rendering harder in the test-bench.
    
    Change-Id: I13a93991050cc25d06f2836d85ec1d0a0bc574f1

diff --git a/libreofficekit/qa/tilebench/tilebench.cxx b/libreofficekit/qa/tilebench/tilebench.cxx
index 80d5c16..edb6889 100644
--- a/libreofficekit/qa/tilebench/tilebench.cxx
+++ b/libreofficekit/qa/tilebench/tilebench.cxx
@@ -13,6 +13,9 @@
 
 #include <vector>
 #include <osl/time.h>
+
+#define LOK_USE_UNSTABLE_API
+
 #include <LibreOfficeKit/LibreOfficeKitInit.h>
 #include <LibreOfficeKit/LibreOfficeKit.hxx>
 
@@ -66,6 +69,85 @@ int main( int argc, char* argv[] )
         Document *pDocument(pOffice->documentLoad(argv[2]));
         aTimes.push_back(TimeRecord());
 
+        aTimes.push_back(TimeRecord("getparts"));
+        int nParts = pDocument->getParts();
+        aTimes.push_back(TimeRecord());
+
+        aTimes.push_back(TimeRecord("get size of parts"));
+        for (int nPart = 0; nPart < nParts; nPart++)
+        {
+            char* pName = pDocument->getPartName(nPart);
+            pDocument->setPart(nPart);
+            long nWidth = 0, nHeight = 0;
+            pDocument->getDocumentSize(&nWidth, &nHeight);
+            fprintf (stderr, "  '%s' -> %ld, %ld\n", pName, nWidth, nHeight);
+            free (pName);
+        }
+        aTimes.push_back(TimeRecord());
+
+        unsigned char pPixels[256*256*4];
+        for (int nPart = 0; nPart < nParts; nPart++)
+        {
+            {
+                char* pName = pDocument->getPartName(nPart);
+                fprintf (stderr, "render '%s'\n", pName);
+                free (pName);
+            }
+            pDocument->setPart(nPart);
+            long nWidth = 0, nHeight = 0;
+            pDocument->getDocumentSize(&nWidth, &nHeight);
+
+            { // whole document
+                aTimes.push_back(TimeRecord("render whole document"));
+                int nRowStride = 256;
+                pDocument->paintTile(pPixels, 256, 256, &nRowStride,
+                                     0, 0, nWidth, nHeight); // not square
+                aTimes.push_back(TimeRecord());
+            }
+
+            { // 1:1
+                aTimes.push_back(TimeRecord("render sub-region at 1:1"));
+                int nTiles = 0;
+                int nSplit = nWidth / 4;
+                for (int nX = 0; nX < 4; nX++)
+                {
+                    for (int nY = 0; nY < nHeight / nSplit; nY++)
+                    {
+                        int nRowStride = 256;
+                        int nTilePosX = nX * nSplit;
+                        int nTilePosY = nY * nSplit;
+                        pDocument->paintTile(pPixels, 256, 256, &nRowStride,
+                                             nTilePosX, nTilePosY, 256, 256);
+                        nTiles++;
+                        fprintf (stderr, "   rendered tile %d at %d, %d\n",
+                                 nTiles, nTilePosX, nTilePosY);
+                    }
+                }
+                aTimes.push_back(TimeRecord());
+            }
+
+            { // scaled
+                aTimes.push_back(TimeRecord("render sub-regions at scale"));
+                int nTiles = 0;
+                int nSplit = nWidth / 4;
+                for (int nX = 0; nX < 4; nX++)
+                {
+                    for (int nY = 0; nY < nHeight / nSplit; nY++)
+                    {
+                        int nRowStride = 256;
+                        int nTilePosX = nX * nSplit;
+                        int nTilePosY = nY * nSplit;
+                        pDocument->paintTile(pPixels, 256, 256, &nRowStride,
+                                             nTilePosX, nTilePosY, nSplit, nSplit);
+                        nTiles++;
+                        fprintf (stderr, "   rendered tile %d at %d, %d\n",
+                                 nTiles, nTilePosX, nTilePosY);
+                    }
+                }
+                aTimes.push_back(TimeRecord());
+            }
+        }
+
         aTimes.push_back(TimeRecord("destroy document"));
         delete pDocument;
         aTimes.push_back(TimeRecord());
commit 87fad21582fceb200e3630e9ec10a873f7d7a3ed
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Wed Oct 1 22:14:49 2014 +0100

    LOK: Add a tiled rendering testbench.
    
    Change-Id: I631c0506f427d974c3dd4c75484aa25603100895

diff --git a/Repository.mk b/Repository.mk
index 7b86d58..29dbf6e 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -86,6 +86,7 @@ $(eval $(call gb_Helper_register_executables_for_install,OOO,ooo, \
 ))
 
 $(eval $(call gb_Helper_register_executables,OOO, \
+	$(if $(filter LINUX,$(OS)), tilebench) \
 	$(call gb_Helper_optional,CRASHREP,crashrep) \
 	gnome-open-url.bin \
 	$(if $(filter-out ANDROID IOS MACOSX WNT,$(OS)),oosplash) \
diff --git a/android/mobile-config.py b/android/mobile-config.py
new file mode 100755
index 0000000..6f29297
--- /dev/null
+++ b/android/mobile-config.py
@@ -0,0 +1,99 @@
+#!/usr/bin/python
+# 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/.
+
+# this tool rips out configuration pieces that are not useful for
+# a mobile viewer / editing application without a full UI.
+#
+# ideally the postprocess/ makefile would cope with this but its
+# already over-complicated by rampant conditionals.
+
+import sys
+import xml.etree.ElementTree as ET
+
+
+main_xcd_discard = [
+    'org.openoffice.Office/TableWizard', # huge
+
+    'org.openoffice.Office/WebWizard',
+    'org.openoffice.Office.DataAccess/Drivers', # no database
+    'org.openoffice.Office/Addons', # no addons
+
+    # no conventional UI; reverse sorted by size
+    'org.openoffice.Office.UI/GenericCommands',
+    'org.openoffice.Office/Accelerators',
+    'org.openoffice.Office/UI',
+
+    'org.openoffice.Office.UI/DrawImpressCommands',
+    'org.openoffice.Office.UI/Sidebar',
+    'org.openoffice.Office.UI/ChartCommands',
+    'org.openoffice.Office.UI/DbuCommands',
+    'org.openoffice.Office.UI/Controller',
+    'org.openoffice.Office/UI',
+    'org.openoffice.Office.UI/StartModuleCommands',
+    'org.openoffice.Office.UI/BasicIDEWindowState',
+    'org.openoffice.Office.UI/GenericCategories',
+    'org.openoffice.Office.UI/ChartWindowState',
+    'org.openoffice.Office.UI/Factories',
+    'org.openoffice.Office.UI/BaseWindowState',
+    'org.openoffice.Office.UI/BasicIDECommands',
+    'org.openoffice.Office.UI/Sidebar',
+    'org.openoffice.Office.UI/BibliographyCommands',
+    'org.openoffice.Office.UI/DbQueryWindowState',
+    'org.openoffice.Office.UI/WindowState',
+    'org.openoffice.Office.UI/Controller',
+    'org.openoffice.Office.UI/DbRelationWindowState',
+    'org.openoffice.Office.UI/DbTableWindowState',
+    'org.openoffice.Office.UI/DbTableDataWindowState',
+    'org.openoffice.Office.UI/DbBrowserWindowState',
+    'org.openoffice.Office.UI/WindowContentFactories',
+    'org.openoffice.Office.UI/Factories',
+    'org.openoffice.Office.UI/StartModuleWindowState',
+    'org.openoffice.Office.UI/GlobalSettings',
+    'org.openoffice.Office.UI/Commands',
+    'org.openoffice.Office.UI/BibliographyCommands',
+    'org.openoffice.Office.UI/StartModuleCommands',
+    'org.openoffice.Office.UI/DrawImpressCommands',
+    'org.openoffice.Office.UI/BasicIDECommands',
+    'org.openoffice.Office.UI/GenericCommands',
+    'org.openoffice.Office.UI/ChartCommands',
+    'org.openoffice.Office.UI/DbuCommands',
+    'org.openoffice.Office.UI/BibliographyWindowState',
+    'org.openoffice.Office.UI/StartModuleWindowState',
+    'org.openoffice.Office.UI/DbTableDataWindowState',
+    'org.openoffice.Office.UI/DbRelationWindowState',
+    'org.openoffice.Office.UI/DbBrowserWindowState',
+    'org.openoffice.Office.UI/BasicIDEWindowState',
+    'org.openoffice.Office.UI/DbTableWindowState',
+    'org.openoffice.Office.UI/DbQueryWindowState',
+    'org.openoffice.Office.UI/ChartWindowState',
+    'org.openoffice.Office.UI/BaseWindowState',
+    'org.openoffice.Office.UI/GenericCategories',
+    'org.openoffice.Office.UI/Category',
+    ]
+
+
+if __name__ == '__main__':
+    tree = ET.parse(sys.argv[1])
+    root = tree.getroot()
+
+    print "Foo\n"
+    saved = 0
+    total = 0
+    for child in root:
+        section = child.attrib['{http://openoffice.org/2001/registry}name']
+        package = child.attrib['{http://openoffice.org/2001/registry}package']
+        size = len(ET.tostring(child));
+        total = total + size
+        key = '%s/%s' % (package, section)
+        if key in main_xcd_discard:
+            root.remove(child)
+            print 'removed %s - saving %d' % (key, size)
+            saved = saved + size
+
+    print "saved %d of %d bytes: %2.f%%" % (saved, total, saved*100.0/total)
+    tree.write(sys.argv[2], 'UTF-8', True)
+
diff --git a/libreofficekit/Executable_tilebench.mk b/libreofficekit/Executable_tilebench.mk
new file mode 100644
index 0000000..11e73de
--- /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 a5b9cb0..716ff48 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 0000000..80d5c16
--- /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: */


More information about the Libreoffice-commits mailing list