Guest User

Untitled

a guest
Sep 26th, 2016
1,367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. def measure_page_performance_time(driver, tries_count, url):
  2.     average = 0
  3.     print "url: ", url
  4.     for n in range(tries_count):
  5.         driver.get(url)
  6.         stext = driver.execute_script(
  7.             "return ( window.performance.timing.loadEventEnd - window.performance.timing.navigationStart )")
  8.         average = average + int(stext)
  9.         print "trying ", n + 1, " time", "........Value is: %s" % float(float(stext) / 1000), "seconds"
  10.  
  11.     total_load_time = (float(float(average) / float(tries_count)) / 1000)
  12.  
  13.     if total_load_time < TIME_THRESHOLD:
  14.         warning_msg = " - OK"
  15.     else:
  16.         warning_msg = "!!!WARNING!!! THIS PAGE PERFORMANCE IS TOO SLOW"
  17.  
  18.     print "||url: ", url, "AVERAGE is: %s" % total_load_time, "seconds" + warning_msg + "||"
  19.     print ""
Advertisement
Add Comment
Please, Sign In to add comment