Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 5723d2029c
Fetching contributors…

Cannot retrieve contributors at this time

188 lines (157 sloc) 5.984 kB
<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="report.js"></script>
<script type="text/javascript">
function drawChart() {
var builds = travisdata();
var masterBuilds = builds.filter(function(build) {
return build.branch == "master";
});
var passed = masterBuilds.filter(function(build) {
return build.matrix.every(function(m) {
return m.status == 0;
});
}).sort(function(l, r) {
return parseInt(l.number) - parseInt(r.number);
});
var title = document.getElementById('header');
title.innerText = "Charts for the past " + passed.length + " passing builds";
var from = document.getElementById('date-from');
from.innerText = "From: " + passed[0].started_at;
var to = document.getElementById('date-to');
to.innerText = "To: " + passed[passed.length - 1].started_at;
all(passed);
passed[0].matrix.map(function(m) {
var env = m.config.env.split('=', 2)[1];
chart(passed, env, 10);
});
}
function groupBy(list, func) {
var groups = {};
list.forEach(function(item) {
var key = func(item);
if(!groups[key]) groups[key] = []
groups[key].push(item);
});
return groups;
}
function all(builds) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Build');
var buildIds = builds.map(function(build) {
return build.number;
});
var matrices = builds.map(function(build) {
return build.matrix;
}).reduce(function(x, y){ return x.concat(y); });
var buildGroups = groupBy(matrices, function(matrix) {
return matrix.config.env;
});
// Add the columns
Object.keys(buildGroups).forEach(function(key) {
data.addColumn('number', key);
});
builds.forEach(function(build) {
var times = build.matrix.map(function(matrix) {
var start = Date.parse(matrix.started_at);
var finish = Date.parse(matrix.finished_at);
return (finish - start) / 1000;
});
times.unshift(build.number);
data.addRow(times);
});
// Set chart options
var options = chartOptions('Test Time for master on TravisCI');
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.LineChart(document.getElementById('all'));
chart.draw(data, options);
}
function chart(builds, name, avg) {
var data = new google.visualization.DataTable();
var elementId = name.replace(/[,:]/g, '_');
data.addColumn('string', 'Build');
data.addColumn('number', name);
data.addColumn('number', 'avg(' + avg + ')');
var buildIds = builds.map(function(build) {
return build.number;
});
var times = builds.map(function(build) {
var matrix = build.matrix.filter(function(matrix) {
return matrix.config.env == ("GEM=" + name);
})[0];
var start = Date.parse(matrix.started_at);
var finish = Date.parse(matrix.finished_at);
return (finish - start) / 1000;
});
var avgs = movingAvg(times, avg);
for(var i = 0; i < times.length; i++) {
data.addRow([buildIds[i], times[i], avgs[i]]);
}
// Set chart options
var options = chartOptions('Test Time for ' + name + ' on TravisCI');
options.title += ' (mean: ' +
mean(times) + ', stddev: ' + stddev(times) + ')';
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.LineChart(document.getElementById(elementId));
chart.draw(data, options);
}
function mean(numbers) {
return numbers.reduce(function(a, b) {
return a + b;
}) / numbers.length;
}
function stddev(numbers) {
var m = mean(numbers);
var square_deviations = numbers.map(function(number) {
return Math.pow(number - m, 2);
});
var square_sum = square_deviations.reduce(function(a, b) {
return a + b;
});
return Math.sqrt(square_sum / (numbers.length - 1));
}
function eachCons(collection, length, cb) {
var list = []
for(var i = 0; i + length <= collection.length; i++) {
list.push(cb(collection.slice(i, i + length)));
}
return list;
}
function movingAvg(numbers, length) {
var avgs = eachCons(numbers, length, function(slice) {
return slice.reduce(function(a, b) { return a + b; }) / length;
});
for(var i = length - 1; i > 0; i--) {
avgs.unshift(null);
}
return avgs;
}
function chartOptions(title) {
return { 'title': title,
'width':1000,
'height':300,
'legend': { 'position': 'bottom' },
'hAxis': { 'title': 'Build ID' },
'vAxis': { 'title': 'Seconds' } };
}
google.load('visualization', '1.0', {'packages':['corechart']});
google.load("jquery", "1.7.1");
google.setOnLoadCallback(drawChart);
</script>
</head>
<body>
<h1 id="header"></h1>
<h2 id="date-from"></h2>
<h2 id="date-to"></h2>
<a href="http://github.com/tenderlove/railschart">Generated by this thing</a>
<div id="all"></div>
<div id="railties"></div>
<div id="ap_am_amo_ares_as"></div>
<div id="ar_sqlite3"></div>
<div id="ar_mysql2"></div>
<div id="ar_mysql"></div>
<div id="ar_postgresql"></div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.