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

Subscribers

People subscribed via source and target branches