It's also important to be respectful of the family's wishes, and the other mourners. If you notice the room is getting crowded, or the family is trying to wrap things up, it's probably time to make your exit. On the other hand, if you're having a great conversation with someone, or sharing a special memory, don't worry about overstaying your welcome - just be present in the moment.
PPT - Altered States of Consciousness PowerPoint Presentation, free
So, to answer your question, the length of time you should stay at a wake really depends on the situation, and the people involved. Just remember to be genuine, be respectful, and be open to the experience. And who knows, you might even find that it's a life-affirming experience, one that helps you appreciate the people in your life even more.