Hayri Acar

Gülfem I Alptekin

Jean-Patrick Gelas

Parisa Ghodous

TEEC: Improving power consumption estimation of software

à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d'enseignement et de recherche français ou étrangers, des laboratoires publics ou privés.

Introduction

Recently, researchers have begun to give importance at the energy consumed by software. But, to solve this problem, they propose often a hardware study of different devices. For this, they used hardware devices like powermeter or printed circuit. The main advantage of this methodology is the fact that we can obtain accurate results because we measure the energy consumed by components. But, we are limited at the fact that we can't measure the power consumed by VM (Virtual Machine) and the cost of this process itself can be expansive. Estimating power consumption of software has begun a popular research field. Several tools have been presented in academic literature, however, these tools have the capacity to estimate only specific component's consumption.

ICT (Information and Communications Technologies) constitutes 2% of such gas emissions, and it is projected an increase to 4% by 2020, if nothing is done [START_REF] Greentouch | ICT Industry Combats Climate Change[END_REF]. In fact, recent trends such as cloud computing and internet of things even increase the number of devices, and consequently the software running on them. Hence, software became a fundamental actor of efficiency plans that aims at reducing greenhouse gas emission.

In this paper, we propose a tool, called TEEC (Tool to Estimate Energy Consumption), in order to estimate the power consumption of a given software at runtime by taking into account CPU, memory and disk power consumptions. Using TEEC, we expect to be able to obtain software/applications having some functionality and consuming less power.

Components Modelization

Related Work

Similar to our recent study [START_REF] Acar | Towards a Green and Sustainable Software[END_REF], there are several tools that are able to estimate the power consumption using a program:  Joulemeter [START_REF] Kansal | Virtual Machine Power Metering and Provisioning[END_REF] which provides components' power usage for all processes. It also estimates power consumed by CPU for a given process.



Span [START_REF] Wang | SPAN: A software power analyzer for multicore computer systems[END_REF] gives power information about running programs. With specific functions, developers can manually instrument source code.

 GREENSOFT [START_REF] Kern | Green software and green software engineering-definitions, measurements, and quality aspects[END_REF] is a hybrid solution, which takes into account hardware devices and software part during the power estimation. For a power estimation to be accurate, it is required that all components need to be taken into account during the software runtime. This estimation will guide software developer to improve their code.

Thus, we propose a detailed study of the components: CPU, memory and hard disk in order to provide an accurate modelization. Accordingly, we use mathematical formula for measuring energy consumption for each component.

CPU

For a long time the CPU was considered the largest energy consumer component [START_REF] Kim | A Simple Model for Estimating Power Consumption of a Multicore Server System[END_REF] in a computer. That is the reason why in most of the works, the modelization has taken into account only the CPU to estimate the energy consumed by computer program. Several models and factors have been proposed for CPU power consumption, but in this study, we will consider the following equation ( 1):

𝑃 𝐶𝑃𝑈 = 𝑃 𝐶𝑃𝑈,𝑑𝑦𝑛𝑎𝑚𝑖𝑐 + 𝑃 𝐶𝑃𝑈,𝑠𝑡𝑎𝑡𝑖𝑐 (1)
where 𝑃 𝐶𝑃𝑈,𝑑𝑦𝑛𝑎𝑚𝑖𝑐 represents dynamic power consumption, while 𝑃 𝐶𝑃𝑈,𝑠𝑡𝑎𝑡𝑖𝑐 corresponds to static power consumption. Only the manufacturer can reduce the static power consumption because it depends on the architectural characteristics of each component. In our case, we want to reduce the energy consumed by software. Therefore, we only consider the dynamic power consumption to get more accurate results. The CPU, like many integrated circuit, is a set of gates. Hence, the main power consumption in CPU is due to capacitors charge and discharge during computations. We assume that in a switching cycle, there are low-to-high and high-to-low transitions. For N gates, the power need to be multiplied by N. Hence, we can define a parameter α < 1 as the average fraction of gates that commute at each cycle. To determine the power consumed by the program, we multiple by the percentage of the process id 𝑁 𝑖𝑑 . The equation of the power becomes (2):

𝑃 𝐶𝑃𝑈,𝑑𝑦𝑛𝑎𝑚𝑖𝑐 = 𝐶. 𝑓. 𝑉 𝑑𝑑 2 (2)
where 𝐶 = 𝐶 𝐿 . 𝑁. 𝛼, 𝑉 𝑑𝑑 is the voltage and f is the frequency.

Memory

According to [START_REF] Minas | The Problem of Power Consumption in Servers[END_REF], the power used on servers is increasing and two largest consumers of power are the processors and RAM chips. Especially because memory RAM size increase a lot this last decade. Several works have the objective to optimize systems to reduce DRAM power consumption [8, 9, and 10].

In this work, we decide to study the DRAM in order to model its power consumption. Doing so, we use datasheet values from DRAM manufacturer to build the power consumption equation. Similar to CPU, we only interest in the dynamic power, since it is the only part for energy saving. Based on Micron [START_REF] Micron | Calculating Memory System Power for DDR3[END_REF], we assume that the dynamic power is composed of: Activate, Precharge, Read and Write power.

Accordingly, total power consumption of DRAM can be give as (3): 𝑃 𝐷𝑅𝐴𝑀,𝑖𝑑 = (𝑃 𝐴𝑐𝑡𝑖𝑣𝑎𝑡𝑒 + 𝑃 𝑃𝑟𝑒𝑐ℎ𝑎𝑟𝑔𝑒 + 𝑃 𝑅𝑒𝑎𝑑 + 𝑃 𝑊𝑟𝑖𝑡𝑒 ). 𝑀 𝑖𝑑

where 𝑀 𝑖𝑑 is the usage percent of the process id.

Hard disk

According to the International Data Corporation (IDC), storage capacity increases each year with a rate of 60% [START_REF]IDC serves up 10 storage predictions for 2008[END_REF].

There are several tools proposed to test the performance of a hard drive. The most known are CristalDiskMark and HD Tune [START_REF] Hd Tune | [END_REF]. However, these programs allow only measuring read/write speeds. They do not give information about power consumption. That is the reason why researchers tried to take into account power consumption due to hard disk during the runtime. Some of the tools that are built for this purpose are: DiskSim [START_REF] Bucy | The DiskSim Simulation EnvironmentVersion 4.0 Reference Manual[END_REF], Tempo [START_REF] Molaro | Tempo: Disk Drive Power Consumption Characterization and Modeling[END_REF] and SODA [START_REF] Sankar | Sensitivity Based Optimization of Disk Architecture[END_REF].

In an Hard Disk Drive, there are four power management states are supported: active, idle, standby and sleep. Hard disk is also composed of dynamic (4) and static power:

𝑃 𝐷𝑖𝑠𝑘,𝑑𝑦𝑛𝑎𝑚𝑖𝑐 = 𝑃 𝐴𝑐𝑡𝑖𝑣𝑒 = 𝑃 𝑅𝑒𝑎𝑑 + 𝑃 𝑊𝑟𝑖𝑡𝑒 (4)

Experiments

In order to realize our experiments, we develop a tool called TEEC. This tool has been developed in Java which is one of informatic language most used. We use Sigar library [17] to automatically obtain information about CPU, memory and disk. Besides, static manufacturer data are saved and used. So, we can provide an estimation of power consumption due to each component during runtime of software.

We perform our test on a notebook ASUS N751JK-T7238H, running Windows 8. Different tests have been executed with unoptimized and optimized code source in order to see the impact on each component.

Loops have an important effect on the performance of a program and provide efficient way for repeating a piece of code as many times as required. Java has three types of loop control structures which are: for, while and do-while. So, it is interesting to study some functions, as represented in Table 1, that are used during a development of a program in order to examine possible optimizations.

Unoptimized

Summary

We develop two JAVA projects in order to regroup all the unoptimized and optimized functions previously described. We obtain the following power and energy related relationships (Figure 1 and2). 2: Optimized Power and Energy Therefore, we observe, without surprise, that in general the power consumption of CPU dominate memory or disk consumption. If we analyze the results obtained each 50 ms, we can say that the power consumption of disk can be neglected for these cases, but in some cases power consumption of memory must be taken into account. Moreover, we can say that the power consumption of the unoptimized code is higher than the one of the optimized code and the total execution time of optimized code is less than the one of the unoptimized code. Consequently, it is of great interest to develop optimized parts of code in order to obtain green and efficient software.

Validation

To validate our experiments, we use a powermeter 'wattsup ?PRO'. We connect this device to the notebook via USB port. This device saves in his memory the power consumed by all process in runtime. So, we connect WattsUp to the notebook and then we wait until the power reach a stationary state. Then, we launch the unoptimized program, followed by the optimized program. We then transfer the results using the application WattsUpUSB and the results are depicted in Figure 3.

Comparing to the results obtain with TEEC, even if we make a measurement in each second, we can say that in most of the case, optimized code test is faster and reveals less power than unoptimized code test. Each optimized and unoptimized curves present some increase of power as we observed with TEEC.

Conclusion

In addition to the CPU, a modelization of memory and hard disk has been made to describe the behavior of each component. Mathematical expressions have been established in order to calculate the 6 power consumption of each component. The tool we designed, named TEEC, take into account CPU, memory and hard disk power consumption.

The accuracy of TEEC has been tested over several optimized and unoptimized functions and validated against a real powermeter.

We stated that power consumption of memory should not always be neglected in front of the CPU power consumption whereas power consumption of hard disk can be neglected.

We observed that the optimizations of source code are required in order to contribute to the reduction of the greenhouse gas emissions.

In a short term, we wish to extend the capability of TEEC by integrating others components power consumption (such as network interface cards, etc.). In a long term, we will use the output of TEEC to guide developers in order to build greener software in real time.

Figure 1 :

 1 Figure 1: Unoptimized Power and Energy

Figure

  Figure2: Optimized Power and Energy Therefore, we observe, without surprise, that in general the power consumption of CPU dominate memory or disk consumption. If we analyze the results obtained each 50 ms, we can say that the power consumption of disk can be neglected for these cases, but in some cases power consumption of memory must be taken into account. Moreover, we can say that the power consumption of the unoptimized code is higher than the one of the optimized code and the total execution time of optimized code is less than the one of the unoptimized code. Consequently, it is of great interest to develop optimized parts of code in order to obtain green and efficient software.

Figure 3 :

 3 Figure 3: Unoptimized and Optimized Power

Table 1 :

 1 Unoptimized and optimized functions

		Optimized
	Locality of reference
	for(int i=0;i<1000000;i++){	for(int i=0;i<1000000;i++){
	int sum = 0;	int sum = 0;
	for(int x=0;x<50000;x+=100){	for(int x=0;x<500;x++){
	sum += values[x]; }}	sum += values[x]; }}
	Compare array to array list
	for(int i=0;i<1000000;i++){	for(int i=0;i<1000000;i++){
	int sum = 0;	int sum = 0;
	for(int v=0;v<list.size();v++)	for(int v=0;v<array.length;v++)

LIRIS, University of Lyon 1, Lyon France, hayri.acar@univ-lyon1.fr

Galatasaray University, Istanbul Turkey, gisiklar@gsu.edu.tr

ENS Lyon, LIP, UMR 5668, Lyon France, jean-patrick.gelas@univ-lyon1.fr

LIRIS, University of Lyon 1, Lyon France, parisa.ghodous@univ-lyon1.fr


Hayri Acar
email: hayri.acar@univ-lyon1.fr

Gülfem I Alptekin

Jean-Patrick Gelas
email: jean-patrick.gelas@univ-lyon1.fr

Parisa Ghodous
email: parisa.ghodous@univ-lyon1.fr

International Journal of Electronic Business Management THE IMPACT OF SOURCE CODE IN SOFTWARE ON POWER CONSUMPTION

Keywords: Sustainable Software, Green Software, Power Consumption, Energy Efficiency, Green IT. Study Research Type Facet Research Nature Facet Formula dynamic power consumption, C: load capacitance, Vdd: supply voltage, f: clock frequency and a: fraction between 0 and 1

Writing sustainable, power efficient and green software necessitates understanding the power consumption behavior of a computer program. One of the benefits is the fact that developers, by improving their source code implementations, can optimize power consumption of a software. Existing power consumption models need to be improved by taking into account more components susceptible to consume energy during runtime of an application. In this paper, we first present a detailed classification of previous works on power consumption modelization. Then, we introduce TEEC (Tool to Estimate Energy Consumption) model in order to estimate the power consumed by CPU, memory and disk due to the execution of an application at runtime. The main goal is to guide developers to improve their source code for optimizing energy consumption. TEEC enables determining the part of the code consuming the highest power. This will help to obtain a less energy consuming software with the same functionalities.

INTRODUCTION

The 2015 Paris Climate Conference, COP 21 (Conference of the Parties), the conference have reaffirmed the objective of keeping the rise in temperature below 2°C before the end of the century, by controlling the global greenhouse gas emissions [START_REF]Adoption of the Paris Agreement[END_REF]. Information and Communication Technologies (ICT) represents around 2% of worldwide greenhouse gas emissions (GGE) [START_REF] Gartner | Green IT: The New Industry Shock Wave, Gartner[END_REF]. Moreover, the number of mobile users is increasing due to new technologies, such as mobile Internet, cloud computing, Internet of things, etc. Thus, it is predicted, if nothing is done, that ICT global GGE will be 4% by 2020 [START_REF] Touch | ICT Industry Combats Climate Change[END_REF].

Writing sustainable, power efficient and green software necessitates understanding the power consumption behavior of a computer program. One of the benefits is the fact that developers, by improving their source code implementations, can optimize power consumption of a software. Existing power consumption models need to be improved by taking into account more components susceptible to consume energy during runtime of an application.

In this paper, we first present a detailed classification of previous works on power consumption modelization. Then, we introduce TEEC model (Tool to Estimate Energy Consumption) in order to estimate the power consumed by CPU, memory and disk due to the execution of an application at runtime. The main goal is to guide developers to improve their source code for optimizing energy consumption. TEEC enables determining the part of the code consuming the highest power. This will help to obtain a less energy consuming software with the same functionalities.

This paper is organized as follows. In Section 2, we present a detailed survey of the related works on power modeling and measurement. Then, we describe the modelization of different components in terms of power consumption in Section 3. In Section 4, we represent our proposed model TEEC, followed by experiments in Section 5. We validate the accuracy of TEEC in Section 6. Finally, Section 7 concludes the work.

RELATED WORKS

In related literature, it is possible to find several online tools [START_REF]Power Supply Calculator[END_REF][START_REF]eXtreme Power Supply Calculator[END_REF], which aim to estimate the power consumption arising from different components like CPU, memory, disk, network card, etc. However, these power calculators are not accurate enough and give a global estimation on consumed energy. We believe that there is a need to have a tool, which can accurately estimate the power consumption of an application. For this purpose, researchers have used different methodologies that we can classify into three main categories: hardware methodologies, software methodologies and hybrid methodologies.

Software Methodology

This type of methodologies estimate the consumed power based on mathematical formula, which is established according to the characteristics of each component susceptible to consume power. We followed systematic review methodology [START_REF] Kitchenham | A systematic review of systematic review process research in software engineering[END_REF] to analyze previous works in literature. We respect the systematic mapping process [START_REF] Petersen | Systematic Mapping Studies in Software Engineering[END_REF].

Research Type Facet

We summarize research approaches respecting research type facet in Therefore, we will use these two criteria (research work and research type facet) when classifying the works. The final classification is represented in Table 3, where we give also related mathematical equations, together with the brief description of each study.

Using the information in Table 3, we establish a diagram in two bubble plots that is represented in Figure 1.

Hardware Methodology

Research works, using hardware methodologies in order to measure the power consumed by components, can be grouped in two categories. First [START_REF] Hu | Toward an evaluation infrastructure for power and energy optimizations[END_REF][START_REF] Kamil | Power efficiency in high performance computing[END_REF], power meters are used to measure directly the voltages and currents in devices to obtain the power. Second way [START_REF] Giri | Increasing data center efficiency with server power measurements[END_REF] consists to connect power sensors directly into the component that we want to measure the power consumption. This approach is particularly used by high performance servers.

Hardware methodologies are more accurate than software methodologies. However, it is impossible to measure the power consumed by programs on process and virtual machines. Moreover, this method is expansive and circuits consume also power.

Hybrid Methodology

Hybrid methodology [START_REF] Ge | Powerpack energy profiling and analysis of high-performance systems and applications[END_REF][START_REF] Isci | Phase characterization for power: evaluating controlflow-based and event-counter-based techniques[END_REF] is also a research area, since it enables taking the accuracy of hardware methodologies and the simplicity of software methodologies. However, this way of measurement methodology is more difficult to establish, in practice.

POWER MODEL

The power consumption of the software is composed of two parts: static and dynamic. Static power consumption is due to the manufacturer component's features. Therefore, we cannot modify this part. Hence, we are interested only in dynamic power consumption, which depends on source code of software. In order to model the power consumption of different components, we take into account only dynamic part of power consumption.

Power Model of CPU

As shown in Table 3, the power consumption equation of CPU is, in the majority of cases, the multiplication of frequency, square of voltage and a constant. So, we our formula (1) that is distinguished from others concerning the constant part:

𝑃 𝐶𝑃𝑈 = 𝛽 . 𝑓 . 𝑉 𝑑𝑑 2 (1)
where 𝛽 = 𝐶 𝐿 . 𝑁 . 𝛼, the constant, 𝐶 𝐿 is the capacitance, N represents the number of gates and α < 1 as the average fraction of gates that commute at each cycle, f is the frequency and 𝑉 𝑑𝑑 corresponds to voltage.

The difference of the proposed equation is in the constant part. In order to obtain the power consumed by a specific process, we multiply (1) by the percentage of the process id N id [START_REF] Gartner | Green IT: The New Industry Shock Wave, Gartner[END_REF]:

𝑃 𝐶𝑃𝑈, 𝑖𝑑 = 𝑃 𝐶𝑃𝑈 . 𝑁 𝑖𝑑 (2)

Power Model of Memory

Dynamic DRAM power is composed of four states: activate, precharge, read and write. So, power consumption can be expressed as (3):

𝑃 𝐷𝑅𝐴𝑀 = 𝑃 𝐴𝑐𝑡𝑖𝑣𝑎𝑡𝑒 + 𝑃 𝑃𝑟𝑒𝑐ℎ𝑎𝑟𝑔𝑒 + 𝑃 𝑅𝑒𝑎𝑑 + 𝑃 𝑊𝑟𝑖𝑡𝑒 (3)
We multiply previous equation ( 3) by the usage percent M id of the process id to obtain Eq. ( 4): 𝑃 𝐷𝑅𝐴𝑀, 𝑖𝑑 = 𝑃 𝐷𝑅𝐴𝑀 . 𝑀 𝑖𝑑 (4)

Power Model of Disk

A disk executing a sequence of requests is composed of four mode: active, idle, standby and sleep.

The dynamic disk power consumption is obtained when the disk is in active mode. Thus, we can deduce the following equation ( 5):

𝑃 𝐷𝑖𝑠𝑘 = 𝑃 𝐴𝑐𝑡𝑖𝑣𝑒 = 𝑃 𝑅𝑒𝑎𝑑 + 𝑃 𝑊𝑟𝑖𝑡𝑒 [START_REF]eXtreme Power Supply Calculator[END_REF] where 𝑃 𝑅𝑒𝑎𝑑 is the read power and 𝑃 𝑊𝑟𝑖𝑡𝑒 is the write power.

Total Power Consumption

Based on previous equation, it is possible to define the global power consumption due to software by adding Eq. ( 2), (4), and (5) in order to obtain the following expression [START_REF] Kitchenham | A systematic review of systematic review process research in software engineering[END_REF]:

𝑃 𝑆𝑜𝑓𝑡 = 𝑃 𝐶𝑃𝑈,𝑖𝑑 + 𝑃 𝐷𝑅𝐴𝑀,𝑖𝑑 + 𝑃 𝐷𝑖𝑠𝑘 (16)

TEEC (TOOL TO ESTIMATE ENERGY CONSUMPTION) 4.1 Green Process

All development processes of a computer program requires following a specific sequence in order to complete the project. In addition, after each phase, a green analysis step can be involved in order to check if the considered step has respected all criteria that allow reducing energy consumption. If the criteria of a phase are not validated by the green analysis, depending uncommitted specifications, a return to the previous step or even return until the requirement analysis step can be performed.

The process described in [START_REF] Noureddine | A Preliminary Study of the Impact of Software Engineering on GreenIT[END_REF] presents a comprehensive progress of a development project. Thus, we offer our descriptive diagram in Figure 2. Requirements: It is the first step in order to build a software product. This stage corresponds to the descriptions of the tasks that will be performed by the product. The aim is to meet customer demands.

Design: The defined requirements are considered in order to create system architecture. The classes and the relationships among them are defined at this stage.

Implementation: In this step, the program is implemented in respect to its design. Developers should choose the most appropriate programming language.

Tests: This step allows checking if the software meets its requirements, to discover faults or defects. The tests will be defined at the end of requirements phase (QCHP) before design and implementation step, to show that the specifications have been understood. Use of different tests will allow developers to see if the requirements are correct and consistent.

The proposed energy consumption measurement tool (TEEC) will be used in order to know whether the program can be improved.

Usage: This step defines how the software product can be used by the user in a green manner. The responsibility belongs to the user, but also to the engineers themselves. The user should be trained to use the software, because the fact that improper handling can cause errors in the program.

Maintenance: Newer versions or enhancements usually involve changes. The developers need to handle them. Furthermore, developers need to know the cost is proportional to the energy waste. Several types of errors in the program can cause the return to the implementation phase, but sometimes even more complicated errors can cause the developer to return to the first step of requirement analysis. The maintenance process must be carried out in the most energy efficient manner.

Disposal: Software and hardware must be replaced when it is not profitable to up to date them, or when it is no longer used, or when it has become obsolete. This step considers both the software and the hardware running the code. Disposal of old hardware also causes energy consumption.

Green analysis: This step can be added at the end of each one in order to improve energy efficiency. This stage will evaluate the greenness of the software.

Design and Implementation

According to [START_REF] Noureddine | A Preliminary Study of the Impact of Software Engineering on GreenIT[END_REF], Java programming language is stated as the language with the least energy consumption during compilation and execution stages. Thus, Java is chosen as the development language.

Sigar library [40] allows getting information about the CPU usage, including the percentage of usage of each process and the number of cores used. Thus, the id of the ongoing process can be identified and retrieved. Moreover, the form of global variable data providers is formed that allows estimating the energy and assigning a corresponding value. Java agents are utilized, which are software components that provide with the instrumentation capabilities to an application, such as re-defining the content of class that is loaded at run-time.

Our proposed model TEEC, with whom we can provide an estimation of power consumption of each component is illustrated in Figure 3.

EXPERIMENTS

We carry out our tests on a notebook ASUS N751JK-T7238H, running Windows 8.

Thus, using TEEC, different tests have been executed with unoptimized and optimized methods in order to observe the variation of the power consumption due to the CPU, the memory and the disk and compare them

Tests Description

Loops have an important effect on the performance of a program and provide efficient way for repeating a piece of code as many times as required. Java has three types of loop control structures which are: while, do-while and for. If we do not know the number of required iterations, then while loop can be used. The do-while loop is always executed at least once and then the condition is checked at the end of the loop. If we know how many iterations are required, then we for loop Therefore, it is interesting to study some methods that are used during a development of a program in order to examine possible improvement.

Array copy

It is better to use an int data type than byte or short data types for a loop index variable, because of its efficiency. The fact to use byte or short data type as the loop index variable involves implicit type cast to int data type.

It is always efficient to copy arrays using System.arraycopy() than using a loop. Table 4 shows the difference between optimized and unoptimized source code.

Unoptimized

Optimized for (int j = 0; j < a.length; j++) b[j] = a[j]; System.arraycopy(a, 0, b, 0, b.length); Table 4: Array copy

Locality of Reference

Elements close to each other in memory are faster to access. We can observe this principle with the programs described in Table 5. Locality of reference in an array is used.

In the unoptimized version, the loop reads the values of 100 elements in an array. In the optimized version, the loop loads 100 elements, but they are spaced 100 elements apart from each other.

Array and array list

Arrays are harder to use than ArrayLists, but they have a speed advantage, even on simple element accesses. In Table 6, we represent a sum of two 100-element collections: an array and an ArrayList.

Unoptimized

Integer list loop

There are several ways to iterate elements of an integer list. In Table 7, we compare two different ways.

Unoptimized

Optimized for (Integer i : list) count++;

int size = list.size(); for (int i = 0; i < size; i++) count++; Table 7: Integer list loop

Char array and StringBuilder

We can replace a StringBuilder with a char array in some programs as in Table 8.

Unoptimized

Binary search

As showed in Table 9, the BinarySearch method searches an integer in a sorted array of integers. This is more practical to use compare to a for loop.

Unoptimized

Results

We develop two JAVA projects in order to regroup all the optimized and unoptimized methods previously defined. We obtain the following power and energy related relationships (Figure 4 Therefore, we observe that globally the power consumption of CPU dominates memory or disk consumption. If we examine the results obtained each 50 ms, we can note that the power consumption of disk can be neglected for these cases, but in some cases power consumption of memory must be taken into account. In addition, we can note that the power consumption of the unoptimized code is higher than the one of the optimized code and the total execution time of optimized code is less than the one of the unoptimized code. Consequently, it is a great interest to develop optimized parts of code in order to obtain green, sustainable and efficient software.

So, going more in details, for each method code, we measure the time elapsed during the execution of the tests and results are represented in Table 10. Hence, optimized codes are found faster than unoptimized codes. Particularly, we can remark a faster execution of the following optimized methods: "Locality of reference", "Compare array to array list", "Char array StringBuilder" and "Binary search".

Functions

VALIDATION

To validate our experiments, we use a powermeter 'wattsup ?PRO' as shown in Figure 8. We connect this powermeter to the notebook via USB port. This device saves in his memory the power consumed by all process in runtime. So, we connect WattsUp to the notebook and then we wait until the power reach a stationary state. Then, we execute the unoptimized code, followed by the optimized code. We then transfer the results using the application WattsUpUSB and the results are depicted in Figure 9. Comparing to the results obtain with TEEC, even if we make a measurement in each second, we can say that in all of the case, optimized code test is faster and reveals less power than unoptimized code test. Each optimized and unoptimized curves present some increase of power as we observed with TEEC.

CONCLUSION

In addition to the CPU, a modelization of memory and hard disk have been made to describe the consumption behavior of each component. The proposed tool, named TEEC, takes into account all these three components. Mathematical expressions have been established in order to calculate the power consumption of each component.

The accuracy of TEEC has been tested over several optimized and unoptimized functions and validated against a real powermeter.

The results revealed that the power consumption of memory should not always be neglected when compared to the CPU power consumption, whereas power consumption of hard disk can be neglected. We observed that the optimization of source code is required in order to contribute to the reduction of the greenhouse gas emissions.

Going further, we will extend the capability of TEEC by integrating other components power consumption (such as network interface cards, etc.). Then, we will use the output of TEEC to guide developers in order to build greener software in real time and analyze the results.

Figure

  Figure 1: Systematic map in a bubble plot of research type and nature facets

Figure 2 :

 2 Figure 2: Green Software Engineering Process

Figure 3 :

 3 Figure 3: TEEC

  Optimized for (int i = 0; i < 1000000; i++) { StringBuilder builder = new StringBuilder(); for (int v = 0; v < 1000; v++) builder.append('? '); String result = builder.toString(); } for (int i = 0; i < 1000000; i++) { char[] array = new char[1000]; for (int v = 0; v < 1000; v++) array[v] = '?'; String result = new String(array); } Table 8: Char array and StringBuilder

  Optimized for (int i = 0; i < 10000000; i++) { int index = -1; for (int j = 0; j < values.length; j++) { if (values[j] == 80

  , 5, 6 and 7).

Figure 4 :Figure 5 :Figure 6 :

 456 Figure 4: Power consumption of an unoptimized code

Figure 7 :

 7 Figure 7: Energy consumption of an optimized code

Figure 8 :

 8 Figure 8: wattsup?PRO

Figure 9 :

 9 Figure 9: unoptimized and optimized functions power consumption

Table

Table 1 :

 1 . Research Type Facet

				establish a power estimation model of
				software.
	Name		Description
	Validation Research	Investigated techniques
			are novel and have not
			yet been implemented in
			practice.
	Evaluation Research	Techniques	are
			implemented in practice
			and an evaluation of the
			technique is conducted.
	Solution Proposal	A solution for a problem
			is proposed, the solution
			can be either novel or a
			significant extension of
			an existing technique.
			The potential benefits
			and the applicability of
			the solution is shown by
			a small example or a
			good	line	of
			argumentation.
	2.1.2 Research Nature Facet
	In Table 2, related works on component-based
	power estimation models are summarized.
	Name	Description
	CPU	It consists of the studies, where the
		CPU is taken into account in order to
		establish a power estimation model of
		software.
	Memory	It consists of the studies, where the
		memory is taken into account in order
		to establish a power estimation model
		of software.
	Disk	It consists of the studies, where the
		disk is taken into account in order to

Table 2 :

 2 Research Nature Facet

Table 3 :

 3 1: Systematic map in a bubble plot of research type and nature facets Research works classification

	So, we observe that the majority of studies for
	calculating power consumption of software takes into
	account only one component and neglects others.
	Moreover, the most remarkable research type facet is
	solution proposal.

𝑏𝑢𝑠 + 𝐸 𝑐𝑒𝑙𝑙 + 𝐸 𝑝𝑎𝑑 + 𝐸 𝑚𝑎𝑖𝑛 Ebus: data and address bus energy, Ecell: cache energy, Epad: data and

Table 6 :

 6 Array and array list

	Optimized

Table 10 :

 10 Functions time execution

		Unoptimized	Optimized
		Time (ms)
	Array copy	359	312
	Locality of reference	18140	17219
	Compare array to array list	22047	17297
	Compare integer list loop	7734	7391
	Char array StringBuilder	11235	2421
	Binary search	2250	438