set fileName "test.txt"
set bufSize [expr 4096 * 1]

puts "Tcl version: [info patchlevel] on $tcl_platform(platform)"

# Create large file.
set ten "123456789\n"
set line [string repeat $ten 10]
set str [string repeat $line 10000000]

set fp [open $fileName w]
fconfigure $fp -translation lf
puts -nonewline $fp $str
close $fp

set size [file size $fileName]
puts "File size  : $size"
puts "Buffer size: $bufSize"

# Read using 3 different modes.
foreach mode { 1 2 3 } {
    catch { unset str }
    set fp [open $fileName r]
    # fconfigure $fp -translation binary
    set startTime [clock milliseconds]

    if { $mode == 1 } {
        while { 1 } {
            set buf [read $fp $bufSize]
            if { $buf eq "" } {
                break
            }
            append str $buf
        }
    } elseif { $mode == 2 } {
        set str [read $fp]
    } elseif { $mode == 3 } {
        set str [read $fp $size]
    }
    set endTime [clock milliseconds]
    puts [format "Time mode $mode: %.2f secs" [expr {( $endTime - $startTime ) / 1.0E03 }]]
    close $fp
}
