Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Performance testing with Multi-Mechanize

Avatar for Rich Leland Rich Leland
February 07, 2012

Performance testing with Multi-Mechanize

Presentation to DC Python on Feb 7, 2012 about Multi-Mechanize, a performance testing framework.

Avatar for Rich Leland

Rich Leland

February 07, 2012
Tweet

Other Decks in Programming

Transcript

  1. [global] run_time: 30 rampup: 0 results_ts_interval: 10 progress_bar: on console_logging:

    off xml_report: off [user_group-1] threads: 3 script: example.py [user_group-2] threads: 3 script: example.py
  2. import requests import time class Transaction(object): def run(self): start =

    time.time() url = 'http://www.treehugger.com/' r = requests.get(url) latency = time.time() - start self.custom_timers['Home_Page'] = latency time.sleep(1)
  3. $ multimech-run . user_groups: 2 threads: 20 [================100%==================] 60s/60s transactions:

    232 timers: 464 errors: 0 waiting for all requests to finish... analyzing results... created results/results_2012.02.06_23.11.01/results.html done.
  4. myproject ├── results │ ├── results_2012.02.05_00.16.23 │ │ ├── config.cfg

    │ │ ├── results.csv │ │ └── results.html │ └── static ├── test_scripts └── config.cfg Results output
  5. import requests import time class Transaction(object): def run(self): start =

    time.time() url = 'http://example.com/api/v1/articles/' r = requests.get(url) latency = time.time() - start self.custom_timers['API_Articles'] = latency time.sleep(1)
  6. import time from sqlalchemy import create_engine class Transaction(object): def __init__(self):

    self.custom_timers = {} conn_info = 'postgresql+psycopg2://rleland@localhost/th' self.engine = create_engine(conn_info) def run(self): start = time.time() self.engine.execute("SELECT COUNT(*) FROM cms_entry") latency = time.time() - start self.custom_timers['Entries_Count'] = latency
  7. import memcache import random import time NODES = ['192.168.10.2:11211',] DATA_SIZE

    = 30000 WAIT_TIME = .1 KEY_RANGE = (1, 1000000) class Transaction(object): def __init__(self): self.mc = memcache.Client(NODES) self.custom_timers = {} def run(self): key = str(random.randint(*KEY_RANGE)) data = '*' * DATA_SIZE start_timer = time.time() self.mc.set(key, data) stop_timer = time.time() self.custom_timers['SET'] = stop_timer - start_timer start_timer = time.time() self.mc.get(key) stop_timer = time.time() self.custom_timers['GET'] = stop_timer - start_timer time.sleep(WAIT_TIME)