# Inserting One New Element into Hashes of Varying Sizes

DevFeed: [Inserting One New Element into Hashes of Varying Sizes](<https://devfeed.tech/articles/inserting-one-new-element-into-hashes-of-varying-sizes-31812.md>)

Original publisher: [Read original article](<https://patshaughnessy.net/2025/2/4/inserting-one-new-element-into-hashes-of-varying-sizes>)

Author: Pat Shaughnessy

Published: 2025-02-04T00:00:00Z

Content type: tutorial

Language: en

Sources: [Pat Shaughnessy](<https://devfeed.tech/sources/pat-shaughnessy.md>)

Topics: [Ruby](<https://devfeed.tech/topics/ruby.md>), [hash](<https://devfeed.tech/topics/hash.md>), [Benchmark](<https://devfeed.tech/topics/benchmark.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [benchmark](<https://devfeed.tech/tags/benchmark.md>), [hash](<https://devfeed.tech/tags/hash.md>), [internals](<https://devfeed.tech/tags/internals.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [table](<https://devfeed.tech/tags/table.md>), [updating-ruby-under-a-microscope](<https://devfeed.tech/tags/updating-ruby-under-a-microscope.md>)

## AI overview

This article presents a Ruby experiment measuring the time required to insert one new element into hashes of different sizes. Using Ruby 3.4.1, it observes timing spikes when the hash grows to certain sizes, consistent with rehashing or redistribution.

## Source excerpt

I've started working on a new edition of Ruby Under a Microscope that covers Ruby 3.x. I'm working on this in my spare time, so it will take a while. Leave a comment or drop me a line and I'll email you when it's finished. RUM includes a serie