I did some RAM benchmarking by generating many small hashes and arrays and was irritated that the hashes only needed <30% more memory than the arrays holding the values.
Then I realized that all hashes were generated with the same 5 keys.
When I created the hashes with random keys of same length, the need for memory doubled.
\@ARGV: ["test", "-n_objs=3", "-n_attr=5", "-share_keys=0"] at d:/tmp/
+pm/bless_hash_overhead.pl line 21.
\%opt: { -n_attr => 5, -n_objs => 3, -share_keys => 0 } at d:/tmp/pm/b
+less_hash_overhead.pl line 22.
\@types: ["test"] at d:/tmp/pm/bless_hash_overhead.pl line 23.
Running Test Demo at d:/tmp/pm/bless_hash_overhead.pl line 53.
Id : 14940
PM : 2945024
WS : 7933952
*** hash ***
[
{
"_0_852324.26186940" => 1,
"_1_164918.79415432" => 1,
"_2_708618.00181786" => 1,
"_3_693984.59335475" => 1,
"_4_318308.30209681" => 1,
"_5_354558.95958874" => 1,
"id" => 1,
},
{
"_0_941653.32000406" => 2,
"_1_026454.70369051" => 2,
"_2_708950.10790847" => 2,
"_3_858794.53324083" => 2,
"_4_112273.33593869" => 2,
"_5_135182.85796952" => 2,
"id" => 2,
},
{
"_0_926854.36297414" => 3,
"_1_445275.68350328" => 3,
"_2_111781.50175010" => 3,
"_3_326689.53909899" => 3,
"_4_069944.31695859" => 3,
"_5_650963.32051237" => 3,
"id" => 3,
},
] at d:/tmp/pm/bless_hash_overhead.pl line 56.
C:/Perl_524/bin\perl.exe -w d:/tmp/pm/bless_hash_overhead.pl test -n_o
+bjs=3 -n_attr=5 -share_keys=1
\@ARGV: ["test", "-n_objs=3", "-n_attr=5", "-share_keys=1"] at d:/tmp/
+pm/bless_hash_overhead.pl line 21.
\%opt: { -n_attr => 5, -n_objs => 3, -share_keys => 1 } at d:/tmp/pm/b
+less_hash_overhead.pl line 22.
\@types: ["test"] at d:/tmp/pm/bless_hash_overhead.pl line 23.
Running Test Demo at d:/tmp/pm/bless_hash_overhead.pl line 53.
Id : 14752
PM : 2924544
WS : 7909376
*** hash ***
[
{
_0_xxxxxxxxxxxxxxx => 1,
_1_xxxxxxxxxxxxxxx => 1,
_2_xxxxxxxxxxxxxxx => 1,
_3_xxxxxxxxxxxxxxx => 1,
_4_xxxxxxxxxxxxxxx => 1,
_5_xxxxxxxxxxxxxxx => 1,
id => 1,
},
{
_0_xxxxxxxxxxxxxxx => 2,
_1_xxxxxxxxxxxxxxx => 2,
_2_xxxxxxxxxxxxxxx => 2,
_3_xxxxxxxxxxxxxxx => 2,
_4_xxxxxxxxxxxxxxx => 2,
_5_xxxxxxxxxxxxxxx => 2,
id => 2,
},
{
_0_xxxxxxxxxxxxxxx => 3,
_1_xxxxxxxxxxxxxxx => 3,
_2_xxxxxxxxxxxxxxx => 3,
_3_xxxxxxxxxxxxxxx => 3,
_4_xxxxxxxxxxxxxxx => 3,
_5_xxxxxxxxxxxxxxx => 3,
id => 3,
},
] at d:/tmp/pm/bless_hash_overhead.pl line 56.