parser_test.py
public python v1 · immutableimport psycopsyco.full()from time import *stime = time();print 'start:', stimefrom HTMLParser import HTMLParserfp = file('index.html', 'r')data = fp.read()i = 0class MyHTMLParser(HTMLParser): def handle_starttag(self, tag, attrs): global i if tag == 'a': i = i + 1html = MyHTMLParser()for x in range(100): html.feed(data) html.reset()etime = time()print 'stop:', etimeprint i, " A tags found"print 'time taken:', (etime - stime)#print 'average time per loop:', ((etime - stime)/10)