arbre icon indicating copy to clipboard operation
arbre copied to clipboard

Indent Perfomance

Open alexesDev opened this issue 6 years ago • 2 comments

Hi. I see Arbre::HTML::Tag#indent in stackprof top and it confuses me.

  Mode: cpu(1000)
  Samples: 172 (0.00% miss rate)
  GC: 33 (19.19%)
==================================
     TOTAL    (pct)     SAMPLES    (pct)     FRAME
        33  (19.2%)          33  (19.2%)     (garbage collection)
        29  (16.9%)          29  (16.9%)     ActiveSupport::SafeBuffer#initialize
        14   (8.1%)          13   (7.6%)     Arbre::Element#initialize
        11   (6.4%)          11   (6.4%)     Arbre::HTML::Attributes#value_empty?
        19  (11.0%)           8   (4.7%)     Arbre::HTML::Tag#indent
         7   (4.1%)           7   (4.1%)     ActiveSupport::Inflector#demodulize

I test this patch and got a 10% performance boost. https://gist.github.com/alexesDev/343e22b45fac02fd7f509bb408874f66

Are indents really needed?

alexesDev avatar May 22 '19 20:05 alexesDev

@alexesDev nice catch, imo it can be removed in order to get better performance, @activeadmin/collaborators what do u think ?

Fivell avatar Jun 13 '19 12:06 Fivell

Yeah, nice catch! I think the pretty HTML output is a nice feature that might be appreciated by some people, so it'd be nice to find a middle ground. Maybe make the "pretty html" an opt-out feature through configuration?

deivid-rodriguez avatar Jun 14 '19 08:06 deivid-rodriguez

I would accept a PR for this if you’re still interested in the change. Thank you.

javierjulio avatar Mar 14 '23 03:03 javierjulio