You need to look at the Napolionic period where the bayonet ruled within infantry tactics. The bayonet was for offensive attack against troops and defence against cavalry. Disceplined troops working with the bayonet, after firing a couple of musket shots, were as devastating as Roman Legionaries with their short swords and shields, having thrown their spears(forgoten correct term).
It really takes two well trained soldiers armed with bayonets to take out one enemy, where the enemy is as good as dead. Native North American Indians with their fighting sticks and tomahawks were put to the sword and bayonet fairly swiftly. It was later when rearmed by the European armies that they began to hold their own.
A full sized battle sword, in well practiced hands, is a more even match. Revolver and sword better still, but not necessarily revolver on its own. Pistol hits do not stop a bayonet thrust which have to be powerfully paried away.
WWI saw the demise of the long bayonet; no cavalry. From about 1915 the German army rarely if ever fixed bayonets; it took a little longer for the Allies to follow. True, the trenches ensured that all manner of improvised weapons were deployed including shotguns, cutlasses and clubs; but grenades (bombers)ruled up close.
However, bolt action rifles still remained the soldiers personal weapon, so the bayonet survived as part of infantry's offensive weaponary, if a bit shorter, to this day. Some Brits in the Falklands War, 1980's, used their bayonets in their final assault to good effect because they had either run out of ammunition or hadn't the time to change magazines. The rifle was the long FN FAL SLR 7.62 with a twenty round mag.
Now that high capacity, fully automatic, assault rifles are the norm the bayonet realy is redundant especially on the ever popular bullpup and carbine sized assault rifles. For the weight you are better off having a light weight utility knife, such as the Swedish army issues, and more ammunition.
When a recruit I was charged by Gurkhas with fixed swords (days of the SLR). It was scarey. But then I didn't know how to put a DF down within 50m of me, and this was a demonstration/experience builder not how to do it.
To sum up, a bayonet on the end of a rifle gives reach and power. But if you have the ammunition you might as well shoot the b***er. Today firepower rules, period.