Assuming you have a piece of code that does some processing, and you want it to process more within a given time frame there are certainly things you can do.
1) The most important thing is, of course, to write your code correctly. You say you have optimized the code as much as possible, but try to get a pair of fresh eyes on it. If you don't have a performance expert within reach, you can probably find some here: https://codereview.stackexchange.com/
2) Make sure your machine isn't busy doing something else. Research the command top
. Programs you don't want running on your machine, ever, you could remove using (generally) sudo apt-get remove <program>
. If you need more memory, specifically, you can sort the top
-list with the interactive command M
.
3) Give higher priority to you process. Research nice
. Be careful not to starve your own process, tough - that is, if your program consumes data provided by another program, and your process has much higher priority, data might not be available in the pace it can me processed.
4) And the obvious answer: get another machine. The pi is not really made to be a fast cruncher - it's a lab board. If you need to get something done quickly, it's simply not the right HW.