Skip to content

Instantly share code, notes, and snippets.

@flodolo
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save flodolo/6df990debff274ad5c86 to your computer and use it in GitHub Desktop.

Select an option

Save flodolo/6df990debff274ad5c86 to your computer and use it in GitHub Desktop.
Check load time, memory usage on langchecker
#! /usr/bin/env python
import os
import urllib2
os.system('clear')
base_langchecker = "http://192.168.133.115/langchecker/"
pages = [
base_langchecker + "?locale=it",
base_langchecker + "?action=activation",
base_langchecker + "?action=errors",
base_langchecker + "?website=0&file=mozorg/home.lang&action=translate",
base_langchecker + "?website=0&file=mozorg/home.lang&locale=all",
base_langchecker + "?website=0&file=main.lang&action=translate",
base_langchecker + "?website=0&file=main.lang&locale=all",
base_langchecker + "?action=count",
]
tries = 10
for page in pages:
try:
print "************"
print "Page: " + page
time_total = 0
memory_total = 0
for count in range(1,tries+1):
response = urllib2.urlopen(page)
for line in response:
if (line.startswith('<!-- Elapsed time (s):')):
time_single = float(line.lstrip('<!-- Elapsed time (s): ').rstrip(' -->\n'));
time_total += time_single
print "#%d: %f seconds" % (count, time_single)
if (line.startswith('<!-- Memory usage (MB):')):
memory_single = float(line.lstrip('<!-- Memory usage (MB): ').rstrip(' -->\n'));
memory_total += memory_single
print "#%d: %f MB" % (count, memory_single)
print "Average load time (%d tries): %f seconds" % (count, time_total/float(count))
print "Average memory usage (%d tries): %f MB" % (count, memory_total/float(count))
except Exception as e:
print "Error reading page " + page
print e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment