Merge lp:~aacid/ubuntu-performance-tests/idlecputime into lp:ubuntu-performance-tests

Proposed by Albert Astals Cid
Status: Merged
Merged at revision: 25
Proposed branch: lp:~aacid/ubuntu-performance-tests/idlecputime
Merge into: lp:ubuntu-performance-tests
Diff against target: 111 lines (+101/-0)
2 files modified
kpi/idlecputime/__init__.py (+19/-0)
kpi/idlecputime/runner.py (+82/-0)
To merge this branch: bzr merge lp:~aacid/ubuntu-performance-tests/idlecputime
Reviewer Review Type Date Requested Status
Sergio Cazzolato Pending
Review via email: mp+297620@code.launchpad.net

Commit message

Add a test that captures cpu time used when idle

Will help us find out regressions like bug #1588873

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'kpi/idlecputime'
2=== added file 'kpi/idlecputime/__init__.py'
3--- kpi/idlecputime/__init__.py 1970-01-01 00:00:00 +0000
4+++ kpi/idlecputime/__init__.py 2016-06-16 12:36:58 +0000
5@@ -0,0 +1,19 @@
6+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
7+
8+#
9+# Ubuntu System Tests
10+# Copyright (C) 2016 Canonical
11+#
12+# This program is free software: you can redistribute it and/or modify
13+# it under the terms of the GNU General Public License as published by
14+# the Free Software Foundation, either version 3 of the License, or
15+# (at your option) any later version.
16+#
17+# This program is distributed in the hope that it will be useful,
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+# GNU General Public License for more details.
21+#
22+# You should have received a copy of the GNU General Public License
23+# along with this program. If not, see <http://www.gnu.org/licenses/>.
24+#
25
26=== added file 'kpi/idlecputime/runner.py'
27--- kpi/idlecputime/runner.py 1970-01-01 00:00:00 +0000
28+++ kpi/idlecputime/runner.py 2016-06-16 12:36:58 +0000
29@@ -0,0 +1,82 @@
30+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
31+
32+#
33+# Ubuntu System Tests
34+# Copyright (C) 2016 Canonical
35+#
36+# This program is free software: you can redistribute it and/or modify
37+# it under the terms of the GNU General Public License as published by
38+# the Free Software Foundation, either version 3 of the License, or
39+# (at your option) any later version.
40+#
41+# This program is distributed in the hope that it will be useful,
42+# but WITHOUT ANY WARRANTY; without even the implied warranty of
43+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44+# GNU General Public License for more details.
45+#
46+# You should have received a copy of the GNU General Public License
47+# along with this program. If not, see <http://www.gnu.org/licenses/>.
48+#
49+
50+from argparse import ArgumentParser
51+import datetime
52+import logging
53+import os
54+import sys
55+import time
56+
57+from utils import executor
58+
59+logger = logging.getLogger(__name__)
60+
61+def setup(args):
62+ try:
63+ if args.serial:
64+ executor.set_serial(args.serial)
65+ executor.set_password(args.password)
66+ executor.log_global_info()
67+ except Exception as e:
68+ logger.error('Error during device setup: {}'.format(e))
69+ sys.exit(1)
70+
71+
72+def prepare_device():
73+ try:
74+ executor.reboot_device()
75+ executor.wait_for_device()
76+ except Exception as e:
77+ logger.error('Error preparing the device: {}'.format(e))
78+ sys.exit(1)
79+
80+
81+def parse(remaining_argv):
82+ args_parser = ArgumentParser("Parse times from kpi")
83+ args_parser.add_argument('-i', '--iterations', default=5,
84+ type=int, help='Number of iterations')
85+ return args_parser.parse_args(args=remaining_argv)
86+
87+
88+def log_ps_time(process_name):
89+ timestr = executor.execute_remote_command("ps -p \`pidof {}\` -o bsdtime | sed 1d".format(process_name)).strip()
90+ x = time.strptime(timestr,'%M:%S')
91+ seconds = datetime.timedelta(hours=x.tm_hour,minutes=x.tm_min,seconds=x.tm_sec).total_seconds()
92+ executor.log_time_info(executor.build_time_info(seconds, "cpuidletime", "seconds", process_name))
93+
94+
95+def run_test():
96+ # idle for three minutes
97+ time.sleep(180)
98+
99+ # Get the cpu time
100+ log_ps_time("unity8")
101+ log_ps_time("unity8-dash")
102+
103+def main(global_args, remaining_argv):
104+ local_args = parse(remaining_argv)
105+
106+ setup(global_args)
107+ prepare_device()
108+
109+ for x in range(local_args.iterations):
110+ run_test()
111+ prepare_device()

Subscribers

People subscribed via source and target branches