#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw( gettimeofday);  #since timing things

use threads;    #we need the libraries

sub f { #just count 10,000,000 numbers
    my $s = 0;
    while ($s < 10000000){ #count first 10 million numbers
        $s++;
    }
}

my $start1 = gettimeofday();    #when did we 
f();
print "non threaded " , gettimeofday() - $start1 , "\n";


$start1 = gettimeofday();    #when did we start the thread
my $x = threads->create(\&f); #start a threaded version
$x->join();
print "threaded " , gettimeofday() - $start1 , "\n";

$start1 = gettimeofday();    #when did we start the threads
$x = threads->create(\&f); #start a threaded version
my $y = threads->create(\&f);
my $z = threads->create(\&f);
$x->join();
$y->join();
$z->join();
print "three threads  " , gettimeofday() - $start1 , "\n";
