• Post Reply Bookmark Topic Watch Topic
  • New Topic

Optimising a java program for memory and time efficiency

 
ola ula
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I am looking for a way to optimise further the following code but for memory and time efficiency. It at present takes 11 seconds to run the main function. However, if possible I really would like to see how I can reduce this further. Please also let me know how I can optimise for memory use too ?

Thanks a lot
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
408
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know which part is taking the time - the IO or the algorithm? If you aren't sure, you can find out by replacing the method with this one see if it still takes 11 seconds.

public static String londonBus_algo(int testCaseCount, int R, int k, int N, String[] testCaseGroups){
return "Returned value" ;
}
 
ola ula
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply.
I have just checked it and it seems that 10 seconds of 11 are consumed during the algorithm execution. I/O seems negligible. So, I really wonder how I can reduce this time for the algorithm.
 
Jayesh A Lalwani
Rancher
Posts: 2762
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How big is R and how many elements in testcaseGroups? It seems to me that the number of iterations would be r*testcase groups.length. How big is this?


What are you trying to do here exactly? It looks like you just take elements from the begging of the list, and add it to the end. Why don't you just iterate over the whole list once?
 
ola ula
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

thanks a lot for the replies. I think that I have resolved it !
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!