+ Start a Discussion

Error CPU Time Limit Exceeded

I am trying to figure out why this is exceeding the CPU Time Limit.  It is bulked with 200 records in the test class and works fine but updating even 50 records in real life gives me CPU Time Limit exceeded errors.  It is only telling me there is an error for the whole Class and not a specific section of the class.  Can anyone please give me some pointers on how I can pinpoint exactly what part of the class is exceeding the CPU Time Limit? I've tried doing the standard things to lower CPU usage but it just keeps going up exponentially in real time but not in the test classes.  It won't let me post the whole code here but you can see it at https://gist.github.com/e43a5f3537d48e26a3b1.git

Are you using for loop inside for loop any where in you code
like as mentioned below, if yes then you have to use Map to resolve this , it is one of the big reasons for CPU Time Limit