def _test_behaviour(self, signal_name, error_margin_pct): task = self.task_name phase = self.wlgen_task.phases[0] df = self.get_simulated_pelt(task, signal_name) cpus = sorted(phase['cpus']) assert len(cpus) == 1 cpu = cpus[0] expected_duty_cycle_pct = phase['wload'].unscaled_duty_cycle_pct(self.plat_info) expected_final_util = expected_duty_cycle_pct / 100 * UTIL_SCALE settling_time = pelt_settling_time(10, init=0, final=expected_final_util) settling_time += df.index[0] df = df[settling_time:] # Instead of taking the mean, take the average between the min and max # values of the settled signal. This avoids the bias introduced by the # fact that the util signal stays high while the task sleeps settled_signal_mean = kernel_util_mean(df[signal_name], plat_info=self.plat_info) expected_signal_mean = expected_final_util signal_mean_error_pct = abs(expected_signal_mean - settled_signal_mean) / UTIL_SCALE * 100 res = ResultBundle.from_bool(signal_mean_error_pct < error_margin_pct) res.add_metric('expected mean', expected_signal_mean) res.add_metric('settled mean', settled_signal_mean) res.add_metric('settled mean error', signal_mean_error_pct, '%') self._plot_pelt(task, signal_name, df['simulated'], 'behaviour') res = self._add_cpu_metric(res) return res
from lisa.tests.base import (Result, ResultBundle, AggregatedResultBundle, TestBundleBase, TestBundle, RTATestBundle) from lisa.target import Target from lisa.utils import ArtifactPath, ExekallTaggable, groupby, kwargs_forwarded_to, memoized from lisa.datautils import df_refit_index, series_dereference, series_mean from lisa.wlgen.rta import PeriodicWload, RTAPhase from lisa.trace import MissingTraceEventError from lisa.analysis.load_tracking import LoadTrackingAnalysis from lisa.analysis.tasks import TasksAnalysis from lisa.pelt import PELT_SCALE, simulate_pelt, pelt_settling_time, kernel_util_mean from lisa.notebook import plot_signal UTIL_SCALE = PELT_SCALE UTIL_CONVERGENCE_TIME_S = pelt_settling_time(1, init=0, final=1024) """ Time in seconds for util_avg to converge (i.e. ignored time) """ class LoadTrackingHelpers: """ Common bunch of helpers for load tracking tests. """ MAX_RTAPP_CALIB_DEVIATION = 3 / 100 """ Ignore CPUs that have a RTapp calibration value that deviates too much from the average calib value in their capacity class. """