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 |
12 import common | 13 import common |
13 from autotest_lib.client.common_lib import barrier | 14 from autotest_lib.client.common_lib import barrier |
14 | 15 |
15 # Client control file snippet used to synchronize profiler start & stop. | 16 # Client control file snippet used to synchronize profiler start & stop. |
16 _RUNTEST_PATTERN = ("job.run_test('profiler_sync', timeout_sync=%r,\n" | 17 _RUNTEST_PATTERN = ("job.run_test('profiler_sync', timeout_sync=%r,\n" |
17 " timeout_start=%r, timeout_stop=%r,\n" | 18 " timeout_start=%r, timeout_stop=%r,\n" |
18 " hostid='%s', masterid='%s', all_ids=%r)") | 19 " hostid='%s', masterid='%s', all_ids=%r)") |
19 _PROF_MASTER = "PROF_MASTER" | 20 _PROF_MASTER = platform.node() |
20 _PORT = 11920 | 21 _PORT = 11920 |
21 | 22 |
22 | 23 |
23 def _encode_args(profiler, args, dargs): | 24 def _encode_args(profiler, args, dargs): |
24 parts = [repr(profiler)] | 25 parts = [repr(profiler)] |
25 parts += [repr(arg) for arg in args] | 26 parts += [repr(arg) for arg in args] |
26 parts += ["%s=%r" % darg for darg in dargs.iteritems()] | 27 parts += ["%s=%r" % darg for darg in dargs.iteritems()] |
27 return ", ".join(parts) | 28 return ", ".join(parts) |
28 | 29 |
29 | 30 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 def stop_profilers(machines, timeout=120): | 80 def stop_profilers(machines, timeout=120): |
80 sb = barrier.barrier(_PROF_MASTER, "stop_profilers", | 81 sb = barrier.barrier(_PROF_MASTER, "stop_profilers", |
81 timeout, port=_PORT) | 82 timeout, port=_PORT) |
82 sb.rendezvous_servers(_PROF_MASTER, *machines) | 83 sb.rendezvous_servers(_PROF_MASTER, *machines) |
83 | 84 |
84 | 85 |
85 def finish_profilers(machines, timeout=120): | 86 def finish_profilers(machines, timeout=120): |
86 sb = barrier.barrier(_PROF_MASTER, "finish_profilers", | 87 sb = barrier.barrier(_PROF_MASTER, "finish_profilers", |
87 timeout, port=_PORT) | 88 timeout, port=_PORT) |
88 sb.rendezvous_servers(_PROF_MASTER, *machines) | 89 sb.rendezvous_servers(_PROF_MASTER, *machines) |
OLD | NEW |