How long will it take to go to mayo from dublin by train?

Depending on which Mayo station you are going to it will be between 3 and 3.5 hours approx. Some services require a change of train in Athlone but most are direct.