In my experience, how quickly you correctly identify a gunshot or similar noise for what it is is dependent on three factors:
1. Your experience with aforementioned noises.
2. How much you expect to hear them in that particular environment.
3. The proximity and succession of the noises
While at a firing range you expect to hear gunfire, and your ears are conditioned for it. You might even be able to determine what is being fired. Anywhere else, not only will the noise sound different because of distance or other obstacles between you and the gunshot, but it will also take longer for your brain to register what it really is.
I remember when on my first overseas deployment, the first time I heard incoming mortar fire, it took me a few seconds to figure out what it was. Not long after that it was very natural to quickly react to that same sound, and distinguish between the noises of rockets, mortars, and outgoing artillery. Upon returning home, I was still conditioned for those noises. For a couple weeks at least, even the sound of a slamming freezer lid (WHUMP!) would nearly make me hit the deck. If I were to hear the same noises today, I would definitely not recognize the sound nearly as quickly, because I am not expecting it. I realize comparing explosives to gunshots is apples and oranges (I doubt anyone is gonna snap and start lobbing mortars at the local wal-mart), but the same principle still applies.
Though I've fired and heard way too many gunshots to count (like everyone else here I'm sure), the realist in me seriously doubts my ability to quickly identify a gunshot for what it is in an environment that I am not expecting it. With that being said, some sounds can give away gunshots much more easily. A gun fired in rapid succession is much less mistakable than a single gunshot, and the shear volume of a gunshot in close proximity rules out just about any other possibility.
Spending time at the firing range may give you a little edge in identifying gunfire, but don't overestimate it.