List<Account> accountList = [
SELECT Id, Name, AccountNumber FROM Account WHERE Name LIKE 'Test Account - %'
LIMIT 10
];
Datetime startDttm = System.now();
Map<String, SObject> acctMapByNbr =
MapCreator.createMapByIndex( accountList, 'AccountNumber' );
system.debug( 'MapCreator -> ' + ( System.now().getTime() - startDttm.getTime() ) );
startDttm = System.now();
Map<String, SObject> acctMapByNbr2 =
new Map<String, SObject>();
for( Account anAccount : accountList ) {
acctMapByNbr2.put( String.valueOf( anAccount.AccountNumber ), anAccount );
}
system.debug( 'standard map creation -> ' + ( System.now().getTime() - startDttm.getTime() ) );
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter