summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominic Dunlop <domo@slipper.ip.lu>1997-03-25 15:39:26 +0100
committerChip Salzenberg <chip@atlantic.net>1997-03-22 15:34:25 +1200
commitd26eb0becc8c51ffd352f1667ada71b0e03e9b19 (patch)
tree7fbf93d37530b1cf59ca0eb151cf339f28368ba3
parentd0d9edbfefaa66459eb57c5d4857a3ae7e77cc0f (diff)
downloadperl-d26eb0becc8c51ffd352f1667ada71b0e03e9b19.tar.gz
Reduce memory footprint of complex.t
Over the weekend, I said: >Passes all expected tests on MachTen 4.0.3, EXCEPT... > >lib/complex fails to run because it wants more virtual memory than my >system can provide. My system can provide 22 megs, which is not vast, but >should be adequate to run a test, so I think lib/complex is being greedy. >I'm pretty sure that the cause is repeated use of .= or similar on a >scalar: the system malloc() which perl has to use on MachTen does not >appear to coalesce free()d chunks, so behaves very badly when a scalar >grows repeatedly. Anyway, I'll delve deeper and probably post a patch. Here's that patch. It saves 2,861 (give or take) of those realloc()s my system's native malloc() package fields so badly. Beware long lines. Hope they reach you unmangled. (If not, ask me to send it uuencoded, or as a MIME attachment or something.) You'll also need to hand patch a --ignore-whitespace option: tabs will have been munged into spaces. p5p-msgid: v03020902af5d8e03c5ab@[194.51.248.84]
-rwxr-xr-xt/lib/complex.t17
1 files changed, 9 insertions, 8 deletions
diff --git a/t/lib/complex.t b/t/lib/complex.t
index 5dcac6c6ce..f58bb499bc 100755
--- a/t/lib/complex.t
+++ b/t/lib/complex.t
@@ -5,6 +5,7 @@
# Regression tests for the new Math::Complex pacakge
# -- Raphael Manfredi, Septemeber 1996
# -- Jarkko Hietaniemi Manfredi, March 1997
+# -- Dominic Dunlop, March 1997 (reduce virtual memory requirement only)
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
@@ -13,7 +14,7 @@ use Math::Complex;
$test = 0;
$| = 1;
-$script = '';
+@script = ();
my $eps = 1e-4; # for example root() is quite bad
while (<DATA>) {
@@ -48,7 +49,7 @@ while (<DATA>) {
}
print "1..$test\n";
-eval $script;
+eval join '', @script;
die $@ if $@;
sub test {
@@ -57,13 +58,13 @@ sub test {
my $i;
for ($i = 0; $i < @args; $i++) {
$val = value($args[$i]);
- $script .= "\$z$i = $val;\n";
+ push @script, "\$z$i = $val;\n";
}
if (defined $z) {
$args = "'$op'"; # Really the value
$try = "abs(\$z0 - \$z1) <= $eps ? \$z1 : \$z0";
- $script .= "\$res = $try; ";
- $script .= "check($test, $args[0], \$res, \$z$#args, $args);\n";
+ push @script, "\$res = $try; ";
+ push @script, "check($test, $args[0], \$res, \$z$#args, $args);\n";
} else {
my ($try, $args);
if (@args == 2) {
@@ -73,8 +74,8 @@ sub test {
$try = ($op =~ /^\w/) ? "$op(\$z0, \$z1)" : "\$z0 $op \$z1";
$args = "'$args[0]', '$args[1]'";
}
- $script .= "\$res = $try; ";
- $script .= "check($test, '$try', \$res, \$z$#args, $args);\n";
+ push @script, "\$res = $try; ";
+ push @script, "check($test, '$try', \$res, \$z$#args, $args);\n";
}
}
@@ -88,7 +89,7 @@ sub set {
for ($i = 0; $i < @set; $i++) {
push(@{$valref}, $set[$i]);
my $val = value($set[$i]);
- $script .= "\$s$i = $val;\n";
+ push @script, "\$s$i = $val;\n";
push(@{$setref}, "\$s$i");
}
}