The Blog of Brad
Days of Code: Perl URL Shortener // Day 5
Since I last wrote, I’ve reconfigured a few different things in this.
- In shorten.pl – I’ve fixed the API key verification for now, added rudimentary invalid URL detection.
- In list.pl – I’ve used threads, as mentioned in a tweet, , and now save about 64% of the time in listing all of the URLs in the database. (that’s using 2 threads; I’ve found that 8 is optimal in general on this server)YES! #Perl | With threads I was able to cut total execution time from 0.121s to 0.78s (both averages)! Perl==WIN!
- In stats.pl – I now order the URLs by id (in other words, the one with the latest created short code first).
- In subs.pl – I rewrote some of the
randomPasswordsubroutine. It should be more efficient in the future, however I will need to write one from scratch to make it work; I keep getting long short codes, I specify a 2-character sc and get a 4 (always 4) character password/sc in return. Help?
I’ve posted the updates to this code on the usual Code >> Perl URL Shortener page.
You can also see it in action at Brad-Zone.com … for now.
| Print article | This entry was posted by BradArsenault on January 29, 2010 at 10:02 pm, and is filed under Blog. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |

















Comments are closed.