package com.airbnb.lottie; import com.airbnb.lottie.utils.MeanCalculator; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import o.uOF; import o.wnv; /* loaded from: classes.dex */ public class PerformanceTracker { private boolean enabled = false; private final Set frameListeners = new wnv(); private final Map layerRenderTimes = new HashMap(); private final Comparator> floatComparator = new Comparator>(this) { // from class: com.airbnb.lottie.PerformanceTracker.1 final PerformanceTracker this$0; { this.this$0 = this; } @Override // java.util.Comparator public int compare(uOF uof, uOF uof2) { float floatValue = uof.b.floatValue(); float floatValue2 = uof2.b.floatValue(); if (floatValue2 > floatValue) { return 1; } return floatValue > floatValue2 ? -1 : 0; } }; /* loaded from: classes.dex */ public interface FrameListener { void onFrameRendered(float f); } public void recordRenderTime(String str, float f) { if (this.enabled) { MeanCalculator meanCalculator = this.layerRenderTimes.get(str); if (meanCalculator == null) { meanCalculator = new MeanCalculator(); this.layerRenderTimes.put(str, meanCalculator); } meanCalculator.add(f); if (str.equals("__container")) { Iterator it = this.frameListeners.iterator(); while (it.hasNext()) { it.next().onFrameRendered(f); } } } } public void addFrameListener(FrameListener frameListener) { this.frameListeners.add(frameListener); } public void removeFrameListener(FrameListener frameListener) { this.frameListeners.remove(frameListener); } public void clearRenderTimes() { this.layerRenderTimes.clear(); } public void logRenderTimes() { if (this.enabled) { List> sortedRenderTimes = getSortedRenderTimes(); for (int i = 0; i < sortedRenderTimes.size(); i++) { uOF uof = sortedRenderTimes.get(i); new Object[]{uof.d, uof.b}; } } } public List> getSortedRenderTimes() { if (!this.enabled) { return Collections.emptyList(); } ArrayList arrayList = new ArrayList(this.layerRenderTimes.size()); for (Map.Entry entry : this.layerRenderTimes.entrySet()) { arrayList.add(new uOF(entry.getKey(), Float.valueOf(entry.getValue().getMean()))); } Collections.sort(arrayList, this.floatComparator); return arrayList; } /* JADX INFO: Access modifiers changed from: package-private */ public void setEnabled(boolean z) { this.enabled = z; } }