RubyFlow The Ruby and Rails community linklog


The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Micro benchmarking value objects in Ruby: Data.define vs Struct vs OpenStruct

I did a series of benchmarks between Data class, Struct, and OpenStruct testing, creating new objects and accessing attributes. The tests consider keyword arguments and not positional arguments.

TL;DR - When creating a new object Struct and Data.define have the same performance. OpenStruct is very slow compared with them. The same is true for accessing attributes.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in