Skip to content

Commit 8455db5

Browse files
committed
docs(getting-started): Getting started archive is ready for use
The first version of the getting started archive is ready to be used and tested.
1 parent a0d8de3 commit 8455db5

File tree

2 files changed

+88
-18
lines changed

2 files changed

+88
-18
lines changed
Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,64 @@
1+
# Copyright (c) 2024, INRIA
2+
# Copyright (c) 2024, University of Lille
3+
# All rights reserved.
4+
#
5+
# Redistribution and use in source and binary forms, with or without
6+
# modification, are permitted provided that the following conditions are met:
7+
#
8+
# * Redistributions of source code must retain the above copyright notice, this
9+
# list of conditions and the following disclaimer.
10+
#
11+
# * Redistributions in binary form must reproduce the above copyright notice,
12+
# this list of conditions and the following disclaimer in the documentation
13+
# and/or other materials provided with the distribution.
14+
#
15+
# * Neither the name of the copyright holder nor the names of its
16+
# contributors may be used to endorse or promote products derived from
17+
# this software without specific prior written permission.
18+
#
19+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
130
import csv
231
import os
332

433

534
def start_pretty_print():
635
"""
7-
Pretty print the result of the demo by parsing the csv files of each cgroup,
8-
then proceed to calculate the average, maximum, and minimum consumption of each cgroup
36+
Pretty print the result of the demo by parsing the csv files,
37+
then proceed to calculate the average, maximum, and minimum consumption
938
and print them in a table format
1039
"""
1140
data = []
12-
result = [["Cgroup", "Average consumption", "Maximum consumption", "Minimum consumption"]]
13-
14-
directory = './csv'
41+
result = [["Cgroup",
42+
"Average consumption",
43+
"Maximum consumption",
44+
"Minimum consumption"]]
1545

16-
print("\nThe consumptions are given in Watt, note that the precision depend on the value given in the configuration file (the base CPU frequence, the CPU TDP, ...) \n")
46+
print("\nThe consumptions are given in Watt, "
47+
"note that the precision depend on the value given in the "
48+
"configuration file (the base CPU frequency, the CPU TDP, ...) \n")
1749

1850
# Get all the csv power report in the csv directory
19-
for dirpath, dirnames, filenames in os.walk(directory):
20-
for filename in filenames:
51+
for root, _, files in os.walk('./csv'):
52+
for filename in files:
2153
if filename.endswith('.csv'):
22-
file_path = os.path.join(dirpath, filename)
54+
file_path = os.path.join(root, filename)
2355

24-
with open(file_path, mode='r', newline='') as f:
25-
reader = csv.DictReader(f)
26-
for row in reader:
56+
with open(file_path, mode='r', newline='', encoding='UTF-8') as f:
57+
for row in csv.DictReader(f):
2758
data.append(row)
2859

2960
cgroup_data = {}
30-
61+
total = [0, 0, 0]
3162
# We remove rapl, but it's still available in the csv files
3263
for row in data:
3364
target = row['target']
@@ -45,20 +76,32 @@ def start_pretty_print():
4576
min_consumption = min(consumptions)
4677

4778
if not target == 'global':
48-
result.append([target, f"{avg_consumption:.2f}", f"{max_consumption:.2f}", f"{min_consumption:.2f}"])
79+
result.append([target,
80+
f"{avg_consumption:.2f}",
81+
f"{max_consumption:.2f}",
82+
f"{min_consumption:.2f}"])
4983
else:
5084
total = [avg_consumption, max_consumption, min_consumption]
5185

52-
print(f"{'Cgroup':<20} {'Average consumption':<20} {'Maximum consumption':<20} {'Minimum consumption':<20}")
86+
print(f"{'Target':<20} "
87+
f"{'Average consumption':<20} "
88+
f"{'Maximum consumption':<20} "
89+
f"{'Minimum consumption':<20}")
5390
print("=" * 80)
5491

5592
for row in result[1:]:
5693
print(f"{row[0]:<20} {row[1]:<20} {row[2]:<20} {row[3]:<20}")
5794

5895
print("=" * 80)
59-
print(f"{'Global':<20} {total[0]:<20.2f} {total[1]:<20.2f} {total[2]:<20.2f}")
96+
print(f"{'Global':<20} "
97+
f"{total[0]:<20.2f} "
98+
f"{total[1]:<20.2f} "
99+
f"{total[2]:<20.2f}")
100+
101+
print("\nIf you want to get a more precise evaluation, "
102+
"we encourage you to read the documentation of PowerAPI "
103+
"and adapt the sensor/formula configuration file in consequence \n")
60104

61-
print("\nIf you want to get a more precise evaluation, we encourage you to read the documentation of PowerAPI and adapte the sensor and formula configuration file in consequence \n")
62105

63106
if __name__ == '__main__':
64107
start_pretty_print()

docs/script/getting_started/start.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
1-
1+
# Copyright (c) 2024, INRIA
2+
# Copyright (c) 2024, University of Lille
3+
# All rights reserved.
4+
#
5+
# Redistribution and use in source and binary forms, with or without
6+
# modification, are permitted provided that the following conditions are met:
7+
#
8+
# * Redistributions of source code must retain the above copyright notice, this
9+
# list of conditions and the following disclaimer.
10+
#
11+
# * Redistributions in binary form must reproduce the above copyright notice,
12+
# this list of conditions and the following disclaimer in the documentation
13+
# and/or other materials provided with the distribution.
14+
#
15+
# * Neither the name of the copyright holder nor the names of its
16+
# contributors may be used to endorse or promote products derived from
17+
# this software without specific prior written permission.
18+
#
19+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
229

330
import sys
431
from subprocess import call

0 commit comments

Comments
 (0)