If a bad guy jumps you with a knife, pulling your gun out is too slow.
If a bad guy "jumps you" then unless you're Aikido dude or what have you, you're probably already fucked no matter how you intend to defend yourself. Initiative is massively important, and I don't mean that in a dungeons and dragons kind of way. Often, the first shot decides the fight.
On the other hand, most people aren't carrying around long sheathed knives, if the knife is big enough to need a weapon to defend against it then it's probably a folder and you very much can draw a gun, point it, and shoot in about the same kind of time.
Guns work great at a moderate distance. Three meters. If you can keep three meters and draw a firearm against a melee-armed man, you have control. At shorter distance, you have liability.
At a shorter distance, guns are still massively deadly. Point blank is scary for a reason. I don't want to be involved in a close-quarters fight with someone with any kind of weapon. The best defense is to be somewhere else. Yeah, blaming the victim, but if you have the opportunity to be somewhere [relatively] nonviolent, take that option.