in reply to Re^7: Benchmarking "Are all these characters in this sentence?" (Are you bored yet? :)
in thread Benchmarking "Are all these characters in this sentence?"

The benchmarks run whether the code is right or not.

To see the tests run, pass a -t argument:

$ perl timeSentenceChars.pl -t
... other tests ....
Testing buk4
not ok 77
#   Failed test in timeSentenceChars.pl at line 103.
Use of uninitialized value in numeric eq (==) at timeSentenceChars.pl line 103.
not ok 78
#   Failed test in timeSentenceChars.pl at line 103.
Use of uninitialized value in numeric eq (==) at timeSentenceChars.pl line 103.
not ok 79
#   Failed test in timeSentenceChars.pl at line 103.
Use of uninitialized value in numeric eq (==) at timeSentenceChars.pl line 103.
ok 80
ok 81
Use of uninitialized value in numeric eq (==) at timeSentenceChars.pl line 103.
not ok 82
#   Failed test in timeSentenceChars.pl at line 103.
Use of uninitialized value in numeric eq (==) at timeSentenceChars.pl line 103.
not ok 83
#   Failed test in timeSentenceChars.pl at line 103.
Use of uninitialized value in numeric eq (==) at timeSentenceChars.pl line 103.
ok 84
Use of uninitialized value in numeric eq (==) at timeSentenceChars.pl line 103.
not ok 85
#   Failed test in timeSentenceChars.pl at line 103.
ok 86
Use of uninitialized value in numeric eq (==) at timeSentenceChars.pl line 103.
not ok 87
#   Failed test in timeSentenceChars.pl at line 103.
Use of uninitialized value in numeric eq (==) at timeSentenceChars.pl line 103.
ok 88
ok 89
Use of uninitialized value in numeric eq (==) at timeSentenceChars.pl line 103.
not ok 90
#   Failed test in timeSentenceChars.pl at line 103.
Use of uninitialized value in numeric eq (==) at timeSentenceChars.pl line 103.
not ok 91
#   Failed test in timeSentenceChars.pl at line 103.
Use of uninitialized value in numeric eq (==) at timeSentenceChars.pl line 103.
ok 92
Use of uninitialized value in numeric eq (==) at timeSentenceChars.pl line 103.
not ok 93
#   Failed test in timeSentenceChars.pl at line 103.
Use of uninitialized value in numeric eq (==) at timeSentenceChars.pl line 103.
ok 94
Use of uninitialized value in numeric eq (==) at timeSentenceChars.pl line 103.
not ok 95
#   Failed test in timeSentenceChars.pl at line 103.


Mike
  • Comment on Re^8: Benchmarking "Are all these characters in this sentence?" (Are you bored yet? :)

Replies are listed 'Best First'.
Re^9: Benchmarking "Are all these characters in this sentence?" (Broken tests, not code!)
by BrowserUk (Patriarch) on Sep 02, 2008 at 02:13 UTC

    Actually, it's your tests that are broken. They assume that the routines will return "0" for false, where as my routines (all of them including buk3 which you said passes all the tests), return undef. And that is where the Use of uninitialized value in numeric eq (==) ... warning message is coming from. Your tests (or test tools) not my code.

    The received wisdom is that subs should just return; to indicate false as this will do the right thing when called in both scalar and list contexts.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Fixed with a !!, thanks.

      No, that didn't do it. I'm getting undef where a true return is expected...

      Ah, I see. You had -1 ==, I think you meant -1 !=...

      buk4 => sub { ( -1 != index $_[0], chop $_[ 1 ] ) || return for 1 .. length +$_[ 1 ]; 1; },
      Once I made that change, it passes all the tests (which are now updated to check truth values) and it does win the speed crown by a 1% (on Short) to 11% (on LongLong) margin over buk3 (on perl 5.8.4 - I don't have my mac handy).

      Mike
Re^9: Benchmarking "Are all these characters in this sentence?" (Are you bored yet? :)
by BrowserUk (Patriarch) on Sep 02, 2008 at 01:57 UTC