Cardy formula for 4d SUSY theories and localization