Skip to content

Instantly share code, notes, and snippets.

@dhaniksahni
Created January 4, 2022 16:40
Show Gist options
  • Save dhaniksahni/36687ac2d42f972b96ffd17c89b91cf3 to your computer and use it in GitHub Desktop.
Save dhaniksahni/36687ac2d42f972b96ffd17c89b91cf3 to your computer and use it in GitHub Desktop.
Debug Test Service
public class DebugTestService {
public class AccountWrapper
{
@auraenabled
public string Name{get;set;}
@auraenabled
public integer NumberOfEmployees{get;set;}
@AuraEnabled
public List<Contact> Contacts { get; set; }
}
public void DebugTest()
{
List<AccountWrapper> wrapperList=new List<AccountWrapper>();
AccountWrapper wrap=null;
for(integer i=0;i<2000;i++)
{
wrap=new AccountWrapper();
wrap.Name='Test'+ (i+1);
wrap.NumberOfEmployees=(i+1);
wrap.Contacts=new List<Contact>();
for(integer j=1;j<6;j++)
{
Contact c=new Contact();
c.LastName='Contact '+j+' for '+'Test'+ (i+1);
wrap.Contacts.addAll(new List<Contact>{c});
}
wrapperList.add(wrap);
}
Long startMillis=System.now().getTime();
Long startCPU=Limits.getCpuTime();
system.debug('wrapperList:'+wrapperList);
system.debug('wrapperList:'+wrapperList);
system.debug('wrapperList:'+wrapperList);
Long totalMills=System.now().getTime() - startMillis;
Long cpuTimes=Limits.getCpuTime() - startCPU;
system.debug('totalMillseconds:'+totalMills);
system.debug('cpuTimes:'+cpuTimes);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment