An experimental method is presented to experimentally measure and control the carrier-envelope-phase (CEP)-dependent pulse-energy contrast of isolated attosecond pulses. By scanning the CEP and measuring the photoelectron spectrum produced by the combined action of the attosecond pulses and the high-harmonic driving laser pulses at zero relative time delay, one can extract the pulse-energy ratio between the main attosecond pulse and its neighboring satellite pulses arriving in preceding or subsequent half-cycles of the driver pulse. Moreover, this method allows fast and efficient in situ retrieval of the optimal CEP for high-contrast isolated attosecond pulse generation.