Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Just to clarify Pustular Postulant, the OP must have called the functions in a void or scalar context. sort is optimized to do nothing in that situation, so the functions naive and orcish return instantly. Read more for confirmation of Pustular Postulant's results and confirmation that running the sorts in scalar context give results similar to those of the OP.

my @unsorted = sort map { "foo$_.tla" } 0..999; Benchmark::cmpthese(5000, { naive => sub { my @a = naive @unsorted; }, orcish => sub { my @a = orcish @unsorted; }, schwartzian => sub { my @a = schwartzian @unsorted; }, guttros => sub { my @a = guttros @unsorted; }, });

gives me

Rate naive orcish schwartzian guttros naive 48.3/s -- -34% -46% -60% orcish 73.1/s 51% -- -19% -40% schwartzian 90.1/s 86% 23% -- -26% guttros 122/s 152% 67% 35% --


my @unsorted = sort map { "foo$_.tla" } 0..999; Benchmark::cmpthese(5000, { naive => sub { scalar naive @unsorted; }, orcish => sub { scalar orcish @unsorted; }, schwartzian => sub { scalar schwartzian @unsorted; }, guttros => sub { scalar guttros @unsorted; }, });

gives me

(warning: too few iterations for a reliable count) (warning: too few iterations for a reliable count) Rate schwartzian guttros orcish naive schwartzian 107/s -- -26% -100% -100% guttros 144/s 35% -- -100% -100% orcish 106383/s 99666% 73834% -- -0% naive 106383/s 99666% 73834% 0% --

That's why it's important to show one's work :)

In reply to Re^2: Choosing the right sort (Or: WUDsamatter?) by ikegami
in thread Choosing the right sort (Or: WUDsamatter?) by friedo

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [Discipulus]: so every library (js) to sdelect and modify the id parameters can be good.
    [Discipulus]: I never understood something: I can on the fly modify the XML structure of the SVG using for example XML::Twig ?
    [Corion]: Discipulus: If you want to rewrite the SVG, then yes, something like XML::Twig should be enough. I would try to not modify the SVG but only modify the display, but so far I haven't convinced IE to change the style...
    Corion gives up
    [Discipulus]: ah! so you mean if i need a static image i can use Twig, if on the fly better css selector and mody attrs (jquery?), rigth?
    [LanX]: not sure what you guys are taking about, but a DOM manipulation in JS shouldn't be difficult
    [Corion]: Discipulus: Yeah, that's what I would try (but so far, I can't even change the colors manually in the SVG, which is why I gave up ;) )
    Discipulus bad sign..

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (13)
    As of 2017-03-23 09:42 GMT
    Find Nodes?
      Voting Booth?
      Should Pluto Get Its Planethood Back?

      Results (285 votes). Check out past polls.