I'm not sure. I haven't tested it but I think the amount of earned XP stays constant, no matter how poor or how fast or slow your car is over the AI's cars. I think the only factor that really changes it is the position you land on when you finish the last lap/at the last second (for endurance races).