OLD | NEW |
1 # | 1 # |
2 # Copyright 2007 Google Inc. All Rights Reserved. | 2 # Copyright 2007 Google Inc. All Rights Reserved. |
3 | 3 |
4 """Runs profilers on a machine when no autotest job is running. | 4 """Runs profilers on a machine when no autotest job is running. |
5 | 5 |
6 This is used to profile a task when the task is running on a machine that is not | 6 This is used to profile a task when the task is running on a machine that is not |
7 running through autotest. | 7 running through autotest. |
8 """ | 8 """ |
9 | 9 |
10 __author__ = 'cranger@google.com (Colby Ranger)' | 10 __author__ = 'cranger@google.com (Colby Ranger)' |
11 | 11 |
12 import platform | |
13 import common | 12 import common |
14 from autotest_lib.client.common_lib import barrier | 13 from autotest_lib.client.common_lib import barrier |
15 | 14 |
16 # Client control file snippet used to synchronize profiler start & stop. | 15 # Client control file snippet used to synchronize profiler start & stop. |
17 _RUNTEST_PATTERN = ("job.run_test('profiler_sync', timeout_sync=%r,\n" | 16 _RUNTEST_PATTERN = ("job.run_test('profiler_sync', timeout_sync=%r,\n" |
18 " timeout_start=%r, timeout_stop=%r,\n" | 17 " timeout_start=%r, timeout_stop=%r,\n" |
19 " hostid='%s', masterid='%s', all_ids=%r)") | 18 " hostid='%s', masterid='%s', all_ids=%r)") |
20 _PROF_MASTER = platform.node() | 19 _PROF_MASTER = "PROF_MASTER" |
21 _PORT = 11920 | 20 _PORT = 11920 |
22 | 21 |
23 | 22 |
24 def _encode_args(profiler, args, dargs): | 23 def _encode_args(profiler, args, dargs): |
25 parts = [repr(profiler)] | 24 parts = [repr(profiler)] |
26 parts += [repr(arg) for arg in args] | 25 parts += [repr(arg) for arg in args] |
27 parts += ["%s=%r" % darg for darg in dargs.iteritems()] | 26 parts += ["%s=%r" % darg for darg in dargs.iteritems()] |
28 return ", ".join(parts) | 27 return ", ".join(parts) |
29 | 28 |
30 | 29 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 def stop_profilers(machines, timeout=120): | 79 def stop_profilers(machines, timeout=120): |
81 sb = barrier.barrier(_PROF_MASTER, "stop_profilers", | 80 sb = barrier.barrier(_PROF_MASTER, "stop_profilers", |
82 timeout, port=_PORT) | 81 timeout, port=_PORT) |
83 sb.rendezvous_servers(_PROF_MASTER, *machines) | 82 sb.rendezvous_servers(_PROF_MASTER, *machines) |
84 | 83 |
85 | 84 |
86 def finish_profilers(machines, timeout=120): | 85 def finish_profilers(machines, timeout=120): |
87 sb = barrier.barrier(_PROF_MASTER, "finish_profilers", | 86 sb = barrier.barrier(_PROF_MASTER, "finish_profilers", |
88 timeout, port=_PORT) | 87 timeout, port=_PORT) |
89 sb.rendezvous_servers(_PROF_MASTER, *machines) | 88 sb.rendezvous_servers(_PROF_MASTER, *machines) |
OLD | NEW |