
This re-adds the Tempest timeline view as a set of Angular directives. This includes related functionality, such as the Dstat parser and some array utilities. The timeline view consists of a timeline component, which includes the d3 chart, and a separate details component, which shows additional information for tests when selected in the timeline. Change-Id: Ifaaeda91b0617e8cf7a60d30728005f5c8d00546
59 lines
1.1 KiB
JavaScript
59 lines
1.1 KiB
JavaScript
var binaryMinIndex = function(min, array, func) {
|
|
"use strict";
|
|
|
|
var left = 0;
|
|
var right = array.length - 1;
|
|
|
|
while (left < right) {
|
|
var mid = Math.floor((left + right) / 2);
|
|
|
|
if (min < func(array[mid])) {
|
|
right = mid - 1;
|
|
} else if (min > func(array[mid])) {
|
|
left = mid + 1;
|
|
} else {
|
|
right = mid;
|
|
}
|
|
}
|
|
|
|
if (left >= array.length) {
|
|
return array.length - 1;
|
|
} else if (func(array[left]) <= min) {
|
|
return left;
|
|
} else {
|
|
return left - 1;
|
|
}
|
|
};
|
|
|
|
var binaryMaxIndex = function(max, array, func) {
|
|
"use strict";
|
|
|
|
var left = 0;
|
|
var right = array.length - 1;
|
|
|
|
while (left < right) {
|
|
var mid = Math.floor((left + right) / 2);
|
|
|
|
if (max < func(array[mid])) {
|
|
right = mid - 1;
|
|
} else if (max > func(array[mid])) {
|
|
left = mid + 1;
|
|
} else {
|
|
right = mid;
|
|
}
|
|
}
|
|
|
|
if (right < 0) {
|
|
return 0;
|
|
} else if (func(array[right]) <= max) {
|
|
return right + 1; // exclusive index
|
|
} else {
|
|
return right;
|
|
}
|
|
};
|
|
|
|
module.exports = {
|
|
binaryMinIndex: binaryMinIndex,
|
|
binaryMaxIndex: binaryMaxIndex
|
|
};
|