Commit a9bd98c0 authored by Cornelius Schumacher's avatar Cornelius Schumacher
Browse files

Initial commit

parents
Copyright 2020 KDE
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# FOSS Energy Efficiency Project
## Vision
The goal of the Free and Open Source Energy Efficiency Project (FOSSEEP) is to improve the energy efficiency of free and open source software.
Design and implementation of software has a significant impact on the energy consumption of the systems it is part of. By becoming aware of the factors how software affects energy consumption and providing tools to quantify them it is possibly to drive down energy consuption and increase energy efficiency. This contributes to a more sustainable use of energy as one of the shared resources of our planet. This project strives to achieve that for and through Free and Open Source Software (FOSS).
Let's make energy efficient software part of our story so we can live up to our responsibility for this and future generations.
## Strategy
As a first step we will develop a framework to measure energy consumption of FOSS applications using the [criteria for the Blue Angel environmental label](https://produktinfo.blauer-engel.de/uploads/criteriafile/en/DE-UZ%20215-202001-en-Criteria-2020-02-13.pdf) based on the [research by the Environmental Campus Birkenfeld](https://www.umwelt-campus.de/en/research/projekte/green-software-engineering/projects/ufoplan-ssd-2015) and execute measurements on selected applications, starting with a set of KDE applications.
Later we intend to integrate measuring energy consumption into the development process of applications so that energy efficiency can become a quality metric for these applications.
To scale this to a wide variety of projects we envision a distributed network of FOSS energy measurement labs which provide energy consumption data to projects as a service which can be intergrated as quality gate in release processes and drive energy efficiency as a goal of the development process.
We start with KDE but are happy to welcome other projects to join the project. The current focus are desktop applications where the most solid and usable procedures exist for measuring energy consumption. This will likely be expanded in the future to other types of applications and systems.
## Resources
This repository contains the following resources:
* [Usage scenarios](usage_scenarios) - Detailed Descriptions of usage scenarios for specific application types. These are the scenarios for which energy consumption will be measured.
* [Measurement setup](measurement_setup.md) - Description of hardware and software setup for performing energy measurements. This defines comparable environments and tools how to do automated measurements.
* [Test runs](test_runs) - Automation for doing test runs of specific applications for their corresponding usage scenarios.
## License
The content of this repository is licensed under the [MIT license](https://opensource.org/licenses/MIT). See the file [LICENSE.txt](LICENSE.txt) for the full text of the license.
# Measurement setup
The measurement setup consists of a computer as reference system, an energy meter for measuring energy consumption of the computer, and software to automate the usage scenario and record and process the measured data.
The setup described here follows the specifications from the [Blue Angel Basic Award Criteria for Resource and Energy-Efficient Software Products](https://produktinfo.blauer-engel.de/uploads/criteriafile/en/DE-UZ%20215-202001-en-Criteria-2020-02-13.pdf)
## Energy meter
We use the [GUDE Expert Power Control 1202](https://www.gude.info/en/power-distribution/switched-metered-pdu/expert-power-control-1202-series.html). It provides plugs for powering the computer and measures the current during operation. The device can be controlled and read via cabled Ethernet. There is a web-based user interface, a [REST API](http://wiki.gude.info/EPC_HTTP_Interface), and the device supports various protocols such as SNMP or syslog.
## Reference system
As reference system we use a Fujitsu Esprimo P920 Desktop-PC proGreen selection (Intel Core i5-4570 3,6GHz, 4GB RAM, 500GB HDD) running Ubuntu 18.04.
## Test automation
We need an automation tool which can run the standard usage scenarios in a way which doesn't need human intervention, so it can be run repeatedly in a well-defined way to provide accurate measurements.
There are some candidates for tools which might meet the requirements:
* [Actiona](https://github.com/Jmgr/actiona)
* [Atbswp](https://github.com/RMPR/atbswp)
* [xdotool](https://github.com/jordansissel/xdotool)
* [SikuliX](https://github.com/RaiMan/SikuliX1)
There might be more. We need to assess them and come up with a working solution.
## Measurement of system performance indicators
During the energy measurement we also need to record a set of performance indicators: processor utilisation, RAM utilisation, hard disk activity and network traffic).
Tool candidates:
* [Collectl](http://collectl.sourceforge.net/)
## Measurement process
The measurement process is defined in Appendix A of the [Basic Award Criteria](https://produktinfo.blauer-engel.de/uploads/criteriafile/en/DE-UZ%20215-202001-en-Criteria-2020-02-13.pdf). It requires to record energy data and performance indicators with a granularity of 1 second and log it so it can be processed and average values can be calculated.
We might want to look into tools such as [Prometheus](https://prometheus.io/) to gather the data.
This directory contains script to automatically go through usage scenarios.
There is one example for okular which uses xdotool to generate mouse and keyboard actions. There is a python script `okular.py` which writes a shell script `okular.sh`. The shell script can then be executed to run okular through the usage scenario for pdf readers.
Other ways to automate test runs are possible as well. See the [description of the measurement setup](../measurement-setup.md) for more details.
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2020 Cornelius Schumacher <schumacher@kde.org>
from pathlib import Path
class XDoWriter:
def __init__(self):
self.script = ""
def write_script(self):
path = Path(__file__).resolve().parent / "okular.sh"
with path.open("w") as f:
f.write(self.script)
def add(self, line=""):
self.script += line + "\n"
def xdo(self, args):
self.add("xdotool " + args)
def key(self, symbol, repeat=1):
self.xdo("key" + (" " + symbol) * repeat)
def key_ctrl(self, symbol):
self.key("ctrl+" + symbol)
def keys(self, string):
self.xdo(f'type "{string}"')
def mousemove(self, point):
self.xdo(f"mousemove {point[0]} {point[1]}")
def click(self):
self.xdo("click 1")
def sleep(self, seconds=1):
self.add(f"sleep {seconds}")
def she_bang(self):
self.add("#!/bin/bash")
self.add()
def clear_files(self, filename):
self.add("rm " + filename)
def clear_line_of_file(self, filename, pattern):
self.add(f"sed -i '/{pattern}/d' {filename}")
def cd(self, wd):
self.add(f"cd {wd}")
self.add()
def start_application(self, name):
self.add(name + " &")
self.sleep()
self.add()
def reset_window(self):
self.add("WID=`xdotool getactivewindow`")
self.xdo("windowsize $WID 1200 800")
self.xdo("windowmove --sync $WID 0 0")
self.add()
def quit_application(self, discard=False):
self.key_ctrl("q")
if discard:
self.key("Right Return")
else:
self.key("Escape")
class OkularWriter(XDoWriter):
def __init__(self):
super().__init__()
def open_file(self, name):
self.key_ctrl("o")
self.sleep()
self.keys("20yearsofKDE.pdf")
self.sleep()
self.key("Return")
self.sleep()
self.add()
def goto_page(self, number):
self.key_ctrl("g")
self.sleep()
self.keys(str(number))
self.sleep()
self.key("Return")
self.sleep()
self.add()
def page_down(self):
self.key("Next")
self.sleep()
self.add()
def add_note(self):
self.key("F6")
self.sleep()
self.key("1")
self.sleep()
self.mousemove((419, 172))
self.click()
self.sleep()
self.keys("This is an important bit of history")
self.key("Return")
self.sleep()
self.add()
def rotate_right(self):
self.key("alt+v")
self.sleep()
self.key("Down", 8)
self.key("Right Down")
self.sleep(1)
self.key("Return")
self.sleep(1)
self.add()
def rotate_left(self):
self.key("alt+v")
self.sleep()
self.key("Down", 9)
self.key("Right")
self.sleep(1)
self.key("Return")
self.sleep(1)
self.add()
def zoom_in(self, factor):
self.key_ctrl("0")
self.sleep()
for i in range(0, factor):
self.key_ctrl("+")
self.sleep()
self.add()
def zoom_out(self, factor):
self.key_ctrl("0")
self.sleep()
for i in range(0, factor):
self.key_ctrl("minus")
self.sleep()
self.add()
def start_presentation(self):
self.key("ctrl+shift+p")
self.sleep()
self.key("Escape")
self.sleep()
self.add()
def exit_presentation(self):
self.key("Escape")
self.sleep()
self.add()
def page_back(self, count):
for i in range(0, count):
self.key("Left")
self.sleep()
self.add()
def page_forward(self, count):
for i in range(0, count):
self.key("Right")
self.sleep()
self.add()
def activate_inverted_colors(self):
self.key("ctrl+shift+comma")
self.sleep()
self.key("Down")
self.sleep()
self.key("Tab", 5)
self.sleep()
self.key("space")
self.sleep()
self.key("alt+k")
self.sleep()
self.add()
def select_text(self):
self.key_ctrl("4")
self.sleep()
self.mousemove((483, 320))
self.xdo("mousedown 1")
self.sleep()
self.mousemove((567, 360))
self.sleep()
self.xdo("mouseup 1")
self.sleep()
self.add()
def run(self):
self.she_bang()
self.clear_files("~/.local/share/okular/docdata/*.20yearsofKDE.pdf.xml")
self.clear_files("~/.config/okular*")
self.clear_line_of_file("~/.config/QtProject.conf", "^lastVisited")
self.add()
self.cd("../usage_scenarios/test_data")
self.start_application("okular")
self.reset_window()
self.open_file("20yearsofKDE.pdf")
self.goto_page(97)
self.page_down()
self.add_note()
self.rotate_right()
self.zoom_in(3)
self.zoom_out(2)
self.start_presentation()
self.page_back(4)
self.exit_presentation()
self.activate_inverted_colors()
self.rotate_left()
self.zoom_out(1)
self.goto_page(111)
self.select_text()
self.start_presentation()
self.page_forward(14)
self.exit_presentation()
self.quit_application(discard=True)
self.write_script()
OkularWriter().run()
#!/bin/bash
rm ~/.local/share/okular/docdata/*.20yearsofKDE.pdf.xml
rm ~/.config/okular*
sed -i '/^lastVisited/d' ~/.config/QtProject.conf
cd ../usage_scenarios/test_data
okular &
sleep 1
WID=`xdotool getactivewindow`
xdotool windowsize $WID 1200 800
xdotool windowmove --sync $WID 0 0
xdotool key ctrl+o
sleep 1
xdotool type "20yearsofKDE.pdf"
sleep 1
xdotool key Return
sleep 1
xdotool key ctrl+g
sleep 1
xdotool type "97"
sleep 1
xdotool key Return
sleep 1
xdotool key Next
sleep 1
xdotool key F6
sleep 1
xdotool key 1
sleep 1
xdotool mousemove 419 172
xdotool click 1
sleep 1
xdotool type "This is an important bit of history"
xdotool key Return
sleep 1
xdotool key alt+v
sleep 1
xdotool key Down Down Down Down Down Down Down Down
xdotool key Right Down
sleep 1
xdotool key Return
sleep 1
xdotool key ctrl+0
sleep 1
xdotool key ctrl++
sleep 1
xdotool key ctrl++
sleep 1
xdotool key ctrl++
sleep 1
xdotool key ctrl+0
sleep 1
xdotool key ctrl+minus
sleep 1
xdotool key ctrl+minus
sleep 1
xdotool key ctrl+shift+p
sleep 1
xdotool key Escape
sleep 1
xdotool key Left
sleep 1
xdotool key Left
sleep 1
xdotool key Left
sleep 1
xdotool key Left
sleep 1
xdotool key Escape
sleep 1
xdotool key ctrl+shift+comma
sleep 1
xdotool key Down
sleep 1
xdotool key Tab Tab Tab Tab Tab
sleep 1
xdotool key space
sleep 1
xdotool key alt+k
sleep 1
xdotool key alt+v
sleep 1
xdotool key Down Down Down Down Down Down Down Down Down
xdotool key Right
sleep 1
xdotool key Return
sleep 1
xdotool key ctrl+0
sleep 1
xdotool key ctrl+minus
sleep 1
xdotool key ctrl+g
sleep 1
xdotool type "111"
sleep 1
xdotool key Return
sleep 1
xdotool key ctrl+4
sleep 1
xdotool mousemove 483 320
xdotool mousedown 1
sleep 1
xdotool mousemove 567 360
sleep 1
xdotool mouseup 1
sleep 1
xdotool key ctrl+shift+p
sleep 1
xdotool key Escape
sleep 1
xdotool key Right
sleep 1
xdotool key Right
sleep 1
xdotool key Right
sleep 1
xdotool key Right
sleep 1
xdotool key Right
sleep 1
xdotool key Right
sleep 1
xdotool key Right
sleep 1
xdotool key Right
sleep 1
xdotool key Right
sleep 1
xdotool key Right
sleep 1
xdotool key Right
sleep 1
xdotool key Right
sleep 1
xdotool key Right
sleep 1
xdotool key Right
sleep 1
xdotool key Escape
sleep 1
xdotool key ctrl+q
xdotool key Right Return
# Standard Usage Scenarios
This directory contains a set of standard usage scenarios for certain application types. Energy measurements are done going through these scenarios with concrete applications and recording energy consumption and other parameters for the system under test.
# PDF Reader
* Open the document [20yearsofKDE.pdf](test_data/20yearsofKDE.pdf) from the local disk
* Jump to page 81 by entering the page number
* Highlight text of last paragraph on page 81
* Add a pop-up note "This is an important bit of history"
* Rotate the page right
* Zoom in to 200 %
* Zoom out to 50 %
* Enter presentation mode
* Go back 4 pages, page by page
* Exit presentation mode
* Activate inverted colors
* Rotate the page left
* Zoom to 150 %
* Jump to page 95 by entering the page number
* Highlight the text of the title
* Enter presentation mode
* Go forward 14 pages, page by page
* Exit presentation mode
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment