Is there any performance overhead that you take on when using Structs (as compared to Arrays, Hashes, etc.) in Ruby?
Is there any performance overhead that you take on when using Structs (as compared
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I tried running the following several times (following Jörg’s comment this has been updated to use a fixed variable for the value instead of creating lots of strings):
Update
It seems with a large enough value of
nthe Struct is slightly slower but I can’t imagine this would be noticeable or an issue in practice.