Skip to content

Commit 030da8c

Browse files
committed
Update design-document
* Add also tool to visualize the results and examples of results.
1 parent d5ea4f8 commit 030da8c

21 files changed

+153
-25
lines changed

docs/design-document.md

+53-25
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,16 @@ The timestamp is the date (unix epoch) when the result was received by the serve
258258
About the json files
259259
--------------------
260260

261-
If you check the JSON data files generated by the bots you will see that
262-
the following:
263-
264-
265-
The value for a test is as follows. There are two possibilities:
261+
If you check the JSON data files generated by the bots you will see the
262+
following format:
266263

264+
The value for a test is as follows. There are two possibilities:
267265

266+
```pre
268267
{ ${NameOfTest}: {metrics: { ${NameOfMetric} : { current : [ list of values ] } } } }
269268
270269
{ ${NameOfTest}: {metrics: { ${NameOfMetric} : [ AggregationAlgorithm ] }}}
271-
270+
```
272271

273272
The first option indicates that this specific test has real values for that metric
274273
produced from the browser while running it.
@@ -280,7 +279,6 @@ A test can also contain subtests. Its mandatory that a test with aggreated value
280279
contain subtests.
281280

282281

283-
284282
This is explained better with an example:
285283

286284

@@ -303,7 +301,7 @@ Here we have:
303301

304302
* Main test suite with name SpeedometerExample with two metrics: Score and Time.
305303
* The metric "Score" for SpeedometerExample is calculated directly: we take the list of values in current and we calculate the mean (arithmetic mean)
306-
* The metric "Time" for SpeedometerExample is an aggregated value that is calculated using the "Total" agregation algorithm with the values of the subtests.
304+
* The metric "Time" for SpeedometerExample is an aggregated value that is calculated using the "Total" agregation algorithm with the values of the subtests.
307305

308306
* Subtest AngularJS-TodoMV has one metric Time of aggregated value Total with the values of the subtests
309307

@@ -318,20 +316,16 @@ Here we have:
318316
* Subtests Sync has one metric Time with current values: we calculate the mean of the values.
319317

320318

321-
322-
323-
Check the attached file speedometerexample.result that contains the above example, and run:
319+
Check the attached file [sample-files/speedometerexample.result](sample-files/speedometerexample.result) that contains the above example, and run the example script ```read-json-results``` from this directory (```docs``)
324320

325321
* To generate a python dictionary with all the values calculated and print it:
326-
327-
./read-json-results -print-results-dict speedometerexample.result
322+
```pre
323+
./read-json-results -print-results-dict sample-files/speedometerexample.result
324+
```
328325

329326
* To print the results on plain text:
330-
331-
./read-json-results -print-results-text speedometerexample.result
332-
333327
```pre
334-
$ ./read-json-results -print-results-text speedometerexample.result
328+
$ ./read-json-results -print-results-text sample-files/speedometerexample.result
335329
SpeedometerExample:Score: 142.000pt stdev=0.7%
336330
:Time:Total: 674.220ms stdev=9.8%
337331
AngularJS-TodoMVC:Time:Total: 674.220ms stdev=9.8%
@@ -343,11 +337,23 @@ SpeedometerExample:Score: 142.000pt stdev=0.7%
343337
Sync:Time: 429.160ms stdev=12.3%
344338
345339
```
340+
* To print the results on a format like what is inserted into this application database use :
341+
```pre
342+
./read-json-results -print-results-db sample-files/speedometerexample.result
343+
Name=SpeedometerExample Metric=Score\None Unit=pt Value=142.0 Stdev=0.00704225352113
344+
Name=SpeedometerExample Metric=Time\Total Unit=ms Value=674.22 Stdev=0.098284410446
345+
Name=SpeedometerExample\AngularJS-TodoMVC Metric=Time\Total Unit=ms Value=674.22 Stdev=0.098284410446
346+
Name=SpeedometerExample\AngularJS-TodoMVC\Adding100Items Metric=Time\Total Unit=ms Value=217.81 Stdev=0.0290934151339
347+
Name=SpeedometerExample\AngularJS-TodoMVC\Adding100Items\Async Metric=Time\None Unit=ms Value=11.25 Stdev=0.173561103909
348+
Name=SpeedometerExample\AngularJS-TodoMVC\Adding100Items\Sync Metric=Time\None Unit=ms Value=206.56 Stdev=0.0294749686776
349+
Name=SpeedometerExample\AngularJS-TodoMVC\Adding200Items Metric=Time\Total Unit=ms Value=456.41 Stdev=0.136262489719
350+
Name=SpeedometerExample\AngularJS-TodoMVC\Adding200Items\Async Metric=Time\None Unit=ms Value=27.25 Stdev=0.395773479085
351+
Name=SpeedometerExample\AngularJS-TodoMVC\Adding200Items\Sync Metric=Time\None Unit=ms Value=429.16 Stdev=0.122973388375
352+
```
353+
354+
On the ```sample-files``` diretory there are more example of json files that were generated on the bots.
346355

347-
I have attached more json files, this time real ones generated on the bots
348-
that you can run use as input to start programming the application.
349-
You can also use the attached read-json-results script to parse and
350-
process them.
356+
You can use the ```read-json-results``` script in this directory to see how to parse and process them.
351357

352358

353359
Frontend
@@ -411,7 +417,8 @@ Examples of browser performance related graphs:
411417
Format of the JSON files and what to store in the database
412418
-----------------------------------------------------------
413419

414-
I'm not sure what is the best thing to do here.
420+
This are the design considerations that were taken into account when
421+
designing the format for storing the data on the database.
415422

416423
We want the application to be fast. That it can draw the graphs quickly.
417424

@@ -431,7 +438,8 @@ I do this with the "-print-results-dict" output of ./read-json-results.
431438
By using the keyword "None" for real values, and indicating the aggregation
432439
algorithm for the others.
433440

434-
./read-json-results -print-results-dict speedometerexample.result
441+
```pre
442+
./read-json-results -print-results-dict sample-files/speedometerexample.result
435443
436444
{u'SpeedometerExample': {'metrics': {u'Score': {None: {'mean_value': 142.0,
437445
'raw_values': [142.0,
@@ -444,7 +452,7 @@ algorithm for the others.
444452
u'Time': {u'Total': {'mean_value': 674.22,
445453
'raw_values': [642.0,
446454
[....]
447-
455+
```
448456

449457
Here we see:
450458

@@ -453,12 +461,13 @@ Here we see:
453461

454462
The algorithm for aggregation are 3:
455463

464+
```pre
456465
aggregators = {
457466
'Total': (lambda values: sum(values)),
458467
'Arithmetic': (lambda values: sum(values) / len(values)),
459468
'Geometric': (lambda values: math.exp(sum(map(math.log, values)) / len(values))),
460469
}
461-
470+
```
462471

463472
So I think that we can store this on the DB, have an aggregation field that
464473
indicates how the value was generated. For real values we can use a keyword
@@ -473,3 +482,22 @@ We have two options:
473482

474483
* Do this step on the bots, and send to the server the JSON file already calculated.
475484
Something similar to what the command -print-results-dict-json already outputs.
485+
486+
Final implementation:
487+
488+
* On the ```benchmark_results.py``` file the method ```_generate_db_entries``` is used to
489+
format the data from the json files to the database format. You can see it on the screen
490+
by executing the script ```./read-json-results``` from this directory (```docs```) as follows:
491+
492+
```pre
493+
./read-json-results -print-results-db sample-files/speedometerexample.result
494+
Name=SpeedometerExample Metric=Score\None Unit=pt Value=142.0 Stdev=0.00704225352113
495+
Name=SpeedometerExample Metric=Time\Total Unit=ms Value=674.22 Stdev=0.098284410446
496+
Name=SpeedometerExample\AngularJS-TodoMVC Metric=Time\Total Unit=ms Value=674.22 Stdev=0.098284410446
497+
Name=SpeedometerExample\AngularJS-TodoMVC\Adding100Items Metric=Time\Total Unit=ms Value=217.81 Stdev=0.0290934151339
498+
Name=SpeedometerExample\AngularJS-TodoMVC\Adding100Items\Async Metric=Time\None Unit=ms Value=11.25 Stdev=0.173561103909
499+
Name=SpeedometerExample\AngularJS-TodoMVC\Adding100Items\Sync Metric=Time\None Unit=ms Value=206.56 Stdev=0.0294749686776
500+
Name=SpeedometerExample\AngularJS-TodoMVC\Adding200Items Metric=Time\Total Unit=ms Value=456.41 Stdev=0.136262489719
501+
Name=SpeedometerExample\AngularJS-TodoMVC\Adding200Items\Async Metric=Time\None Unit=ms Value=27.25 Stdev=0.395773479085
502+
Name=SpeedometerExample\AngularJS-TodoMVC\Adding200Items\Sync Metric=Time\None Unit=ms Value=429.16 Stdev=0.122973388375
503+
```

docs/read-json-results

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env python
2+
import sys
3+
import os
4+
import json
5+
import argparse
6+
utils_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'dashboard', 'core', 'bots', 'reports', 'utils')
7+
sys.path.append(utils_dir)
8+
from benchmark_results import BenchmarkResults
9+
from pprint import pprint
10+
11+
12+
if __name__ == '__main__':
13+
parser = argparse.ArgumentParser(description='Read the results from the browser based performance benchmarks.')
14+
group = parser.add_mutually_exclusive_group(required=True)
15+
group.add_argument('-cleanfile', dest='clean_file', action='store_true',
16+
help='Rewrite the JSON file without the debugOutput entries.')
17+
group.add_argument('-print-raw', dest='print_raw', action='store_true',
18+
help='Print the JSON file in raw format.')
19+
group.add_argument('-print-results-dict', dest='print_results_dict', action='store_true',
20+
help='Parse the JSON file, generate aggregated results, store them in a dict and print it.')
21+
group.add_argument('-print-results-dict-json', dest='print_results_dict_json', action='store_true',
22+
help='Parse the JSON file, generate aggregated results, store them in a dict, convert to JSON and print it.')
23+
group.add_argument('-print-results-text', dest='print_results_text', action='store_true',
24+
help='Parse the JSON file, generate aggregated results, print them to stdout.')
25+
group.add_argument('-print-results-db', dest='print_results_db', action='store_true',
26+
help='Parse the JSON file, generate aggregated results, and output a format appropiated for the DB.')
27+
group.add_argument('-print-results-db-noaggregated', dest='print_results_db_noaggregated', action='store_true',
28+
help='Parse the JSON file, generate aggregated results, and output a format appropiated for the DB skipping the aggregated results.')
29+
group.add_argument('-print-results-text-scaled', dest='print_results_text_scaled', action='store_true',
30+
help='Parse the JSON file, generate aggregated results, print them to stdout with the metric unit scaled.')
31+
parser.add_argument('json_file', type=str, help='Specify file you want to format')
32+
args = parser.parse_args()
33+
34+
if not os.path.isfile(args.json_file):
35+
print ('ERROR: Cat find the file %s' % args.json_file)
36+
sys.exit(1)
37+
38+
results_json = json.load(open(args.json_file, 'r'))
39+
40+
if 'debugOutput' in results_json:
41+
del results_json['debugOutput']
42+
if args.clean_file:
43+
json.dump(results_json,open(args.json_file, 'w'))
44+
print('Wrote new file without debugOutput: %s ' %args.json_file)
45+
sys.exit(0)
46+
else:
47+
if args.clean_file:
48+
print('File already clean from debugOutput')
49+
sys.exit(0)
50+
51+
if args.print_raw:
52+
pprint(results_json)
53+
sys.exit(0)
54+
55+
# Generate the aggregated results
56+
results = BenchmarkResults(results_json)
57+
58+
if args.print_results_dict:
59+
pprint(results.format_dict())
60+
elif args.print_results_dict_json:
61+
print results.format_json()
62+
elif args.print_results_text:
63+
print results.format(False)
64+
elif args.print_results_text_scaled:
65+
print results.format(True)
66+
elif args.print_results_db:
67+
results.print_db_entries()
68+
elif args.print_results_db_noaggregated:
69+
results.print_db_entries(skip_aggregated=True)
70+
else:
71+
raise RuntimError("This should have not been reached")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"Animometer": {"metrics": {"Score": ["Geometric"]}, "tests": {"Paths": {"metrics": {"Score": {"current": [5800.795054279303]}}}, "Canvas Arcs": {"metrics": {"Score": {"current": [1529.5914541827824]}}}, "Canvas Lines": {"metrics": {"Score": {"current": [6873.021198301258]}}}, "Leaves": {"metrics": {"Score": {"current": [998.5338266024603]}}}, "Focus": {"metrics": {"Score": {"current": [114.31134208429782]}}}, "Suits": {"metrics": {"Score": {"current": [1165.9160558579822]}}}, "Multiply": {"metrics": {"Score": {"current": [817.6559338497497]}}}, "Design": {"metrics": {"Score": {"current": [132.6417027974514]}}}, "Images": {"metrics": {"Score": {"current": [140.60988923798013]}}}}}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"Dromaeo": {"tests": {"DOM Core Tests": {"metrics": {"Runs": {"current": [3402.1613029819678]}}, "tests": {"DOM Modification": {"metrics": {"Runs": {"current": [956.6854850452467]}}, "tests": {"appendChild": {"metrics": {"Runs": {"current": [[2451, 2485, 2487, 2775, 2818]]}}}, "insertBefore": {"metrics": {"Runs": {"current": [[2161, 2192, 2194, 2220, 2451]]}}}, "innerHTML": {"metrics": {"Runs": {"current": [[285.42914171656685, 294.7052947052947, 299.4011976047904, 301, 307]]}}}, "cloneNode": {"metrics": {"Runs": {"current": [[434, 440, 451, 458, 461.53846153846155]]}}}, "createElement": {"metrics": {"Runs": {"current": [[1036, 1055, 1105, 1143.7125748502995, 1150]]}}}, "createTextNode": {"metrics": {"Runs": {"current": [[878, 880, 898, 903, 917.0829170829171]]}}}}}, "DOM Attributes": {"metrics": {"Runs": {"current": [1175.4404688619516]}}, "tests": {"element.expando": {"metrics": {"Runs": {"current": [[651.3486513486514, 665, 673, 676, 676.3236763236763]]}}}, "getAttribute": {"metrics": {"Runs": {"current": [[2862, 2908, 3342, 3350, 3433]]}}}, "setAttribute": {"metrics": {"Runs": {"current": [[890, 890, 893, 901, 907]]}}}, "element.expando = value": {"metrics": {"Runs": {"current": [[289.4211576846307, 349.65034965034965, 352.64735264735265, 360.9172482552343, 378]]}}}, "element.property = value": {"metrics": {"Runs": {"current": [[1065, 1066, 1068, 1069, 1080]]}}}, "element.property": {"metrics": {"Runs": {"current": [[3112, 3120, 4077, 4166, 4233]]}}}}}, "DOM Query": {"metrics": {"Runs": {"current": [38354.1053584363]}}, "tests": {"getElementsByTagName(div)": {"metrics": {"Runs": {"current": [[254920, 256896, 258120, 258123, 260343]]}}}, "getElementsByTagName(*)": {"metrics": {"Runs": {"current": [[257542, 259110, 259930, 260917, 261255]]}}}, "getElementsByName": {"metrics": {"Runs": {"current": [[1547, 1565, 1580, 1713, 1723]]}}}, "getElementsByName (not in document)": {"metrics": {"Runs": {"current": [[5475, 5736, 5771, 5810, 5846]]}}}, "getElementsByTagName(a)": {"metrics": {"Runs": {"current": [[253046, 256726, 258291, 258494, 263442]]}}}, "getElementById (not in document)": {"metrics": {"Runs": {"current": [[5718, 5780, 5811, 5813, 5833]]}}}, "getElementById": {"metrics": {"Runs": {"current": [[1480, 1500, 1501, 1508, 1516]]}}}, "getElementsByTagName(p)": {"metrics": {"Runs": {"current": [[260104, 265495, 267041, 270858, 271925]]}}}, "getElementsByTagName (not in document)": {"metrics": {"Runs": {"current": [[438372, 485741, 492375, 493133, 496124]]}}}}}, "DOM Traversal": {"metrics": {"Runs": {"current": [713.0177669831319]}}, "tests": {"nextSibling": {"metrics": {"Runs": {"current": [[901, 905, 914, 915, 920]]}}}, "lastChild": {"metrics": {"Runs": {"current": [[531, 533.9321357285429, 534, 537, 542]]}}}, "childNodes": {"metrics": {"Runs": {"current": [[764, 804.1958041958042, 815, 819, 827]]}}}, "previousSibling": {"metrics": {"Runs": {"current": [[858, 877, 878, 882.1178821178821, 887]]}}}, "firstChild": {"metrics": {"Runs": {"current": [[528, 529, 537, 539, 541]]}}}}}}}}}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"ES6SampleBench": {"metrics": {"Time": ["Geometric"]}, "tests": {"Air": {"metrics": {"Time": ["Geometric"]}, "tests": {"firstIteration": {"metrics": {"Time": {"current": [107.415, 99.51000000000002, 104.96500000000002, 93.09, 100.35000000000001, 97.72500000000001, 95.08000000000001, 104.81, 99.72999999999999, 92.15, 97.705, 95.2, 107.57000000000002, 98.85500000000002, 97.00500000000001, 88.11500000000001, 104.395, 82.285, 81.72500000000001, 82.57000000000001]}}}, "averageWorstCase": {"metrics": {"Time": {"current": [49.64000000000002, 54.64000000000016, 64.95499999999994, 57.88624999999996, 45.2950000000003, 63.459999999999965, 53.60249999999969, 54.008750000000106, 65.31875000000002, 56.163750000000036, 46.97000000000011, 57.50499999999993, 56.28999999999999, 56.22000000000008, 56.70375000000005, 60.73999999999981, 51.97875000000002, 57.09999999999999, 54.542499999999876, 56.809999999999974]}}}, "steadyState": {"metrics": {"Time": {"current": [6092.549999999999, 6067.549999999998, 6772.594999999993, 6097.7899999999945, 6007.975000000007, 6712.109999999992, 6048.034999999993, 6325.635000000001, 6423.775, 6377.940000000007, 6192.425000000004, 6300.775000000001, 6266.119999999997, 6117.800000000002, 6115.4800000000005, 6106.674999999999, 5993.119999999999, 5959.774999999998, 6011.970000000001, 6085.980000000002]}}}}}, "Basic": {"metrics": {"Time": ["Geometric"]}, "tests": {"firstIteration": {"metrics": {"Time": {"current": [60.06, 62.04000000000001, 63.575, 47.565, 50.89, 48.395, 50.825, 47.980000000000004, 48.83000000000001, 49.905, 52.265, 62.08500000000001, 50.845000000000006, 49.074999999999996, 50.30500000000001, 47.545, 48.47500000000001, 57.97500000000001, 52.21000000000001, 50.86000000000001]}}}, "averageWorstCase": {"metrics": {"Time": {"current": [35.652500000000245, 42.625, 40.2, 36.33124999999984, 59.980000000000246, 42.4699999999999, 39.88499999999987, 40.551249999999754, 38.663750000000164, 39.42999999999985, 56.42500000000007, 44.93875000000021, 33.836250000000064, 36.63749999999994, 43.381249999999625, 41.43250000000003, 34.932499999999806, 35.02374999999996, 46.68375000000011, 33.50374999999976]}}}, "steadyState": {"metrics": {"Time": {"current": [6217.300000000001, 6615.145, 6118.130000000005, 6167.294999999999, 7033.114999999998, 6615.430000000004, 6455.940000000006, 6583.979999999998, 6395.294999999998, 6367.709999999994, 6682.0400000000045, 6401.580000000004, 6240.095, 6144.97, 6165.3250000000035, 6169.5700000000015, 6157.165000000003, 6147.645000000006, 6177.770000000002, 6264.240000000001]}}}}}}}}

0 commit comments

Comments
 (0)