Companies posted their largest earnings beat in five years despite soaring oil costs.