Thomas Leitner

@gettalong.bsky.social

(Open source) Software developer, creator of kramdown and HexaPDF, Sci-Fi fan.

Time for another Vienna Ruby Meetup! 🎉 It's been three months since the last meetup. To make up for it, we got three wonderful talks covering a wide range of topics this time. Thank you to Meister for hosting us!

Bild

So, I now have implemented a basic template system for VersaDok. However, using ERB as preprocessor instead of the built-in template system is faster in most cases (even though the larger source doc needs to be parsed every time) because AST nodes need to be rendered many times more.

So I have been working on something lately, lightweight markup related. Turns out it's at least 4 times faster than kramdown when parsing the same document (n.b. a bit of an apple to banana comparison as kramdown can do much more at the moment but still 🤯)

Without YJIT on Ruby 3.4.1

Warming up --------------------------------------
            kramdown    259.422 i/s -     270.000 times in 1.040775s (3.85ms/i)
            versadok     1.158k i/s -      1.265k times in 1.091970s (863.22μs/i)
Calculating -------------------------------------
            kramdown    276.681 i/s -     778.000 times in 2.811901s (3.61ms/i)
            versadok     1.138k i/s -      3.475k times in 3.052762s (878.49μs/i)

Comparison:
            versadok:      1138.3 i/s
            kramdown:       276.7 i/s - 4.11x  slower

With YJIT on Ruby 3.4.1

Warming up --------------------------------------
            kramdown    334.871 i/s -     336.000 times in 1.003372s (2.99ms/i)
            versadok     1.853k i/s -      1.969k times in 1.062396s (539.56μs/i)
Calculating -------------------------------------
            kramdown    315.374 i/s -      1.004k times in 3.183520s (3.17ms/i)
            versadok     1.822k i/s -      5.560k times in 3.052272s (548.97μs/i)

Comparison:
            versadok:      1821.6 i/s
            kramdown:       315.4 i/s - 5.78x  slower

So, Ruby friends, how do I remove count number of trailing elements from an array *without* creating a new result array? There is Array#pop(count) but that creates an array I don't need or want ;-)