This lecture explains what a “bottleneck” in input/output is, and how to detect and eliminate it. We will break down why disk and network operations are significantly slower than RAM, which anti-patterns are common (reading one byte at a time via
read(), synchronous logs, etc.), how buffers help (
BufferedInputStream,
BufferedReader), profilers (
VisualVM,
JProfiler), and timing via
System.
currentTimeMillis
(). We will run a practical experiment reading the file
"bigfile.txt", compare speed with and without buffering, look at the impact of SSD/HDD and the network, and list typical mistakes.