use of com.android.tools.adtui.model.Range in project android by JetBrains.
the class CpuMonitorTest method testOtherProcessesCpuUsage.
@Test
public void testOtherProcessesCpuUsage() throws IOException {
CpuUsageDataSeries series = myMonitor.getOtherProcessesCpuUsage();
ImmutableList<SeriesData<Long>> seriesDataList = series.getDataForXRange(new Range());
// Only other processes information.
assertEquals(1, seriesDataList.size());
SeriesData<Long> seriesData = seriesDataList.get(0);
assertNotNull(seriesData);
assertEquals(40, (long) seriesData.value);
}
use of com.android.tools.adtui.model.Range in project android by JetBrains.
the class CpuMonitorTest method testThisProcessCpuUsage.
@Test
public void testThisProcessCpuUsage() throws IOException {
CpuUsageDataSeries series = myMonitor.getThisProcessCpuUsage();
ImmutableList<SeriesData<Long>> seriesDataList = series.getDataForXRange(new Range());
// Only current process information.
assertEquals(1, seriesDataList.size());
SeriesData<Long> seriesData = seriesDataList.get(0);
assertNotNull(seriesData);
assertEquals(20, (long) seriesData.value);
}
use of com.android.tools.adtui.model.Range in project android by JetBrains.
the class AnimatedTimeline method animate.
@Override
public void animate(float frameLength) {
if (!myTimeline.isStreaming()) {
return;
}
// Advances time by frameLength (up to current data max - buffer)
float frameLengthUs = frameLength * TimeUnit.SECONDS.toMicros(1);
Range viewRange = myTimeline.getViewRange();
double viewMaxUs = viewRange.getMax();
double deltaUs = myTimeline.clampToDataRange(viewMaxUs + frameLengthUs) - viewMaxUs;
viewRange.shift(deltaUs);
}
use of com.android.tools.adtui.model.Range in project android by JetBrains.
the class TopDownTreeModel method update.
@Override
public void update(@NotNull Range range) {
DefaultMutableTreeNode root = (DefaultMutableTreeNode) getRoot();
List<Range> diffs = new LinkedList<>();
// Add all the newly added ranges.
diffs.addAll(range.subtract(myRange));
// Add the ranges we don't have anymore
diffs.addAll(myRange.subtract(range));
update(root, range, diffs);
myRange.set(range);
}
use of com.android.tools.adtui.model.Range in project android by JetBrains.
the class LineChart method updateData.
@Override
protected void updateData() {
Map<Range, Double> max = new HashMap<>();
// TODO Handle stacked configs
for (RangedContinuousSeries ranged : myLinesConfig.keySet()) {
Range range = ranged.getYRange();
double yMax = Double.MIN_VALUE;
ImmutableList<SeriesData<Long>> seriesList = ranged.getSeries();
for (int i = 0; i < seriesList.size(); i++) {
double value = seriesList.get(i).value;
if (yMax < value) {
yMax = value;
}
}
Double m = max.get(range);
max.put(range, m == null ? yMax : Math.max(yMax, m));
}
for (Map.Entry<Range, Double> entry : max.entrySet()) {
Range range = entry.getKey();
// Prevent the LineChart to update the range below its current max.
if (range.getMax() < entry.getValue()) {
float fraction = myFirstUpdate ? 1f : DEFAULT_LERP_FRACTION;
range.setMax(Choreographer.lerp(range.getMax(), entry.getValue(), fraction, mFrameLength, (float) (entry.getValue() * DEFAULT_LERP_THRESHOLD_PERCENTAGE)));
}
}
myFirstUpdate = false;
}
Aggregations