Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizing startup time #37

Closed
me21 opened this issue May 30, 2022 · 5 comments
Closed

Optimizing startup time #37

me21 opened this issue May 30, 2022 · 5 comments

Comments

@me21
Copy link
Contributor

me21 commented May 30, 2022

It would be nice to conditionally omit imports of LinePlot and Plot classes. Doing so brought the startup time on Beaglebone Black single board computer from 20+ to 8 seconds.

Another similar thing is justpy importing its chartcomponents.py inside, but perhaps this is an issue for their own repository.

@falkoschindler
Copy link
Contributor

I'm having trouble reproducing your result. The following code measures the time from starting the script until the UI is running. Independent of whether LinePlot and Plot are imported in ui.py, the time is always around 1.4s on my MacBook. Maybe it's an issue with Matplotlib on different processor architectures. Or I misunderstood something.

import time
t = time.time()

from nicegui import ui

ui.label('Hello world!')

ui.on_startup(lambda: print(f'{time.time() - t:.3f}'))

ui.run(port=1234)

@me21
Copy link
Contributor Author

me21 commented May 30, 2022

I'll try to run your code, but I think MacBook is much more powerful than Beaglebone Black, so maybe it's not noticeable there.
I'll update this issue later.

@me21
Copy link
Contributor Author

me21 commented May 30, 2022

With commented imports:

debian@beaglebone:~$ web_env/bin/python nicegui_test.py
/home/debian/web_env/lib/python3.7/site-packages/justpy
Module directory: /home/debian/web_env/lib/python3.7/site-packages/justpy, Application directory: /home/debian
JustPy ready to go on http://0.0.0.0:1234
14.747

With uncommented imports:

debian@beaglebone:~$ web_env/bin/python nicegui_test.py
/home/debian/web_env/lib/python3.7/site-packages/justpy
Module directory: /home/debian/web_env/lib/python3.7/site-packages/justpy, Application directory: /home/debian
JustPy ready to go on http://0.0.0.0:1234
37.066

In my research, I ran python interpreter with -X importtime flag to generate import statements timings. And viewed it with tuna tool. But the results are the same, nicegui is much slower on Beaglebone Black with plot imports.

@falkoschindler
Copy link
Contributor

Ok, we checked the timing on a Jetson Nano and got 4.0 seconds each. The large difference might be caused by the little RAM you have available on the Beaglebone Black.

Nevertheless, we will shortly implement feature flags for things like Matplotlib, Highcharts, AG Grid and Three.js.

@falkoschindler
Copy link
Contributor

Ok, it is finally released as v0.7.29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants