<P> More complex algorithms and data structures perform well with many items, while simple algorithms are more suitable for small amounts of data--the setup, initialization time, and constant factors of the more complex algorithm can outweigh the benefit, and thus a hybrid algorithm or adaptive algorithm may be faster than any single algorithm . A performance profiler can be used to narrow down decisions about which functionality fits which conditions . </P> <P> In some cases, adding more memory can help to make a program run faster . For example, a filtering program will commonly read each line and filter and output that line immediately . This only uses enough memory for one line, but performance is typically poor, due to the latency of each disk read . Performance can be greatly improved by reading the entire file then writing the filtered result, though this uses much more memory . Caching the result is similarly effective, though also requiring larger memory use . </P> <P> Optimization can reduce readability and add code that is used only to improve the performance . This may complicate programs or systems, making them harder to maintain and debug . As a result, optimization or performance tuning is often performed at the end of the development stage . </P> <P> Donald Knuth made the following two statements on optimization: </P>

When does parallelism helps your algorithms run faster and when does it make them run slower