# Benchmarks Are Free Now

DevFeed: [Benchmarks Are Free Now](<https://devfeed.tech/articles/benchmarks-are-free-now-20533.md>)

Original publisher: [Read original article](<https://code.dblock.org/2026/08/15/benchmarks-are-free-now.html>)

Author: Daniel Doubrovkine (dblock@dblock.org)

Published: 2026-08-15T00:00:00Z

Content type: opinion

Language: en

Sources: [Daniel Doubrovkine](<https://devfeed.tech/sources/daniel-doubrovkine.md>)

Topics: [Benchmark](<https://devfeed.tech/topics/benchmark.md>), [subclass](<https://devfeed.tech/topics/subclass.md>), [superclass](<https://devfeed.tech/topics/superclass.md>), [Tool](<https://devfeed.tech/topics/tool.md>), [GitHub Copilot Profiler Agent](<https://devfeed.tech/topics/github-copilot-profiler-agent.md>)

Tags: [agent](<https://devfeed.tech/tags/agent.md>), [ai](<https://devfeed.tech/tags/ai.md>), [benchmarks](<https://devfeed.tech/tags/benchmarks.md>), [caching](<https://devfeed.tech/tags/caching.md>), [class](<https://devfeed.tech/tags/class.md>), [copilot](<https://devfeed.tech/tags/copilot.md>), [cost](<https://devfeed.tech/tags/cost.md>), [dispatch](<https://devfeed.tech/tags/dispatch.md>), [exhaustive](<https://devfeed.tech/tags/exhaustive.md>), [fast](<https://devfeed.tech/tags/fast.md>), [free](<https://devfeed.tech/tags/free.md>), [hash](<https://devfeed.tech/tags/hash.md>), [inheritance](<https://devfeed.tech/tags/inheritance.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [performance](<https://devfeed.tech/tags/performance.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [script](<https://devfeed.tech/tags/script.md>), [speed](<https://devfeed.tech/tags/speed.md>), [subclass](<https://devfeed.tech/tags/subclass.md>), [test](<https://devfeed.tech/tags/test.md>), [tests](<https://devfeed.tech/tags/tests.md>), [time](<https://devfeed.tech/tags/time.md>)

## AI overview

A benchmark generated with Copilot CLI exposed a performance regression in ruby-enum's inheritance fix: subclass lookups repeatedly rebuilt merged enum hashes, making a one-level subclass's calls roughly 5x slower than base-class calls, with deeper inheritance slower still. Tests had caught no issue because they checked correctness, not speed. The author says fix #60 memoized the merged hash and invalidated the cache when a new entry was added; afterward, subclass lookups were indistinguishable from base-class lookups regardless of depth. Further benchmarks found constant access as fast as plain Ruby, hash-backed lookups about 3-5x slower than direct calls, and the exhaustive matcher 50-100x slower than a native statement. The excerpt says these measurements were added to the README's Performance section.

## Source excerpt

My previous post walked through four bugs in ruby-enum, a gem I maintain, all stemming from the fact that class-level instance variables aren't inherited by subclasses. The third fix, #59, made keys, key?, value?, key, value, to_h, parse and each walk up superclass and merge in a parent's enums, so a subclass would see everything its ancestors defined. It was correct, fully tested, and shipped. It also made every one of those methods roughly 5x slower on any subclass. def _enum_hash if superclass < Ruby::Enum superclass.send(:_enum_hash).merge(_own_enum_hash) else _own_enum_hash end end This recomputes the merged hash, walking the entire ancestor chain, on every single call. There's no caching. A one-level subclass calling .value pays for building a brand new hash, on top of the superclass doing the same, every time. The test suite didn't notice because tests check correctness, not speed, and correctness was fine. I only found this because I asked Copilot CLI to add a benchmark script comparing lookups at different inheritance depths, mostly out of curiosity about how the "Benchmarks" section of the README would read next to the new feature. It took one prompt and about a minute to get a working script: class Colors include Ruby::Enum define :RED, 'red' define :GREEN, 'green' end class SubColors < Colors define :BLUE, 'blue' end class SubSubColors < SubColors define :YELLOW, 'yellow' end benchmark('base class (no inheritance)', n) { Colors.value(:RED) } benchmark('subclass (1 level)', n) { SubColors.value(:RED) } benchmark('sub-subclass (2 levels)', n) { SubSubColors.value(:RED) } The first run told the story immediately: a 1-level subclass's .value calls took roughly 5x as long as the base class, and a 2-level subclass was worse still. Nobody had written this benchmark before merging #59 because writing a throwaway benchmark script used to feel like more ceremony than it was worth for a one-off performance check. Now it's a single sentence to an agent, and the scri