Is it cheaper to repair or replace an engine?

Is it cheaper to repair or replace an engine?