I have tested this a little bit and I'm not quite sure I understand the exact numbers or what impacts them.
I took a gym, put in a 25cp Magikarp, and trained against it.
521cp Vaporeon: 10xp and 100 prestige
10cp Magnemite: 100xp and 1000 prestige
I didn't record other numbers, but I know I would only get around 800ish prestige with pokemon around the 25cp-35cp range.
Purpose to this (feel no need to answer these): What if there were 2+ low cp defenders? Would I gain 100xp per defeat as long as my cp is equal to or lower than theirs? Could I gain more xp if the defender was 500cp and I won with a 200cp? Is this a strat to take down more prestige at an opposing gym (low cp, type advantage)?
For all I know, getting less than 100xp per defeat is based on HP difference, attack power difference, or even how many attacks it took to win.
Does anyone know the math for how much xp you gain or prestige you gain when training, and how much they lose at opposing gyms?