slow I/O

Henry Cejtin henry@sourcelight.com
Thu, 14 Sep 2000 15:27:50 -0500


As a further experiment regarding my very very slow reading time, I tried

    fun exact (reader, n) =
           let fun loop (state, k) =
                      case reader state of
                        NONE =>
                           if k = n
                              then SOME ((), state)
                              else NONE
                      | SOME (_, state') =>
                           loop (state', k + 1)
           in fn state => loop (state, 0)
           end

    fun loop n =
           case TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn of
             NONE => n
           | SOME n' => loop (n + 1)

    val _ = print (Int.toString (loop 0) ^ "\n")

and it ran relatively quickly: a bit over 1.6 megabyte a second.