rougier/svg-lib

svg-lib performs slow when rendering hundreds of icons

chenyanming opened this issue · 3 comments

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.

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).

Thanks your help!

@chenyanming Could you make a PR for the README?