[MLton-commit] r6852
Vesa Karvonen
vesak at mlton.org
Sun Sep 14 14:11:41 PDT 2008
Use OS.Process.tmpName to generate the name for the test file. This has
the effect that the file will usually be mapped to a system dependent
directory for temporary files. On many systems the directory for
temporary files is mapped (mounted) to a special file system, such as the
tmpfs (a kind of ramdisk) found on contemporary linux systems. Depending
on the performance of the ordinary file system, this can speed up the io
regression tests (binio and textio.2) by several orders of magnitude (from
hours (seen almost 1 hour per io test on a linux laptop with XFS) or
minutes to seconds).
----------------------------------------------------------------------
U mlton/trunk/regression/binio.sml
U mlton/trunk/regression/textio.2.sml
----------------------------------------------------------------------
Modified: mlton/trunk/regression/binio.sml
===================================================================
--- mlton/trunk/regression/binio.sml 2008-09-14 14:37:27 UTC (rev 6851)
+++ mlton/trunk/regression/binio.sml 2008-09-14 21:11:40 UTC (rev 6852)
@@ -1,3 +1,5 @@
+val filename = OS.FileSys.tmpName ()
+
fun testRange (start, length) =
let
val allChars = Word8Vector.tabulate(length, fn i => Word8.fromInt ((i + start) mod 256))
@@ -2,10 +4,10 @@
- val outStr = BinIO.openOut "testBinIO.txt"
+ val outStr = BinIO.openOut filename
val _ = BinIO.output (outStr, allChars)
val _ = BinIO.closeOut outStr
-
- val inStr = BinIO.openIn "testBinIO.txt"
+
+ val inStr = BinIO.openIn filename
val readChars = BinIO.inputAll inStr
val _ = BinIO.closeIn inStr
-
+
fun testCharF (c, cnt) =
@@ -21,7 +23,7 @@
in
cnt + 1
end
-
+
val _ = Word8Vector.foldl testCharF 0 allChars
in
()
@@ -33,4 +35,4 @@
val _ = print "test of writing files of all possible characters in strings of lengths 0-256 finished\n"
val _ = List.tabulate(6, fn i => List.tabulate(5000, fn i2 => testRange (i, i2)))
-val _ = print "test finished\n"
\ No newline at end of file
+val _ = print "test finished\n"
Modified: mlton/trunk/regression/textio.2.sml
===================================================================
--- mlton/trunk/regression/textio.2.sml 2008-09-14 14:37:27 UTC (rev 6851)
+++ mlton/trunk/regression/textio.2.sml 2008-09-14 21:11:40 UTC (rev 6852)
@@ -1,18 +1,20 @@
(* Notice: This test will not be passed on platforms like Win32!
But for Linux it happens to work... *)
+val filename = OS.FileSys.tmpName ()
+
fun testRange (start, length) =
let
val allChars = CharVector.tabulate(length, fn i => chr ((i + start) mod 256))
- val outStr = TextIO.openOut "testTextIO.txt"
+ val outStr = TextIO.openOut filename
val _ = TextIO.output (outStr, allChars)
val _ = TextIO.closeOut outStr
-
- val inStr = TextIO.openIn "testTextIO.txt"
+
+ val inStr = TextIO.openIn filename
val readChars = TextIO.inputAll inStr
val _ = TextIO.closeIn inStr
-
+
fun testCharF (c, cnt) =
let
val readC = CharVector.sub(readChars, cnt)
@@ -24,7 +26,7 @@
in
cnt + 1
end
-
+
val _ = CharVector.foldl testCharF 0 allChars
in
()
More information about the MLton-commit
mailing list