[Solved] Macro performance - Huge difference

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
AndresSolar
Posts: 72
Joined: Sun Jun 26, 2016 5:42 am

[Solved] Macro performance - Huge difference

Post by AndresSolar »

I thought i read about that somewhere here on the forum but i couldn't find it again...

Depending on where i put the focus (sheet, basic-ide or desktop), the performance of macro execution differs quite dramatically. This is independent of the OS (Windows/prim. OSX). I get the best result if i switch to the basic-ide window and place the cursor into any module. The script itself is just to update the input data and manage buttons, etc. Auto-calc is off (controlled inside the script).

If this is a know effect, then how can i use it to optimize performance? The macro is started from a button on a sheet, so the focus is on the sheet the moment the macro starts.

Thanks in advance!
Last edited by Hagar Delest on Tue Apr 30, 2019 7:52 am, edited 1 time in total.
Reason: tagged solved
LO6.2 on OS-X Mojave 10.14.3
User avatar
Zizi64
Volunteer
Posts: 11361
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: macro performance - huge difference

Post by Zizi64 »

Please upload an ODF type sample file here with the embedded macro.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
AndresSolar
Posts: 72
Joined: Sun Jun 26, 2016 5:42 am

Re: macro performance - huge difference

Post by AndresSolar »

Hello Zizi,

thanks for your reply.

I figured out what happens. Even though the status bar was set hidden in the View-Menu, it pops in every time i update the screen - that means more or less permanently. In the main loop i fetch next days input data array while controllers are locked and action lock is added. Then i unlock all and recalculate since i want to observe the visual update on the screen. Finally i re-lock the controllers and add an action lock for the next day, etc.

Is it possible to force that status bar to stay hidden?

I tried this macro (https://ask.libreoffice.org/en/question ... r-forever/), but it didn't work (status bar pops in and out...)

Code: Select all

Sub HideStatusBar()
    ThisComponent.CurrentController.Frame.LayoutManager.HideElement( "private:resource/statusbar/statusbar" )
End Sub
Thx in advance
LO6.2 on OS-X Mojave 10.14.3
AndresSolar
Posts: 72
Joined: Sun Jun 26, 2016 5:42 am

Re: macro performance - huge difference

Post by AndresSolar »

...would it be possible to "hijack" the status bar but not use it?
LO6.2 on OS-X Mojave 10.14.3
JeJe
Volunteer
Posts: 2784
Joined: Wed Mar 09, 2016 2:40 pm

Re: Macro performance - huge difference

Post by JeJe »

You can easily control the status bar... use ThisComponent.CurrentController.StatusIndicator. with:

https://www.openoffice.org/api/docs/com ... cator.html
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
AndresSolar
Posts: 72
Joined: Sun Jun 26, 2016 5:42 am

Re: Macro performance - huge difference

Post by AndresSolar »

Thanks, JeJe,

i already tried that. the performance increase can be repeated by changing from the spreadsheet window to the basic IDE window after the macro was started (clicking the cursor in the editor). then the status bar stops all visible activities. i can even minimize the ide-window.

i think this is just an old bug within LO.
LO6.2 on OS-X Mojave 10.14.3
JeJe
Volunteer
Posts: 2784
Joined: Wed Mar 09, 2016 2:40 pm

Re: Macro performance - huge difference

Post by JeJe »

You can switch to the IDE in code using BasicIDEAppear. Have you tried showing a modal dialog while your code is running to see if that makes a difference? (with just a progress bar on it or a label saying "Working" maybe)
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
AndresSolar
Posts: 72
Joined: Sun Jun 26, 2016 5:42 am

Re: Macro performance - huge difference

Post by AndresSolar »

JeJe... thanks. i'm working on such a script right now.

the only thing really important is to get rid of those superfluous (who needs that during macro execution?) status bar messages "calculating...& progessbar" since it is slowing down the script execution by approx. 300-500% (and worse if i increase the zoom %).

A non modal dialog helps a little (strange enough) - similarly to if i hijack the status bar as my progress bar. only if i switch to the IDE-window, the status bar stays silent (but visible - even if hidden).

i tried to implement start/pause/stop for my simulator since all my cell-buttons (naked cell with a character, controlled by double-click and animated cell-styles) work flawlessly while the main loop is running :) - but: Starbasic won't let me change a global variable used to interrupt that main loop (Do While run = 1...). "it" hangs in the nowhere if i try to change run to 0.

maybe i have to open a modal dialog from within my macro to keep the focus on the IDE-window?
or change the focus to the IDE-window and hide that window?
LO6.2 on OS-X Mojave 10.14.3
JeJe
Volunteer
Posts: 2784
Joined: Wed Mar 09, 2016 2:40 pm

Re: Macro performance - huge difference

Post by JeJe »

Starbasic won't let me change a global variable used to interrupt that main loop (Do While run = 1...). "it" hangs in the nowhere if i try to change run to 0.
I can't replicate that - see attached testdoc.
Attachments
testdoc.odt
(10.65 KiB) Downloaded 287 times
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
AndresSolar
Posts: 72
Joined: Sun Jun 26, 2016 5:42 am

Re: Macro performance - huge difference

Post by AndresSolar »

i tried your macro (writer) - and it works. if i move all to my spreadsheet then it hangs LO as soon as i try to run it. the dialog doesn't show but the macro (still executing) can't be stopped.
LO6.2 on OS-X Mojave 10.14.3
AndresSolar
Posts: 72
Joined: Sun Jun 26, 2016 5:42 am

Re: Macro performance - huge difference

Post by AndresSolar »

JeJe:

my bad - it works. i just messed with some variable names. Many thanks!!
I tried as well to switch to the IDE-window. that works perfectly for now.
LO6.2 on OS-X Mojave 10.14.3
Post Reply