rougier / svg-lib

Emacs SVG libraries for creatings tags, icons and bars
GNU General Public License v3.0
343 stars 31 forks source link

svg-lib performs slow when rendering hundreds of icons #4

Open chenyanming opened 3 years ago

chenyanming commented 3 years ago

First of all, thanks for your beautiful library!

I am writing a lib which uses svg-lib, and I am using to it render a list, the list has hundreds of items. But if I render 200+ all with svg-lib like the suggested way:

(benchmark 1 '(dotimes (i 200) (svg-lib-icon "open-in-new" nil :scale 1 :height 0.9 :margin 0 :padding 0 :stroke 0)))

It cost me around "Elapsed time: 1.511166s (0.211818s in 1 GCs)", excluding the svg download time.

Now I have to save the svg properties, and do looping at later execution, since each icon type is needed and only to be generated once (it can cache on the disk or memory).

(benchmark 1 '(let ((svg (svg-lib-icon "open-in-new" nil :scale 1 :height 0.9 :margin 0 :padding 0 :stroke 0)) )
                (dotimes (i 200) svg)))

It only consumes "Elapsed time: 0.009498s".

Another way is save it as defvar, and use it in later program.

Thanks you again, for this brilliant library.

rougier commented 3 years ago

Oh thanks for the benchmarking. It might be worth to be added in the README. Could you make a PR (or maybe wait that I expand the README a bit).

chenyanming commented 3 years ago

Thanks your help!

rougier commented 3 years ago

@chenyanming Could you make a PR for the README?