Skip Menu |

This queue is for tickets about the Hash-Path CPAN distribution.

Report information
The Basics
Id: 50024
Status: open
Priority: 0/
Queue: Hash-Path

People
Owner: Nobody in particular
Requestors: frioux [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Faster implementation without recursion
Hi! We actually did this same thing at work and then switched to your module because it's named and documented and whatnot. Eventually I looked at the source and I thought our impl was better as it has no recursion. Here's a benchmark of ours being faster as well as our impl. I'd appreciate it if you included it in your dist :-) #!perl use strict; use warnings; use Time::HiRes 'gettimeofday'; use Hash::Path; use feature ':5.10'; sub generate_giant_thing { my $items = shift; my $top_level_data_structure = {}; my $current = $top_level_data_structure; for (0..( $items - 1 )) { $current->{"f$_"} = {}; $current = $current->{"f$_"}; } $current->{"f$items"} = 1; return ($top_level_data_structure, [ map "f$_", (0..$items) ]); } my ($foo,$path) = generate_giant_thing(500); sub our_path { my $data_set = shift; my @hash_keys = @_; my $levels = scalar @hash_keys; my $return_value = $data_set->{$hash_keys[0]}; for (1..($levels - 1)) { $return_value = $return_value->{$hash_keys[$_]}; } return $return_value; } { my $before = gettimeofday; say our_path($foo, @{$path}); my $after = gettimeofday; warn 'Our Time: '.sprintf('%0.3f', $after - $before).' seconds'; } { my $before = gettimeofday; say Hash::Path->get($foo, @{$path}); my $after = gettimeofday; warn 'HP Time: '.sprintf('%0.3f', $after - $before).' seconds'; }
Subject: Re: [rt.cpan.org #50024] Faster implementation without recursion
Date: Sat, 26 Sep 2009 19:53:48 +0200
To: bug-Hash-Path [...] rt.cpan.org
From: Igor Sutton <igorsutton [...] me.com>
Done. Thanks for the suggestion. I already uploaded the version 0.02 to PAUSE. On Sep 25, 2009, at 10:20 PM, Frew Schmidt via RT wrote: Show quoted text
> Fri Sep 25 16:20:03 2009: Request 50024 was acted upon. > Transaction: Ticket created by frew > Queue: Hash-Path > Subject: Faster implementation without recursion > Broken in: (no value) > Severity: Normal > Owner: Nobody > Requestors: frioux@gmail.com > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=50024 > > > > Hi! We actually did this same thing at work and then switched to your > module because it's named and documented and whatnot. Eventually I > looked at the source and I thought our impl was better as it has no > recursion. Here's a benchmark of ours being faster as well as our > impl. > I'd appreciate it if you included it in your dist :-) > > #!perl > use strict; > use warnings; > use Time::HiRes 'gettimeofday'; > use Hash::Path; > use feature ':5.10'; > > sub generate_giant_thing { > my $items = shift; > my $top_level_data_structure = {}; > my $current = $top_level_data_structure; > for (0..( $items - 1 )) { > $current->{"f$_"} = {}; > $current = $current->{"f$_"}; > } > $current->{"f$items"} = 1; > return ($top_level_data_structure, [ map "f$_", (0..$items) ]); > } > my ($foo,$path) = generate_giant_thing(500); > > sub our_path { > my $data_set = shift; > my @hash_keys = @_; > my $levels = scalar @hash_keys; > my $return_value = $data_set->{$hash_keys[0]}; > for (1..($levels - 1)) { > $return_value = $return_value->{$hash_keys[$_]}; > } > return $return_value; > } > { > my $before = gettimeofday; > say our_path($foo, @{$path}); > my $after = gettimeofday; > warn 'Our Time: '.sprintf('%0.3f', $after - $before).' seconds'; > } > > { > my $before = gettimeofday; > say Hash::Path->get($foo, @{$path}); > my $after = gettimeofday; > warn 'HP Time: '.sprintf('%0.3f', $after - $before).' seconds'; > } > > >
-- Igor Sutton igorsutton@me.com
Download smime.p7s
application/pkcs7-signature 2.3k

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #50024] Faster implementation without recursion
Date: Sat, 26 Sep 2009 13:21:39 -0500
To: bug-Hash-Path [...] rt.cpan.org
From: fREW Schmidt <frioux [...] gmail.com>
Awesome! Thanks! On Sat, Sep 26, 2009 at 12:54 PM, Igor Sutton via RT < bug-Hash-Path@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=50024 > > > Done. Thanks for the suggestion. > > I already uploaded the version 0.02 to PAUSE. > > On Sep 25, 2009, at 10:20 PM, Frew Schmidt via RT wrote: >
> > Fri Sep 25 16:20:03 2009: Request 50024 was acted upon. > > Transaction: Ticket created by frew > > Queue: Hash-Path > > Subject: Faster implementation without recursion > > Broken in: (no value) > > Severity: Normal > > Owner: Nobody > > Requestors: frioux@gmail.com > > Status: new > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=50024 > > > > > > > Hi! We actually did this same thing at work and then switched to your > > module because it's named and documented and whatnot. Eventually I > > looked at the source and I thought our impl was better as it has no > > recursion. Here's a benchmark of ours being faster as well as our > > impl. > > I'd appreciate it if you included it in your dist :-) > > > > #!perl > > use strict; > > use warnings; > > use Time::HiRes 'gettimeofday'; > > use Hash::Path; > > use feature ':5.10'; > > > > sub generate_giant_thing { > > my $items = shift; > > my $top_level_data_structure = {}; > > my $current = $top_level_data_structure; > > for (0..( $items - 1 )) { > > $current->{"f$_"} = {}; > > $current = $current->{"f$_"}; > > } > > $current->{"f$items"} = 1; > > return ($top_level_data_structure, [ map "f$_", (0..$items) ]); > > } > > my ($foo,$path) = generate_giant_thing(500); > > > > sub our_path { > > my $data_set = shift; > > my @hash_keys = @_; > > my $levels = scalar @hash_keys; > > my $return_value = $data_set->{$hash_keys[0]}; > > for (1..($levels - 1)) { > > $return_value = $return_value->{$hash_keys[$_]}; > > } > > return $return_value; > > } > > { > > my $before = gettimeofday; > > say our_path($foo, @{$path}); > > my $after = gettimeofday; > > warn 'Our Time: '.sprintf('%0.3f', $after - $before).' seconds'; > > } > > > > { > > my $before = gettimeofday; > > say Hash::Path->get($foo, @{$path}); > > my $after = gettimeofday; > > warn 'HP Time: '.sprintf('%0.3f', $after - $before).' seconds'; > > } > > > > > >
> > -- > Igor Sutton > igorsutton@me.com > > > > > >
-- fREW Schmidt http://blog.afoolishmanifesto.com