Created
June 18, 2015 17:10
-
-
Save jmcarp/6954c26f04388e3e8616 to your computer and use it in GitHub Desktop.
schedule_a_benchmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| import random | |
| from webservices import rest | |
| from webservices.common import models | |
| rest.app.app_context().push() | |
| years = range(1976, 2016) | |
| cities = [ | |
| 'NEW YORK', | |
| 'DALLAS', | |
| 'OAKLAND', | |
| 'MECHANICSBURG', | |
| 'WINCHESTER', | |
| 'LOS ANGELES', | |
| 'NAPERVILLE' | |
| 'PHOENIX', | |
| 'REDONDO BEACH', | |
| 'NORTH POTOMAC', | |
| 'CHICAGO', | |
| ] | |
| committees = [ | |
| 'C00473744', | |
| 'C00356428', | |
| 'C00537399', | |
| 'C00196303', | |
| 'C00016295', | |
| 'C00081802', | |
| 'C00379099', | |
| 'C00397075', | |
| 'C00073635', | |
| 'C00334052', | |
| 'C00316570', | |
| 'C00003301', | |
| 'C90008368', | |
| 'C00100289', | |
| 'C00555235', | |
| 'C00339705', | |
| 'C00489575', | |
| 'C00302398', | |
| 'C00064329', | |
| 'C00412262', | |
| 'C00558056', | |
| 'C00108746', | |
| 'C00273870', | |
| 'C00256339', | |
| 'C00209007', | |
| 'C00212654', | |
| 'C00017749', | |
| 'C00077974', | |
| 'C00021923', | |
| 'C00293324', | |
| 'C00399691', | |
| 'C00055293', | |
| 'C00550988', | |
| 'C00180935', | |
| 'C99002404', | |
| 'C00212456', | |
| 'C00143503', | |
| 'C90013434', | |
| 'C00042986', | |
| 'C00331132', | |
| 'C00100834', | |
| 'C00513952', | |
| 'C00202069', | |
| 'C00129312', | |
| 'C90010042', | |
| 'C00143537', | |
| 'C00415190', | |
| 'C00104158', | |
| 'C00071233', | |
| 'C00447045', | |
| 'C00494328', | |
| 'C00222943', | |
| 'C00515692', | |
| 'C00034959', | |
| 'C00100891', | |
| 'C00449124', | |
| 'C00103325', | |
| 'C00309542', | |
| 'C00205781', | |
| 'C00227280', | |
| 'C00093450', | |
| 'C00092510', | |
| 'C00253781', | |
| 'C00145540', | |
| 'C00164749', | |
| 'C00196030', | |
| 'C00499236', | |
| 'C00231985', | |
| 'C00162206', | |
| 'C00575720', | |
| 'C00389684', | |
| 'C00560987', | |
| 'C99001703', | |
| 'C00143198', | |
| 'C00467779', | |
| 'C00467779', | |
| 'C00015230', | |
| 'C00509034', | |
| 'C00514661', | |
| 'C00251264', | |
| 'C00206201', | |
| 'C00488007', | |
| 'C00249144', | |
| 'C30002273', | |
| 'C00078501', | |
| 'C00017129', | |
| 'C00269670', | |
| 'C00378638', | |
| 'C00387381', | |
| 'C00252304', | |
| 'C00562207', | |
| 'C00132779', | |
| 'C00071373', | |
| 'C00122713', | |
| 'C00451856', | |
| 'C00218032', | |
| 'C00016485', | |
| 'C00497586', | |
| 'C00259671', | |
| 'C00201145', | |
| 'C00191510', | |
| ] | |
| columns = [ | |
| (models.ScheduleA.report_year, years), | |
| (models.ScheduleA.committee_id, committees), | |
| (models.ScheduleA.contributor_city, cities), | |
| ] | |
| def query(): | |
| column, values = random.choice(columns) | |
| value = random.choice(values) | |
| now = time.time() | |
| models.ScheduleA.query.filter(column == value).limit(50).all() | |
| return time.time() - now | |
| def bench(count): | |
| elapsed = [] | |
| for _ in range(count): | |
| elapsed.append(query()) | |
| return elapsed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment