Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use an Array instead of a Hash #390

Open
3 tasks
azumakuniyuki opened this issue Apr 17, 2020 · 0 comments
Open
3 tasks

Use an Array instead of a Hash #390

azumakuniyuki opened this issue Apr 17, 2020 · 0 comments
Labels
improvement speed-up Performance Tuning

Comments

@azumakuniyuki
Copy link
Member

azumakuniyuki commented Apr 17, 2020

An array is faster and smaller than a hash table.

Running with Perl v5.30.0 on darwin
--------------------------------------------------------------------------------
                  Rate $Hash->{...} $List->[...]
$Hash->{...} 6818182/s           --         -31%
$List->[...] 9836066/s          44%           --

$Hash->{...}    446 bytes
$List->[...]    226 bytes

Benchmarked by https://github.com/azumakuniyuki/make-perl-code-faster/blob/master/t/list-vs-hash.t

A Hash table exists which has a few keys in the following methods:

  • Sisimai::Address->find (%$emailtable)
  • Sisimai::DateTime->parse (%$v)
  • Sisimai::DateTime->tz2second (%$digit)
@azumakuniyuki azumakuniyuki added the speed-up Performance Tuning label May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement speed-up Performance Tuning
Projects
None yet
Development

No branches or pull requests

1 participant