View Issue Details

IDProjectCategoryView StatusLast Update
0009162ScribusScripterpublic2012-01-23 08:27
Reporterupegelow Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status newResolutionopen 
Platformx86OSLinux (OpenSuse)OS Version2.6.27.45
Product Version1.3.6 
Summary0009162: Drastic slow-down of scripter's function sizeObject
DescriptionI am experiencing a very strong slow-down of scripter function sizeObject since version 1.3.6. I have a small script to reproduce the effect (see below). It generates a number (nobj) of rectangular fields, puts them on some place and then does a number (nstep) of random size changes on these objects.

Scribus version 1.3.5.1 on my system needs 12 seconds for 320 objects and 40 size changes. Scribus version 1.3.6 needs 5300 seconds, over one hour for the same task. This is reproducible and seems to be the same for version 1.3.7.

For me this is important, as I use scribus to automatically generate a timetable out of entries in a database. A few hundred text frames need to be generated, adjusted in size (to avoid text overflows) and put into place. With the old 1.3.5.1 the job was done in a few minutes. Scribus 1.3.6 takes over 3 hours and is therefore not usable for me.
Steps To Reproduce#!/usr/bin/python
# -*- coding: utf-8 -*-

import scribus
import random
import resource


nobj=320
nstep=40

random.seed(1)

scribus.newDocument((1000, 1000), (0, 0, 0, 0), scribus.LANDSCAPE, 1, scribus.UNIT_MILLIMETERS, scribus.PAGE_1, 0, 1)

for i in xrange(nobj):

    name="field%d" % i
    x=(i % 10 + 1) * 40.0
    y=(i / 10 + 1) * 20.0

    scribus.createRect(x, y, 35, 15, name)

    for n in xrange(nstep):
        nh=random.uniform(10, 20)
        scribus.sizeObject(35, nh, name)

print resource.getrusage(resource.RUSAGE_SELF)
TagsNo tags attached.
Patch

Activities

cbradney

2010-06-13 14:24

administrator   ~0024065

PyObject *scribus_selectobj(PyObject* /* self */, PyObject* args)
{
    char *Name = const_cast<char*>("");
    if (!PyArg_ParseTuple(args, "es", "utf-8", &Name))
        return NULL;
    if(!checkHaveDocument())
        return NULL;
    PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
    if (i == NULL)
        return NULL;
    ScCore->primaryMainWindow()->view->SelectItemNr(i->ItemNr);
// Py_INCREF(Py_None);
// return Py_None;
    Py_RETURN_NONE;
}

has not changed from 1.3.5.1 to 1.3.7 (to current 1.3.8svn)

cbradney

2010-06-13 14:25

administrator   ~0024066

/* 04/07/10 returns selection if is not name specified pv */
PageItem* GetUniqueItem(QString name)
{
    if (name.length()==0)
        if (ScCore->primaryMainWindow()->doc->m_Selection->count() != 0)
            return ScCore->primaryMainWindow()->doc->m_Selection->itemAt(0);
        else
        {
            PyErr_SetString(NoValidObjectError, QString("Cannot use empty string for object name when there is no selection").toLocal8Bit().constData());
            return NULL;
        }
    else
        return getPageItemByName(name);
}

has not changed from 1.3.5.1 to 1.3.7 (to current 1.3.8svn)

cbradney

2010-06-13 14:27

administrator   ~0024067

and the call to ScCore->primaryMainWindow()->view->SelectItemNr(i->ItemNr); has no underlying code changes in SelectItem via SelectItemNr

cbradney

2010-06-13 14:33

administrator   ~0024068

Can you check the timings if the interior loop is commented out?
( for n in xrange(nstep):
        nh=random.uniform(10, 20)
        scribus.sizeObject(35, nh, name)
)

upegelow

2010-06-13 15:26

reporter   ~0024069

With the inner loop commented out I get 10 seconds for both scribus 1.3.5.1 and 1.3.6.
Maybe someone could try to reproduce my issue with the a.m. script on another system.

ale

2010-06-13 15:52

manager   ~0024071

i can confirm that the script takes very long with 1.3.8svn...

jghali

2010-06-13 22:31

administrator   ~0024079

Last edited: 2010-06-13 22:31

This issue is a side effect of a fix which triggers additional undo action. Fixing that function will not remove those actions (they are needed), so the workaround for this issue is to disable undo in preferences. The real fix will involve adding the possibility to enable/disable undo via script. We have to find first a proper way to provide that functionality as incorrect use of the internal functions which enable/disable undo can make the whole app go awry.

upegelow

2010-06-14 16:44

reporter   ~0024083

Last edited: 2010-06-14 16:50

@jghali:
Thank you for giving the workaround. I tried it directly with my timetable job and used scribus 1.3.7. Great performance now, even a 2-3 times speedup vs. 1.3.5.1.
For the time being I can live very well with this workaround.

And a big Thank You to the whole scribus team.
A great piece of software and a fantastic support. Less than 24 hours after posting my issue I had a working solution!

upegelow

2012-01-23 08:27

reporter   ~0027589

I re-checked the issue within the recent 1.4 series and the problem seems to be solved!

Issue History

Date Modified Username Field Change
2010-06-12 15:11 upegelow New Issue
2010-06-13 14:24 cbradney Note Added: 0024065
2010-06-13 14:25 cbradney Note Added: 0024066
2010-06-13 14:27 cbradney Note Added: 0024067
2010-06-13 14:33 cbradney Note Added: 0024068
2010-06-13 15:26 upegelow Note Added: 0024069
2010-06-13 15:52 ale Note Added: 0024071
2010-06-13 22:31 jghali Note Added: 0024079
2010-06-13 22:31 jghali Note Edited: 0024079
2010-06-14 16:44 upegelow Note Added: 0024083
2010-06-14 16:50 upegelow Note Edited: 0024083
2012-01-23 08:27 upegelow Note Added: 0027589