For the churches/cathedrals, it really depends on whether you want to do a tour and how long you want to spend there. Plan for maybe an hour, but more or less depending on your interests.
An hour sounds about right for Dublin Castle, we did the tour there.
The Gaol tour was about an hour - don't miss this, it was fantastic, and do buy your tickets in advance as the previous poster noted.
Guinness is up to you too. It can be relatively short, or you can spend several hours there. You get one or two free pints with the price of admission (I can't remember if it's one or two), but there are restaurants/cafes, museums, other experiences and things to do. The day we went (a Sunday) they had live music in the pub, so we wound up having lunch and a few more pints and listening to the music for a while.
The National Gallery is good, but not massive. Maybe two hours if you really want to linger. The National Museum is great. About the same.