I don’t know if it can be generalized to any programming languages. I usually use Java for analyzing document data, and most of my codes do very intensive computation taking up 100% CPU usage while iterating the documents a few thousand times. One execution or experiment takes almost the whole day or a couple, so the code optimization is very important to save several hours. I found out from my codes that surprisingly, memory allocation was taking more time than computation itself. Especially, it should be avoided to repeatedly allocate memory for large arrays. When Java allocates memory for an integer array or double array, the elements are initialized to be zero automatically. Considering this initialization can be done efficiently at the memory level, however, I would conclude that reserving consecutive memory space is the most time-consuming part.