bufferedreader: read a file line by line module (BufferedReader vs Scanner vs Files.lines vs readAllLines on a 1 GB file; heap at -Xmx64m, timings, read-call counts, one-huge-line OOM, charset/BOM/line-terminator pitfalls, Scanner swallowing IOException), 10 contract tests

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b3pDoGLiWk6LLBeHjW
This commit is contained in:
Claude
2026-11-15 01:20:37 +05:30
parent 5faa57bb2d
commit f8c9e244a3
25 changed files with 809 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
== 1. read() calls that reach the underlying InputStream (first 50 MB of the file) ==
InputStreamReader.read() per char underlying calls= 6,104 avg bytes/call= 8,192.0
BufferedReader(8192).read() per char underlying calls= 6,104 avg bytes/call= 8,192.0
BufferedReader(8192).readLine() underlying calls= 6,104 avg bytes/call= 8,192.0
BufferedReader(65536).readLine() underlying calls= 6,104 avg bytes/call= 8,192.0
BufferedReader(1).readLine() underlying calls= 6,104 avg bytes/call= 8,192.0
== 2. time to consume the whole file (3 passes each; indicative, same JVM) ==
pass 1 InputStreamReader.read() per char 6,493 ms
pass 1 BufferedReader.read() per char 4,902 ms
pass 1 BufferedReader.readLine() 206 ms
pass 2 InputStreamReader.read() per char 7,373 ms
pass 2 BufferedReader.read() per char 4,948 ms
pass 2 BufferedReader.readLine() 279 ms
pass 3 InputStreamReader.read() per char 7,395 ms
pass 3 BufferedReader.read() per char 5,077 ms
pass 3 BufferedReader.readLine() 269 ms