As has been mentioned frequency has leveled off. CPU companies (read AMD,Intel, and even ARM to some degree) are using multiple cores to increase performance. However many programs, even though they use multiple threads, are not written to take advantage of the 2,4,6,8 cores seen in modern CPUS.
You asked if it was more important to optimize code for CPU or for memory. Both are important but the greatest gain will come from writing applications that can take advantage of the increasingly parallel architecture that is the future for processors. And of course, compilers,interpreters and virtual machines still need to "catch up".