Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Result plot from file #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ OTPQA

Keep track of changes in OTP performance as development progresses, and catch breaking changes to input data sets by observing changes in routing results.

You will need Python and some Python libraries. For the libraries, on a Debian based system like Ubuntu you can run:
You will need Python (2.x) and some Python libraries. For the libraries, on a Debian based system like Ubuntu you can run:

`$ sudo apt-get install python-simplejson python-scipy`

Expand All @@ -26,15 +26,16 @@ It takes no arguments, assumes the presence of endpoints_random.csv and endpoint
Then run the profiler with


$ python otpprofiler.py hostname

That will generate run_summary.TIMESTAMP.json and full_itins.TIMESTAMP.json
That one can do with what one pleases.

To generate a report run

$ python report.py filename1.json filename2.json

Where a file name corresponds to a run_summary file created earlier

To generate an HTML report, run

$ python hreport.py f1 [fn2 [fn3 ...]] > report.html

4 changes: 2 additions & 2 deletions otpprofiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# python-requests wraps urllib2 providing a much nicer API.
import grequests

DATE = '2014-12-30'
DATE = '2015-12-30'
# split out base and specific endpoint
SHOW_PARAMS = False
SHOW_URL = False
Expand Down Expand Up @@ -119,7 +119,7 @@ def summarize_plan (itinerary) :
waits.append(wait)
ret = {
'start_time' : time.asctime(time.gmtime(itinerary['startTime'] / 1000)) + ' GMT',
'duration' : '%d msec' % int(itinerary['duration']),
'duration' : '%d sec' % int(itinerary['duration']),
'n_legs' : n_legs,
'n_vehicles' : n_vehicles,
'walk_distance' : itinerary['walkDistance'],
Expand Down
25 changes: 25 additions & 0 deletions result_plot_from_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import json, violin

def plot_results(dataset, label):

data = []
total_times = []

if "responses" in dataset:
for resp in dataset['responses']:
if "total_time" in resp:
total_times.append( float(resp["total_time"][:-5]) / 1000.00) #to seconds

data.append(total_times)
violin.violin_plot(data, bp=True, scale=True, labels=[label])


if __name__=='__main__':
import sys

if len(sys.argv)<3:
print "usage: cmd json_summary_file_name plot_label"
exit()

dataset = json.load(open(sys.argv[1]))
plot_results(dataset, sys.argv[2])