summaryrefslogtreecommitdiff
path: root/lib/Temp/File-Temp-0.12/misc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Temp/File-Temp-0.12/misc')
-rwxr-xr-xlib/Temp/File-Temp-0.12/misc/benchmark.pl42
-rw-r--r--lib/Temp/File-Temp-0.12/misc/results.txt33
2 files changed, 75 insertions, 0 deletions
diff --git a/lib/Temp/File-Temp-0.12/misc/benchmark.pl b/lib/Temp/File-Temp-0.12/misc/benchmark.pl
new file mode 100755
index 0000000..bdea837
--- /dev/null
+++ b/lib/Temp/File-Temp-0.12/misc/benchmark.pl
@@ -0,0 +1,42 @@
+#!/usr/local/bin/perl -w
+
+# Simple benchmark of temporary file creation (no filename just a handle)
+# Uses the following:
+# - temporary file creation created by IO::File
+# - temporary file creation using File::Temp (uses security checking)
+# - A roll-our-own wrapper on top of POSIX::tempnam (essentially
+# a compact form of File::Temp without all the extras) taken from
+# the Perl cookbook
+
+# Would not
+
+use strict;
+use Benchmark;
+use IO::File;
+use POSIX qw/ tmpnam /;
+use File::Temp qw/ tempfile /;
+use Symbol;
+
+# Benchmark IO::File and File::Temp
+
+timethese(10000, {
+ 'IO::File' => sub {
+ my $fh = IO::File::new_tmpfile || die $ !;
+ },
+ 'File::Temp::tempfile' => sub {
+ my $fh = tempfile() || die $ !;
+ },
+ 'POSIX::tmpnam' => sub {
+ my $fh = gensym;;
+ my $name;
+ for (;;) {
+ $name = tmpnam();
+ sysopen( $fh, $name, O_RDWR | O_CREAT | O_EXCL )
+ && last;
+ }
+ unlink $name;
+ }
+ }
+ );
+
+
diff --git a/lib/Temp/File-Temp-0.12/misc/results.txt b/lib/Temp/File-Temp-0.12/misc/results.txt
new file mode 100644
index 0000000..b73196a
--- /dev/null
+++ b/lib/Temp/File-Temp-0.12/misc/results.txt
@@ -0,0 +1,33 @@
+This file contains the results of the File::Temp benchmark script
+by File::Temp version, perl version and OS.
+
+On Windows NT, currently have problems with this benchmark since it
+runs into a file limit after a while (this is because unlinking of the
+open file is deferred until the end of the program rather than closing
+it and unlinking it explcitly round the loop).
+
+Times are in CPU seconds.
+
+VERSION PERL OS File::Temp/s IO::File/s POSIX::tmpnam
+
+0.07 5.6.0 linux(1) 22.4 1.7 2.1
+ 5.005_03 linux(1) 33.6 1.6 2.1
+
+0.08 5.6.0 linux(1) 8.1 1.7 2.1
+ 5.005_03 linux(1) 8.4 1.6 2.1
+
+ 5.6.0 solaris(2) 32.3 237.0 229.5
+
+ 5.005_03 dig.unix(3) 153.2 44.9 51.5
+
+
+
+
+1. A 600 MHz pentium III running RedHat 6.1
+
+2. A Sparc Ultra 1 running Solaris 2.6. /tmp local, /var/tmp on NFS
+ (/var/tmp is the default temp location on Solaris and is used by
+ POSIX::tmpnam whereas /tmp is used by File::Temp since that is the
+ location specified by File::Spec)
+
+3. DEC 3000 Alpha running digital unix 4.0.