Skip to content

Instantly share code, notes, and snippets.

@adngdb
Last active February 3, 2016 18:22
Show Gist options
  • Save adngdb/aeecc038214c0b059710 to your computer and use it in GitHub Desktop.
Save adngdb/aeecc038214c0b059710 to your computer and use it in GitHub Desktop.
import datetime
import requests
import time
def measure_supersearch(base_url):
today = datetime.datetime.utcnow().date()
two_months_ago = today - datetime.timedelta(weeks=8)
urls = (
'{}?product=Firefox',
'{}?product=Thunderbird',
'{{}}?date=<={}&date=>{}'.format(today, two_months_ago),
'{}?_histogram.date=version',
'{}?_aggs.product.version=_cardinality.install_time',
)
for i, url in enumerate(urls):
url = url.format(base_url)
start = time.time()
requests.get(url)
end = time.time()
delta = end - start
print('Running test {} ({}) took: {}s'.format(
i, url, delta
))
if __name__ == '__main__':
print('Starting measurements at {}'.format(
datetime.datetime.utcnow().isoformat()
))
print('')
print('# STAGE')
stage_url = 'https://crash-stats.allizom.org/api/SuperSearch/'
measure_supersearch(stage_url)
print('')
print('# PROD')
prod_url = 'https://crash-stats.mozilla.com/api/SuperSearch/'
measure_supersearch(prod_url)
Starting measurements at 2016-02-03T18:19:34.294687
# STAGE
Running test 0 (https://crash-stats.allizom.org/api/SuperSearch/?product=Firefox) took: 1.39545416832s
Running test 1 (https://crash-stats.allizom.org/api/SuperSearch/?product=Thunderbird) took: 0.904582977295s
Running test 2 (https://crash-stats.allizom.org/api/SuperSearch/?date=<=2016-02-03&date=>2015-12-09) took: 2.15025186539s
Running test 3 (https://crash-stats.allizom.org/api/SuperSearch/?_histogram.date=version) took: 0.909507989883s
Running test 4 (https://crash-stats.allizom.org/api/SuperSearch/?_aggs.product.version=_cardinality.install_time) took: 0.942596912384s
# PROD
Running test 0 (https://crash-stats.mozilla.com/api/SuperSearch/?product=Firefox) took: 1.37085199356s
Running test 1 (https://crash-stats.mozilla.com/api/SuperSearch/?product=Thunderbird) took: 0.939481019974s
Running test 2 (https://crash-stats.mozilla.com/api/SuperSearch/?date=<=2016-02-03&date=>2015-12-09) took: 1.48775696754s
Running test 3 (https://crash-stats.mozilla.com/api/SuperSearch/?_histogram.date=version) took: 1.02283382416s
Running test 4 (https://crash-stats.mozilla.com/api/SuperSearch/?_aggs.product.version=_cardinality.install_time) took: 0.983560085297s
@peterbe
Copy link

peterbe commented Feb 3, 2016

Why did they all takes the same time?!

@adngdb
Copy link
Author

adngdb commented Feb 3, 2016

I could run a query on a longer time frame to get an example of something taking much longer, if you think that makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment