def test_get_topics_performance(self): scraper = Topics(test_util.CachedHTMLProvider().get_HTML, None) # Run once to cache. topics = list(scraper.get_topics()) print "%s topics found" % (len(topics)) def test(): self.assertEqual(len(topics), len(list(scraper.get_topics()))) t = timeit.Timer(test) repeats = 2 time = t.timeit(repeats) / repeats print "Getting topics list took %s seconds per run" % (time) self.assertGreater(1, time)
def test_get_speakers_performance(self): scraper = Speakers(test_util.CachedHTMLProvider().get_HTML) # Run once to cache. speakers = list(scraper.get_speakers_for_pages([3, 4])) print "%s speakers found" % (len(speakers) - 1 ) # -1 because we yield #pages first def test(): self.assertEqual(len(speakers), len(list(scraper.get_speakers_for_pages([3, 4])))) t = timeit.Timer(test) repeats = 2 time = t.timeit(repeats) / repeats print "Getting speakers list took %s seconds per run" % (time) self.assertGreater(1, time)
def test_get_talks_performance(self): scraper = Themes(test_util.CachedHTMLProvider().get_HTML) # Run once to cache. talks = list( scraper.get_talks( 'http://www.ted.com/themes/a_greener_future.html')) print "%s talks for theme found" % (len(talks)) def test(): self.assertEqual( len(talks), len( list( scraper.get_talks( 'http://www.ted.com/themes/a_greener_future.html')) )) t = timeit.Timer(test) repeats = 2 time = t.timeit(repeats) / repeats print "Getting talks for theme took %s seconds per run" % (time) self.assertGreater(1, time)