System and Method for Energy Profiling Asynchronous API Calls
First Claim
1. A method for profiling energy usage of invoking an application programming interface (API) by an application in a computing device, comprising:
- obtaining source code “
A”
for the API;
identifying each class Ci in the A for the API that contains a callback function Di;
modifying each Ci by adding a callback function identifier field that is initiated to a unique value Vj upon instantiation of each object Oj that belongs to class Ci;
identifying each location Ek in the A that posts the callback function Di for asynchronous execution by enqueueing object Oj instantiated from the Ci containing the callback function Di into the system callback queue;
modifying the A at location Ek by adding a logging function call L to log the callback function identifier Vj and the current call stack into the energy profiling log;
obtaining source code B in the operating system/framework that asynchronously executes any D passed from the API;
identifying each location F in the B that invokes the callback function associated with any object dequeued from the system callback queue;
modifying the B at the F by adding logging function calls L before and after the callback function invocation to log the callback function identifier Vj of the dequeued object when we start and finish executing the callback function respectively to the energy profiling log;
executing the application thereby generating one or two threads, wherein the first thread executes the API call that posts the callback function Di and wherein the second thread which can be the same as the first thread dequeues the callback function Di and invokes the callback function Di;
determining the caller-caller relationship between the function in the API execution stack that posted each Di and the asynchronously invoked callback function by processing the logged callback function ID information and call stack information in the energy profiling log;
determining the energy usage of invoking the API call in thread 1, by monitoring activities of a processor, the processor operating any component that consumes power in the computing device in response to execution of the API;
determining the energy usage of invoking each callback function in thread 2, by monitoring activities of a processor, the processor operating any component that consumes power in the computing device in response to execution of the callback function;
adding the energy usage of invoking every callback function in thread 2 to the energy usage of invoking the API thus determined; and
attributing the combined energy to the API invocation.
1 Assignment
0 Petitions
Accused Products
Abstract
A method for profiling energy usage of invoking an application programming interface (API) by an application in a computing device. The method includes obtaining source code for the API, modifying each class by adding a callback function identifier field that is initiated to a unique value upon instantiation of each object that belongs to the class, identifying each location in the source code that posts the callback function for asynchronous execution by enqueueing each object instantiated from the class containing the callback function into the system callback queue, modifying the source code to log the callback function identifier of object at the location that dequeues objects from the system callback queue, modifying source code by adding two system logging function calls to log the callback function identifier of the dequeued object before and after executing the callback function, executing the application, and performing energy accounting of the asynchronous API calls.
-
Citations
1 Claim
-
1. A method for profiling energy usage of invoking an application programming interface (API) by an application in a computing device, comprising:
-
obtaining source code “
A”
for the API;identifying each class Ci in the A for the API that contains a callback function Di; modifying each Ci by adding a callback function identifier field that is initiated to a unique value Vj upon instantiation of each object Oj that belongs to class Ci; identifying each location Ek in the A that posts the callback function Di for asynchronous execution by enqueueing object Oj instantiated from the Ci containing the callback function Di into the system callback queue; modifying the A at location Ek by adding a logging function call L to log the callback function identifier Vj and the current call stack into the energy profiling log; obtaining source code B in the operating system/framework that asynchronously executes any D passed from the API; identifying each location F in the B that invokes the callback function associated with any object dequeued from the system callback queue; modifying the B at the F by adding logging function calls L before and after the callback function invocation to log the callback function identifier Vj of the dequeued object when we start and finish executing the callback function respectively to the energy profiling log; executing the application thereby generating one or two threads, wherein the first thread executes the API call that posts the callback function Di and wherein the second thread which can be the same as the first thread dequeues the callback function Di and invokes the callback function Di; determining the caller-caller relationship between the function in the API execution stack that posted each Di and the asynchronously invoked callback function by processing the logged callback function ID information and call stack information in the energy profiling log; determining the energy usage of invoking the API call in thread 1, by monitoring activities of a processor, the processor operating any component that consumes power in the computing device in response to execution of the API; determining the energy usage of invoking each callback function in thread 2, by monitoring activities of a processor, the processor operating any component that consumes power in the computing device in response to execution of the callback function; adding the energy usage of invoking every callback function in thread 2 to the energy usage of invoking the API thus determined; and attributing the combined energy to the API invocation.
-
Specification