For benchmarking 50,000 messages the following two scripts were made, based on the one found here.
$ diff hobo_test.pl threads_test.pl
5,6c5,6
< use MCE::Hobo;
< use Foo::Inbox2;
---
> use threads;
> use Foo::Inbox4;
11c11
< my $inbox = Foo::Inbox2->new( @names );
---
> my $inbox = Foo::Inbox4->new( @names );
38,39c38,39
< MCE::Hobo->create(\&foo, $_) for @names;
< MCE::Hobo->waitall;
---
> threads->create(\&foo, $_) for @names;
> $_->join() for threads->list();
Foo::Inbox2 via MCE::Hobo + MCE::Shared->queue 50k test
Foo::Inbox4 via threads + Thread::Queue 50k test
Update: Added results for MCE::Inbox which will ship with MCE::Shared 1.827 on release day. It is Inbox2 with optimizations.
Results from Mac OS X and Cent OS 7.
# Mac OS X ( Perl v5.18.2 )
$ perl foo1.pl | wc -l # Foo::Inbox
duration: 0.690 seconds
50000
$ perl inbox.pl | wc -l # MCE::Inbox w/ blocking capability
duration: 0.721 seconds
50000
$ perl foo2.pl | wc -l # MCE::Shared->queue
duration: 0.789 seconds
50000
$ perl foo4.pl | wc -l # Thread::Queue
duration: 5.735 seconds
50000
# CentOS 7 VM ( Perl v5.16.3 )
$ perl foo1.pl | wc -l # Foo::Inbox
duration: 0.834 seconds
50000
$ perl inbox.pl | wc -l # MCE::Inbox w/ blocking capability
duration: 0.726 seconds
50000
$ perl foo2.pl | wc -l # MCE::Shared->queue
duration: 0.945 seconds
50000
$ perl foo4.pl | wc -l # Thread::Queue
duration: 3.020 seconds
50000
Results from Cygwin and Strawberry Perl.
# Windows ( Cygwin Perl v5.22.3 )
$ perl foo1.pl | wc -l # Foo::Inbox
duration: 1.825 seconds
50000
$ perl inbox.pl | wc -l # MCE::Inbox w/ blocking capability
duration: 2.059 seconds
50000
$ perl foo2.pl | wc -l # MCE::Shared->queue
duration: 2.387 seconds
50000
$ perl foo4.pl | wc -l # Thread::Queue
duration: 24.086 seconds
50000
# Windows ( Strawberry Perl v5.22.2.1 )
$ perl foo1.pl > nul # Foo::Inbox
duration: 1.570 seconds
$ perl inbox.pl > nul # MCE::Inbox w/ blocking capability
duration: 1.664 seconds
$ perl foo2.pl > nul # MCE::Shared->queue
duration: 2.120 seconds
$ perl foo4.pl > nul # Thread::Queue
duration: 2.886 seconds
Results from FreeBSD and Solaris.
# TrueOS 10.0 ( FreeBSD, Perl 5.16.3 )
$ perl foo1.pl | wc -l # Foo::Inbox
duration: 0.910 seconds
50000
$ perl inbox.pl | wc -l # MCE::Inbox w/ blocking capability
duration: 0.875 seconds
50000
$ perl foo2.pl | wc -l # MCE::Shared->queue
duration: 1.107 seconds
50000
$ perl foo4.pl | wc -l # Thread::Queue
duration: 0.797 seconds
50000
# Solaris 11.2 ( Perl 5.22.2 )
$ perl foo1.pl | wc -l # Foo::Inbox
duration: 1.319 seconds
50000
$ perl inbox.pl | wc -l # MCE::Inbox w/ blocking capability
duration: 1.344 seconds
50000
$ perl foo2.pl | wc -l # MCE::Shared->queue
duration: 1.525 seconds
50000
$ perl foo4.pl | wc -l # Thread::Queue
duration: 1.822 seconds
50000
From this testing, Threads + Thread::Queue runs better on FreeBSD and Solaris compared to others.
Foo::Inbox lacks blocking capability, thus has lower latency. However, it may run much slower when the Inbox isn't busy.
Regards, Mario |