A New Perspective Towards a Greener Future

Reyhaneh JabbarvandCell phones and batteries are a part of our everyday life. While energy is a major concern for users, many mobile apps still abound with energy defects and developers find it difficult to properly evaluate the energy behavior of their programs. The root cause of this issue is that there is a lack of tools and techniques aimed at addressing energy concerns. In the mobile setting, reasoning about energy properties of software is further complicated by the fact that such defects manifest themselves under peculiar conditions that depend not only on the source code of the app, but also on the framework, context of usage, and properties of the underlying hardware elements. The best way to assess the impact of these contextual factors on an app’s energy behavior is through dynamic program analysis i.e., testing.

Recent Ph.D. graduate Reyhaneh Jabbarvand’s research in the past five years has leveraged program analysis, AI, mathematical optimization, and data science, in order to advance the state of energy testing for mobile applications. In the preliminary steps of this research, through a novel utilization of mutation testing, Jabbarvand discovered that many energy defects depend on the execution context and manifest themselves under peculiar conditions. That said, the main objective of existing Android test generation approaches is maximizing conventional code coverage metrics and they do not consider the contextual factor into account. Thereby, there is a need to devise an energy testing technique.

An overview of the Cobweb framework.One of Jabbarvand’s recent projects, called Cobweb, employs a search-based evolutionary algorithm to generate event sequences that can identify energy defects. Cobweb uses a novel set of two genetic operators and four model types for generating the event sequences: (1) a model of the possible transitions between components in the app; (2) call graphs representing the internal behavior of each component; (3) state machines representing the possible lifecycle states of each component; and (4) a state machine representing the possible states of the hardware components. The evolutionary algorithm favors test suites based on event sequences that cover energy-greedy APIs and that help exercise different contextual factors. Extensive evaluation of the technique using real-world Android apps with confirmed energy defects demonstrated not only its ability to effectively and efficiently test energy behavior of apps, but also its superiority over state-of-the-art and state-of-the-practice Android testing techniques by finding a wider and more diverse set of energy defects.

Energy testing is not complete without an automated test oracle. Test oracle automation is one of the most challenging facets of testing and, in fact, is a much harder problem to solve for energy testing. Specifically, in contrast to functional defects where their impact is almost explicit as a test terminates, e.g. a crash, it may take several hours, days, or even weeks until developers or users realize that an app drains the phone’s battery. Hence, an energy oracle should be able to determine the outcome of tests by monitoring for certain patterns in the state of software and hardware elements during test execution. The challenge here lies in the fact that determining such patterns is exceptionally cumbersome and requires deep knowledge of energy defects. Furthermore, new types of energy defects may emerge, as mobile platforms evolve, making it impractical to manually derive such patterns.

A high-level overview of the energy oracle construction.Jabbarvand’s solution for this problem employs Deep Learning to learn the (mis)behaviors corresponding to the different types of energy defects. The technique represents the state of software and hardware elements in the form of a feature vector and the learning component uses Long Short-Term Memory (LSTM) Neural Networks to construct an oracle for energy testing. Furthermore, the technique leverages Attention mechanism to interpret the model. Specifically, this technique performs additional analysis on the Attention layer’s product, i.e., Attention weights, to identify a set of features that the model has focused on to predict a label for a given test. If such features for a failing test belong to the state of a hardware that is misused by an energy defect, the validity of the model can be verified. An extensive empirical evaluation demonstrated that the technique is (1) highly effective–achieves an overall precision and recall of 99%, (2) capable of detecting unseen energy defects, (3) interpretable and valid, (4) reusable across a variety of apps and devices, and (5) efficient–detects the existence of energy defects in only 37 milliseconds on average.

Jabbarvand’s plans for the future are to go beyond energy testing to ensure energy efficiency of software. Specifically, she aims to first enable energy debugging, to help developers understand where energy defects happen in the code, and then automatically fix energy inefficiencies in the code through automated program repair.

Jabbarvand will join the University of Illinois at Urbana-Champaign as an Assistant Professor in the Department of Computer Science in January 2021. She received her Ph.D. in May 2020 under the supervision of Professor Sam Malek. She was a recipient of the Google Ph.D. Fellowship in Program Technology and Software Engineering in 2018, and has been recognized as a Rising Star in EECS.

To find out more about Jabbarvand, visit her website. Jabbarvand can be reached at:

This article appeared in ISR Connector issue: