summaryrefslogtreecommitdiff
path: root/server/standalone_profiler.py
blob: 22801fd201095152d326fa0a97e6015f9b2e2bc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python2.4
#
# Copyright 2007 Google Inc. All Rights Reserved.

"""Runs profilers on a machine when no autotest job is running.

This is used to profile a task when the task is running on a machine that is not
running through autotest.
"""

__author__ = 'cranger@google.com (Colby Ranger)'

from autotest_lib.client.common_lib import barrier


def generate_test(machines, hostname, profilers, timeout_start, timeout_stop,
			timeout_sync=180):
	control_file = []
	for profiler in profilers:
		control_file.append("job.profilers.add(%s)"
					% str(profiler)[1:-1])  # Remove parens

	control_file.append("job.run_test('barriertest',%d,%d,%d,'%s','%s',%s)"
			% (timeout_sync, timeout_start, timeout_stop,
				hostname, "PROF_MASTER", str(machines)))

	for profiler in profilers:
		control_file.append("job.profilers.delete('%s')" % profiler[0])

	return "\n".join(control_file)


def wait_for_profilers(machines, timeout = 300):
	sb = barrier.barrier("PROF_MASTER", "sync_profilers",
		timeout, port=63100)
	sb.rendevous_servers("PROF_MASTER", *machines)


def start_profilers(machines, timeout = 120):
	sb = barrier.barrier("PROF_MASTER", "start_profilers",
		timeout, port=63100)
	sb.rendevous_servers("PROF_MASTER", *machines)


def stop_profilers(machines, timeout = 120):
	sb = barrier.barrier("PROF_MASTER", "stop_profilers",
		timeout, port=63100)
	sb.rendevous_servers("PROF_MASTER", *machines)