derrek/street-address — pull request #3 by mattruggio (2013-06-14 19:28:36+00:00)
Title: Optimized for performance

Thank you for this class, it was extremely helpful in understanding address parsing and normalization within Ruby. For our case, we needed to parse datasets that have 6,000,000+ addresses. In order to use your class, we found some very slight modifications could be made that would make it extremely fast.

Here are some benchmarks using the addresses and intersections supplied in the tests:

### Before Optimization

(Time in milliseconds) - Address
(1.0882) - 2730 S Veitch St Apt 207, Arlington, VA 22206
(1.1823) - 44 Canal Center Plaza Suite 500, Alexandria, VA 22314
(1.1187) - 1600 Pennsylvania Ave Washington DC
(1.2637) - 1005 Gravenstein Hwy N, Sebastopol CA 95472
(1.2633) - PO BOX 450, Chicago IL 60657
(1.179) - 2730 S Veitch St #207, Arlington, VA 22206
(2.1652) - Hollywood & Vine, Los Angeles, CA
(2.3919) - Hollywood Blvd and Vine St, Los Angeles, CA
(2.3417) - Mission Street at Valencia Street, San Francisco, CA

### After Optimization

(Time in milliseconds) - Address
(0.0129) - 2730 S Veitch St Apt 207, Arlington, VA 22206
(0.0073) - 44 Canal Center Plaza Suite 500, Alexandria, VA 22314
(0.0063) - 1600 Pennsylvania Ave Washington DC
(0.0053) - 1005 Gravenstein Hwy N, Sebastopol CA 95472
(0.0006) - PO BOX 450, Chicago IL 60657
(0.0086) - 2730 S Veitch St #207, Arlington, VA 22206
(0.0143) - Hollywood & Vine, Los Angeles, CA
(0.009) - Hollywood Blvd and Vine St, Los Angeles, CA
(0.0087) - Mission Street at Valencia Street, San Francisco, CA

### I have supplied 3 commits for you:
1. Added a simple benchmarking script so you can replicate these tests easily.
2. Forced the encoding of the address/intersection to parse to US-ASCII.
3. Made the regular expressions class-level and not instance/method level.

All tests were ran successfully during and after refactoring. Let me know your thoughts!