Skip to content

Commit

Permalink
Merge pull request elastic#8 from colings86/feature/addCommitInfo
Browse files Browse the repository at this point in the history
Add click data point to compare commits on github to benchmark charts
  • Loading branch information
danielmitterdorfer authored Sep 1, 2016
2 parents 278912b + b51663f commit 9564acf
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 18 deletions.
53 changes: 40 additions & 13 deletions external/pages/assets/js/charts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var chartingLib = {
createOpts: function(title, labelsDiv, yLabel) {
createOpts: function(title, labelsDiv, yLabel, commits) {
return { "title": title,
"colors": ["#00BFB3", "#FED10A", "#0078A0", "#DF4998", "#93C90E", "#00A9E5", "#222", "#AAA", "#777"],
"axisLabelColor": "#555",
Expand All @@ -15,24 +15,51 @@ var chartingLib = {
"legend": "always",
"drawPoints": true,
"pointSize": 3,
"gridLineColor": "#BBB"
"gridLineColor": "#BBB",
pointClickCallback: function(e, p) {
var commitInfo = commits[p.xval];
if (commitInfo) {
var url = "https://github.com/elastic/elasticsearch/compare/" + commitInfo.prev_commit + "..." + commitInfo.this_commit;
window.open(url);
}
}
//"strokePattern": [5, 10]
}
},

renderChart: function(elementId, title, yLabel, annotationSource) {
var g = new Dygraph(
document.getElementById("chart_" + elementId),
elementId + ".csv",
this.createOpts("<a href='#" + elementId + "'>" + title + "</a>", "chart_" + elementId + "_labels", yLabel)
);
g.ready(function() {
var annotationSource = elementId + '_annotations.json'
$.getJSON(annotationSource, function(json) {
g.setAnnotations(json);
});
var commits = {};
var g = new Dygraph(
document.getElementById("chart_" + elementId),
elementId + ".csv",
this.createOpts("<a href='#" + elementId + "'>" + title + "</a>", "chart_" + elementId + "_labels", yLabel, commits)
);
g.ready(function() {
var annotationSource = elementId + '_annotations.json'
$.getJSON(annotationSource, function(json) {
g.setAnnotations(json);
});
return g;
$.ajax({
type: 'GET',
url: 'source_revision.csv',
dataType: 'text',
success: function(allText) {
var allTextLines = allText.split(/\r\n|\n/);

var previousCommit = null;
for (var i=1; i<allTextLines.length; i++) {
var data = allTextLines[i].split(',');
var date = new Date(data[0]);
commits[date.getTime()] = {
this_commit: data[1],
prev_commit: previousCommit
};
previousCommit = data[1];
}
}
});
});
return g;
},

synchronize: function(graphs) {
Expand Down
8 changes: 6 additions & 2 deletions external/pages/geonames/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,18 @@ <h3>Overview</h3>
<a href="https://elasticsearch-benchmark-analytics.elastic.co/app/kibana#/dashboard/Nightly-Benchmark-Overview">Kibana dashboard</a>.</p>
</div>
</div>

<div class="row">
<div class="col-md-6">
<h3>Results</h3>
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>Hint</strong> Click and drag to zoom. Double-click to zoom out.
</div>
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>Hint</strong> Click a data point to see the diff between it and the previous race.
</div>
</div>
</div>

Expand Down Expand Up @@ -195,7 +199,7 @@ <h3>Results</h3>
<div id="chart_segment_counts_labels"></div>
</div>
<div class="col-md-10 col-md-pull-2">
<a name="segment_counts" id="segment_counts"></a>
<a name="segment_counts" id="segment_counts"></a>
<div id="chart_segment_counts" class="benchmark-chart"></div>
</div>
</div>
Expand Down
6 changes: 5 additions & 1 deletion external/pages/geopoint/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ <h3>Results</h3>
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>Hint</strong> Click and drag to zoom. Double-click to zoom out.
</div>
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>Hint</strong> Click a data point to see the diff between it and the previous race.
</div>
</div>
</div>

Expand Down Expand Up @@ -180,7 +184,7 @@ <h3>Results</h3>
<div id="chart_segment_counts_labels"></div>
</div>
<div class="col-md-10 col-md-pull-2">
<a name="segment_counts" id="segment_counts"></a>
<a name="segment_counts" id="segment_counts"></a>
<div id="chart_segment_counts" class="benchmark-chart"></div>
</div>
</div>
Expand Down
6 changes: 5 additions & 1 deletion external/pages/percolator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ <h3>Results</h3>
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>Hint</strong> Click and drag to zoom. Double-click to zoom out.
</div>
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>Hint</strong> Click a data point to see the diff between it and the previous race.
</div>
</div>
</div>

Expand Down Expand Up @@ -174,7 +178,7 @@ <h3>Results</h3>
<div id="chart_segment_counts_labels"></div>
</div>
<div class="col-md-10 col-md-pull-2">
<a name="segment_counts" id="segment_counts"></a>
<a name="segment_counts" id="segment_counts"></a>
<div id="chart_segment_counts" class="benchmark-chart"></div>
</div>
</div>
Expand Down
6 changes: 5 additions & 1 deletion external/pages/pmc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ <h3>Results</h3>
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>Hint</strong> Click and drag to zoom. Double-click to zoom out.
</div>
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>Hint</strong> Click a data point to see the diff between it and the previous race.
</div>
</div>
</div>

Expand Down Expand Up @@ -180,7 +184,7 @@ <h3>Results</h3>
<div id="chart_segment_counts_labels"></div>
</div>
<div class="col-md-10 col-md-pull-2">
<a name="segment_counts" id="segment_counts"></a>
<a name="segment_counts" id="segment_counts"></a>
<div id="chart_segment_counts" class="benchmark-chart"></div>
</div>
</div>
Expand Down
35 changes: 35 additions & 0 deletions night_rally.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ def v(d, k):
"Merge time \(.*": "merge_time_parts"
}

META_METRICS_TO_KEY = {
"Elasticsearch source revision": "source_revision"
}


def is_default_setup(default_setup, current_setup):
current_challenge, current_car = current_setup
Expand Down Expand Up @@ -218,6 +222,11 @@ def key_for(metric_pattern, metric_key, metric_name, op_name):
return metric_key
return None

def meta_key_for(metric_pattern, metric_key, metric_name):
if re.match(metric_pattern, metric_name):
return metric_key
return None


def extract_metrics(source_report):
metrics = {}
Expand All @@ -237,6 +246,22 @@ def extract_metrics(source_report):
metrics[final_key] = metric_value
return metrics

def extract_meta_metrics(source_meta_report):
meta_metrics = {}
for row in csv.reader(source_meta_report):
for metric_pattern, metric_key in META_METRICS_TO_KEY.items():
metric_name = row[0]
metric_value = row[1]
final_key = meta_key_for(metric_pattern, metric_key, metric_name)
if final_key:
if is_multi_valued(final_key):
if final_key not in meta_metrics:
meta_metrics[final_key] = []
meta_metrics[final_key].append(metric_value)
else:
meta_metrics[final_key] = metric_value
return meta_metrics


def report(effective_start_date, tracks, default_setup_per_track):
"""
Expand All @@ -263,6 +288,7 @@ def report(effective_start_date, tracks, default_setup_per_track):
challenge, car = setup
current_is_default = is_default_setup(default_setup_per_track[track], setup)
report_path = "%s/%s/rally/%s/%s/%s/%s/report.csv" % (root_dir, report_root_dir, timestamp, track, challenge, car)
meta_report_path = "%s/%s/rally/%s/%s/%s/%s/report.csv.meta" % (root_dir, report_root_dir, timestamp, track, challenge, car)

if not os.path.isfile(report_path):
logger.warn("[%s] does not exist. Skipping track [%s], challenge [%s], car [%s]."
Expand Down Expand Up @@ -326,6 +352,15 @@ def report(effective_start_date, tracks, default_setup_per_track):
with open("%s/merge_parts.csv" % output_report_path, "a") as f:
f.write("%s,%s\n" % (report_timestamp, ",".join(metrics["merge_time_parts"])))



with open(meta_report_path) as csvfile:
meta_metrics = extract_meta_metrics(csvfile)

if "source_revision" in metrics:
with open("%s/source_revision.csv" % output_report_path, "a") as f:
f.write("%s,%s\n" % (report_timestamp, ",".join(metrics["source_revision"])))

if len(segment_count_metrics) > 0:
with open("%s/segment_counts.csv" % output_report_path, "a") as f:
f.write("%s,%s\n" % (report_timestamp, ",".join(segment_count_metrics)))
Expand Down
6 changes: 6 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@
99.0th percentile service time,painless_static,13.627798499919663,ms
100th percentile service time,painless_static,13.649789999817585,ms"""

EXAMPLE_META_REPORT = """Name,Value
Elasticsearch source revision,247cafe"""

class RecordingSystemCall:
def __init__(self, return_value):
Expand Down Expand Up @@ -250,6 +252,10 @@ def test_extract_metrics(self):
self.assertEqual("8.401418720027323", metrics["latency_nodes_stats_p99"])
self.assertEqual(["260", "362", "327", "7", "306", "553", "12", "13"], metrics["query_latency_p99"])

def test_extract_meta_metrics(self):
metrics = night_rally.extract_meta_metrics(EXAMPLE_META_REPORT.split("\n"))
self.assertEqual("247cafe", metrics["source_revision"])


if __name__ == '__main__':
unittest.main()

0 comments on commit 9564acf

Please sign in to comment.