Date: prev next · Thread: first prev next last
2014 Archives by date, by thread · List index


Hello,

I'm opening this ML thread based on the following two forum discussions,
none of which have yielded much resolution yet:

  http://en.libreofficeforum.org/node/9850
  https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=74332

To summarize: I run an office instance locally, headless, as a listener.
Using Python and UNO I connect to that office instance, load a test
document, and iterate over its paragraphs.

On my Mac this takes 1.5s while on Linux it takes about 45s, a severe
degradation in performance.  I could reproduce this across three
different Linux machines now consistently (Gentoo, Ubuntu).

The test document and Python script are attached to both forum
discussions, and to this email.

I have not yet started a more thorough profiling of the office instance,
hoping that raising this issue to the developers might solve the
problems.

Thanks!
Jens

-- 
Jens Tröger
http://savage.light-speed.de/

Attachment: lorem.odt
Description: application/vnd.oasis.opendocument.text


import socket
import errno
import subprocess
import time
import uno
import os

if __name__ == "__main__" :

    def check_socket() :
        print("Trying to connect to office socket.")
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        result = sock.connect_ex(("localhost", 2002))
        if not result :
            print("Connected to office socket, closing test connection.")
            sock.shutdown(socket.SHUT_RDWR)
        else :
            print("Failed to connect to office socket (" + str(result) + ": " + 
errno.errorcode[result] + ").")
        sock.close()
        return result

    #
    #
    #

    myenv = os.environ.copy()                                                   
    #myenv["DISPLAY"] = ""

    # --headless --accept="socket,host=localhost,port=2002,tcpNoDelay=1;urp" --nodefault 
--nofirststartwizard --nolockcheck --nologo --norestore --invisible
    p = subprocess.Popen("soffice 
--accept=\"socket,host=localhost,port=2002;urp;StarOffice.ServiceManager\" --headless", shell=True, 
env=myenv)
    print("Spawning office instance pid=" + str(p.pid))

    while True : # BUGBUG Ought to be a countdown, not an infinite loop!
        time.sleep(2)
        if not check_socket() :
            break

    #
    #
    #

    local = uno.getComponentContext()
    resolver = local.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", 
local)
    context = 
resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
    desktop = context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", 
context)
    document = desktop.loadComponentFromURL("file://" + os.path.abspath("lorem.odt"), "_blank", 0, 
())

    start_time = time.time()

    parenum = document.Text.createEnumeration()
    while parenum.hasMoreElements() :
        par = parenum.nextElement()

    end_time = time.time()
    print("Elapsed time: " + str(end_time - start_time))

    p.terminate()


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.