u/RodionGork

Performance discrepancy between versions 2.7.4 and 4.0.6
▲ 10 r/ruby

Performance discrepancy between versions 2.7.4 and 4.0.6

Recently decided to try learning Ruby more consistently (before that I only touched it occasionally) - and was much pleased with it in various aspects. At some point I was curious to assess its general performance roughly (as I heard it had to be pretty slow but very long in the past). Then I found my system installed Ruby is somewhat outdated 2.7.4p191 (along with my ubuntu 18.04 on this specific laptop). So I learnt to deploy rbenv and installed 4.0.6 with it.

However I ran into small puzzling situation - I tried two small scripts - roughly doing double nested loop - one with simple arithmetic and another with building and using array (collatz sequence calculations and primes calculation by trial division) - and while for the first of them performance of the said two versions is roughly the same, with the other newer version looks a bit slower.

I'm pretty sure I missed something about versions installed or don't catch something about properly writing Ruby code - so any guidance is quite welcome!

Below come details (with this primes.rb script from my github):

$ rbenv local 4.0.6 
$ ruby --version
ruby 4.0.6 (2026-07-14 revision 03b6d3f889) +PRISM [x86_64-linux]

$ time MAXN=1000000 ruby primes.rb
primes[1000000] = 15485863

real0m41,003s
user0m40,985s
sys0m0,018s

$ rbenv local --unset
$ ruby --version
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux]

$ time MAXN=1000000 ruby primes.rb
primes[1000000] = 15485863

real0m34,969s
user0m34,929s
sys0m0,042s

So you see, it looks like 2.7.4 behaves slightly (about 25%) faster in this case, while I remember (from googling) that there was effort to make Ruby 3.x faster than Ruby 2.x perhaps 3 times. Though I may misinterpret this and perhaps 2.7.4. got the same improvements as 3.x (compared to 2.0 etc)

u/RodionGork — 6 days ago

Trup jest rzeczownikiem "żywotnym" lub "ożywionym"?

Rozumiem że to jest tylko gramatyczny podział, chociaż niespodzianka. Biernik "ożywionych" priedmiotów ma inną końcówkę: "ukrywam trupa w szafie" (nie "trup", tak?)

reddit.com
u/RodionGork — 1 month ago

To mój klejnot

(znalazłem starą książkę w szafie)

-- ...bom ci nazwiska swego nie powiedział. (dlaczego nie "powiedziałem"?)

-- więc waść nie jest Abdank?

-- to mój klejnot

Google tlumaczy to jak "cenny kamień" ale myślę że chodzi o czymś jak "ród" czy "herb"?

Też, co to jest "abdank"? Jakiś kamień czy przedmiot? Czy "nazwa własna"?

upd: bardzo dziękuję za wyjaśnienie, szczególnie o "ruchomości końcówek"!

reddit.com
u/RodionGork — 1 month ago

Psica (?)

Próbowałem wyjaśnić że muszę wyjść do spaceru z móją ... "dog" ale ona nie jest "psem" oczywiście.

upd: Bardzo dziękuję wszystkim za wyjaśnienia i przykłady. Słowo "psica" brzmi (dla mnie) troche jak "cerkiewno-słowiańske", więc użiłem go. Ale nie wiedziałem że "z psem" jest normalne kiedy "on/ona" nie ma znaczenia.

Dora

reddit.com
u/RodionGork — 1 month ago

Happy Birthday, America!

Expected to see here already a bunch of videos on occasion of 250th anniversary... Hm-m-m, well, let me try to amend this as well (as poor) as I can! Sorry for not exactly party look.

"This Land is Your Land" after Woody Guthrie, with some addition :)

u/RodionGork — 2 months ago

Trying new harp (Special 20 in A) and my dog joins

Today picked Special 20 in A from the post (before I only had Big River in A and felt I want something more bendy) - and as soon as I got into home, I gave it a try - completely missing the fact that Dora the Dog will immediately join (the reason why I rarely try playing at home).

It probably is hardly recognizable - but I'm trying to play "Tout va tres bien, Madame la Marquise" - comic French song from 1930s.

u/RodionGork — 2 months ago

Guess these tune(s)

We can have a kind of naive fun by making small posts of us playing (trying to play) some recognizable (supposedly) tunes - for others to guess. Surely open to hints and criticism. But anyway if the tune could be guessed, probably it is at least not hopeless :) Here is my meek attempt.

u/RodionGork — 3 months ago