Perl && vs. and – || vs. or Benchmark

I want to compare the && vs. the and operator, and the || vs. or operator in Perl:

 

First result (1 && 0) vs. (1 and 0):

Second result (1 or 0) vs. (1 || 0):

Third result (1 && 1) vs. (1 and 1):

Fourth result (1 or 1) vs. (1 || 1):

It seems the “and” and “&&” don’t make really different, but the “or” and “||” operator seems different.I don’t know why the “||” are 18-48% faster than the “or” …. and the “and” is only about 1-3% faster.

 

Now we check if they work as they should:

result looks good they abort if a true is impossible:

That is more a check up and not really a Benchmark.

5 thoughts on “Perl && vs. and – || vs. or Benchmark”

Leave a Reply

Your email address will not be published.

four − one =