Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-26 Thread JupiterHost.Net
renard wrote: BE AWARE THAT THE BENCHMARK PROVIDES INCORRECT RESULTS. Thnaks, I was aware of that, but still wanted a general idea :) The tested code is within an anonymous subroutine while this does executes, the results differ dramitcally from the results when the tested code is enclosed withi

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-26 Thread JupiterHost.Net
The slice version took about 10 seconds, the grep one took more than 1 minute. Marcello Thanks Marcello! Your example, John's. and renards have been very helpful to help see the point someone else was trying to make about watching what you include in your benchmark. I appreciate your time :)

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-26 Thread Marcello
JupiterHost.Net ha scritto: In benchmarking some code I've come across something I did not expect: slice: use strict; use warnings; my @k=qw(1 2 3 4 5 6); my %n;@[EMAIL PROTECTED] = @k; print "hi" if exists $n{1}; print "hi" if exists $n{3}; print "hi" if exists $n{5}; print "hi" if exists $n{7}; p

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread JupiterHost.Net
> Lawrence Statton wrote: [snip] Gotcha, thx So then can you suggest a method of benchmarking these 2 methods that would be more accurate? I believe John's solution was excellent at illustrating th deficiencies in the way I was doing it and supplying a solution and answering my question all at

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread JupiterHost.Net
#!/usr/bin/perl use warnings; use strict; use Benchmark 'cmpthese'; my @k = qw( 1 2 3 4 5 6 ); cmpthese( -10, { exists => sub { my $count = 0; my %hash; @hash{ @k } = (); for my $num ( 1, 3, 5, 7, 9, 11 ) { $count++ if exists $hash{ $num };

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread John W. Krahn
JupiterHost.Net wrote: In benchmarking some code I've come across something I did not expect: slice: use strict; use warnings; my @k=qw(1 2 3 4 5 6); my %n;@[EMAIL PROTECTED] = @k; print "hi" if exists $n{1}; print "hi" if exists $n{3}; print "hi" if exists $n{5}; print "hi" if exists $n{7}; print

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread Lawrence Statton
> Thanks for your input :) No problem -- I really do enjoy this. However, I do have some actual WORK that I need to do today :( > > Finally, there were serious errors in your methodology in your > > Serious? I thought "in the Big Picture, it won't matter a gnats eyebrow." :) And I stand by t

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread JupiterHost.Net
Thanks for your input :) Finally, there were serious errors in your methodology in your Serious? I thought "in the Big Picture, it won't matter a gnats eyebrow." :) original benchmark. It turns out the printing dominated the total That is why I made both identical except for the difference I'm co

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread JupiterHost.Net
Bakken, Luke wrote: You have to stop spending so much time playing with all this bogus benchmarking :) It not bogus :) Its an example to find the best method for a project. If you prefer I'll ask the question I was trying to answer with the benchmark: Assuming you have an array of 0-15 elements

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread JupiterHost.Net
print "hi" if $n{11}; What if it's value is 0, '', or undef? It would exist but your test would miss it :) In that case "defined" would be a beter function to use. ok, but I'm still not interested in the value of the key I;'m interested inthe key, so why not exists since its made for hashes :)

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread Lawrence Statton
> > You have to stop spending so much time playing with all this bogus > > benchmarking :) > > It not bogus :) Its an example to find the best method for a project. > And I'll reiterate more clearly. Benchmarking is *not* the tool to find the best method. The BEST method for a project is that

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread mgoland
- Original Message - From: "JupiterHost.Net" <[EMAIL PROTECTED]> Date: Tuesday, January 25, 2005 11:37 am Subject: Re: hash slice/exists vs. grep benchmark weirdness... > > > > > Just as an FYI, you don't need "exists" in your code at all.

RE: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread Bakken, Luke
> > You have to stop spending so much time playing with all this bogus > > benchmarking :) > > It not bogus :) Its an example to find the best method for a project. > > If you prefer I'll ask the question I was trying to answer with the > benchmark: > > Assuming you have an array of 0-15 elemen

RE: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread Thomas Bätzler
[EMAIL PROTECTED] suggested: > Just as an FYI, you don't need "exists" in your code at all. > It is just a waste of time in your example. Should be beter writen as: > > print "hi" if $n{11}; Bad idea, if you consider this: $n{'oops'} = 0; print "hi" if $n{'oops'}; print "ho" if exists $n{'oop

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread JupiterHost.Net
Just as an FYI, you don't need "exists" in your code at all. It is just a waste of time in your example. Should be beter writen as: print "hi" if $n{11}; What if it's value is 0, '', or undef? It would exist but your test would miss it :) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additio

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread mgoland
- Original Message - From: "JupiterHost.Net" <[EMAIL PROTECTED]> Date: Tuesday, January 25, 2005 11:01 am Subject: Re: hash slice/exists vs. grep benchmark weirdness... > > You have to stop spending so much time playing with all this bogus > > benchmarking :)

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-25 Thread JupiterHost.Net
You have to stop spending so much time playing with all this bogus benchmarking :) It not bogus :) Its an example to find the best method for a project. If you prefer I'll ask the question I was trying to answer with the benchmark: Assuming you have an array of 0-15 elements is it quicker/more ef

Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-24 Thread Lawrence Statton
> In benchmarking some code I've come across something I did not expect: > You have to stop spending so much time playing with all this bogus benchmarking :) > slice: > use strict; > use warnings; > my @k=qw(1 2 3 4 5 6); > my %n;@[EMAIL PROTECTED] = @k; > print "hi" if exists $n{1}; > print "h