#!/usr/bin/env perl
# Copyright (c) 2015 Christian Jaeger, copying@christianjaeger.ch
# This is free software. See the file COPYING.md that came bundled
# with this file.
# This file checks whether passing global functions as *foo instead of
# \&foo incurs (much) overhead.
use
strict;
use
warnings;
# Find modules from the functional-perl working directory (not
# installed)
our
(
$mydir
,
$myname
);
BEGIN {
my
$location
= (-l $0) ? abs_path($0) : $0;
$location
=~ /(.*?)([^\/]+?)_?\z/s or
die
"?"
;
(
$mydir
,
$myname
) = ($1, $2);
}
# for development/debugging
#use Chj::ruse; # get the 'ruse' procedure which will reload modules;
# since we're putting the meat of the program into the
# main file, this won't help us here.
use
Chj::TEST;
# ------------------------------------------------------------------
use
Chj::time_this;
our
$n
= 1500000;
sub
t {
my
(
$f
) =
@_
;
my
$z
= 0;
for
(1 ..
$n
) {
$z
=
&$f
(
$z
)
}
$z
}
sub
tim {
time_this { t
*inc
}
" *"
;
time_this { t \
&inc
}
"\\&"
;
}
tim
for
1 .. 3;
#perhaps_run_tests "main" or repl;