#!/usr/bin/perl use strict; use warnings; use Junction qw/ xall xany /; use Quantum::Superpositions qw/ all any /; use Benchmark ':all'; print "all: numeric (few)\n"; cmpthese(30_000,{ Junction => sub { 1 if xall(1..5) == 2; }, 'Quantum-Superpositions' => sub { 1 if all(1..5) == 2; }, }); print "\nall: numeric (lots)\n"; cmpthese(30_000,{ Junction => sub { 1 if xall(1..300) == 250; }, 'Quantum-Superpositions' => sub { 1 if all(1..300) == 250; }, }); print "\nall: string\n"; cmpthese(10_000,{ Junction => sub { 1 if xall('a'..'z') eq 'z'; }, 'Quantum-Superpositions' => sub { 1 if all('a'..'z') eq 'z'; }, }); print "\nany: numeric (few)\n"; cmpthese(30_000,{ Junction => sub { 1 if xany(1..5) == 2; }, 'Quantum-Superpositions' => sub { 1 if any(1..5) == 2; }, }); print "\nany: numeric (lots)\n"; cmpthese(2_000,{ Junction => sub { 1 if xany(1..300) == 250; }, 'Quantum-Superpositions' => sub { 1 if any(1..300) == 250; }, }); print "\nany: string\n"; cmpthese(7_000,{ Junction => sub { 1 if xany('a'..'z') eq 'z'; }, 'Quantum-Superpositions' => sub { 1 if any('a'..'z') eq 'z'; }, });