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