Test whether empty updates are faster than if-empty checks in Apex
Wed Jul 24 2024 21:08:13 GMT+0000 (Coordinated Universal Time)
Saved by
@taurenhunter
List<Account> accountList = new List<Account>();
Datetime startDttm = System.now();
for( Integer i = 0; i < 1000; i++ ) {
update accountList;
}
system.debug( 'update no checks -> ' + ( System.now().getTime() - startDttm.getTime() ) );
startDttm = System.now();
for( Integer j = 0; j < 1000; j++ ) {
if( ! accountList.isEmpty() ) {
update accountList;
}
}
system.debug( 'check before update -> ' + ( System.now().getTime() - startDttm.getTime() ) );
content_copyCOPY
Comments