manafa package¶
Subpackages¶
Submodules¶
manafa.emanafa module¶
- class manafa.emanafa.EManafa(power_profile=None, timezone=None, resources_dir='/Users/ruirua/repos/emanafa/manafa/resources')[source]¶
Bases:
manafa.services.service.Service
Main class that abstracts all the modules and steps of the profiling procedure
- resources_dir¶
directory where aux resources are contained
- power_profile¶
the power profile to be used in the profiling sessions
- boot_time¶
device’s last boot timestamp
- batterystats¶
batterystats service
- perfetto¶
perfetto service
- timezone¶
device timezone
- unplugged¶
if the device is not charging
- bat_events¶
Batterystats parser
- pft_out_file¶
perfetto service output file
- bts_out_file¶
batterystats output file
- calculate_cpu_energy(start_time, end_time)[source]¶
calculates cpu energy consumption of device between a timestamp interval :param start_time: begin timestamp :param end_time: end timestamp
- Returns
cpu energy consumption
- Return type
total
- calculate_glob_and_component_consumption(last_event, per_component_consumption, delta_time, total)[source]¶
retrieves the global and per-component consumption of a state that lasts delta_time. :param last_event: the event containing the last state. :param per_component_consumption: per_component consumption so far. :param delta_time: duration of the state. :param total: total consumption so far.
- Returns
total consumed (at device level). per_component_consumption(dict): consumption per device component.
- Return type
total(float)
- calculate_non_cpu_energy(start_time, end_time)[source]¶
Obtains energy consumption of device between a timestamp interval for every component except cpu. for cpu component, it stores only the state recorded in battarystats. :param start_time: begin timestamp. :param end_time: end timestamp.
- Returns
system-level energy consumption without cpu energy consumption. per_component: per-component energy consumption without cpu energy consumption.
- Return type
total
- get_consumption_in_between(start_time=0, end_time=9223372036854775807)[source]¶
retrieves energy consumption and device events between a timestamp interval.
- Parameters
start_time – begin timestamp.
end_time – end timestamp.
- Returns
system-level energy consumption. per_component(dict): per-component energy consumption. metrics(dict): batterystats info containing events occurred during the interval. for each type of event, it presents.
- Return type
total(float)
- infer_power_profile()[source]¶
picks the most appropriate power profile file. power profile files present in self.resources_dir contains a device model id in the filename, which is determinated by ro.product.model property. if there is an adequate file locally, it retrieves such filename. Otherwise, it extracts the profile from the device using __extractPowerProfile.
- Returns
the name of the xml file.
- Return type
filename
- parse_results(bts_file=None, pf_file=None)[source]¶
parses results from output results files of perfetto and batterystats services. :param bts_file: batterystats output file. if none, uses self.bts_out_file :param pf_file: perfetto output file. if none, uses self.pft_out_file
- manafa.emanafa.get_last_boot_time(bts_file=None)[source]¶
Retrieves timestamp of device last boot, either from the batterystats output filename that contains that info or the device itself.
- Parameters
bts_file (str) – filename or filename, whose filename contains the boot time of the respective session where it was
recorded. –
- Returns
secs.ms.
- Return type
timestamp(float)
manafa.hunter_emanafa module¶
- class manafa.hunter_emanafa.HunterEManafa(power_profile=None, timezone=None, resources_dir='/Users/ruirua/repos/emanafa/manafa/resources', instrument_file=None, not_instrument_file=None)[source]¶
Bases:
manafa.emanafa.EManafa
Class that extends default framework behaviour, allowing to parse app traces from logcat using LogService and estimate battery consumption of app components. it is designed to consider method traces, but it can be used to parse and estimate consumption of source code at other granularity levels.
- resources_dir¶
directory where aux resources are contained.
- power_profile¶
the power profile to be used in the profiling sessions.
- timezone¶
device timezone.
- unplugged¶
if the device is not charging.
- calculate_function_consumption()[source]¶
calculates consumption per function called during the profiling session.