Prestiging and attacking are different. When attacking, gyms are reduced by a flat 1000 for each mon fainted regardless of the CP of your mons with an additional 1000 bonus for clearing the gym.
Ideally while prestiging you want your mon half the cp for the maximum of 1000 prestige reward, with 100 being the minimum if your mon is double the CP of the enemy.
https://pokemongo.gamepress.gg/gyms
Unless I'm not understanding your question.