edge2992 / toy-browser

Reimplemented a web browser using Python.
0 stars 0 forks source link

Too slow #5

Open edge2992 opened 1 year ago

edge2992 commented 1 year ago

On some systems, the measure and metrics commands are awfully slow. Adding another call makes things even slower.

Luckily, this metrics call duplicates a call in flush. If you’re careful you can pass the results of that call to DrawText as an argument.

https://browser.engineering/layout.html

edge2992 commented 1 year ago

You can profile Python programs by replacing your python3 command with python3 -m cProfile. Look for the lines corresponding to the measure and metrics calls to see how much time is spent measuring text.

edge2992 commented 1 year ago

https://python.hotexamples.com/examples/tkinter.font/Font/measure/python-font-measure-method-examples.html