Yuheng Long | 16d7a52 | 2013-07-19 16:29:13 -0700 | [diff] [blame] | 1 | # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
Yuheng Long | f20cffa | 2013-06-03 18:46:00 -0700 | [diff] [blame] | 5 | """A reproducing entity. |
| 6 | |
Yuheng Long | 49358b7 | 2013-07-10 14:45:29 -0700 | [diff] [blame] | 7 | Part of the Chrome build flags optimization. |
| 8 | |
Yuheng Long | f20cffa | 2013-06-03 18:46:00 -0700 | [diff] [blame] | 9 | The Task class is used by different modules. Each module fills in the |
| 10 | corresponding information into a Task instance. Class Task contains the bit set |
| 11 | representing the flags selection. The builder module is responsible for filling |
| 12 | the image and the checksum field of a Task. The executor module will put the |
| 13 | execution output to the execution field. |
| 14 | """ |
| 15 | |
| 16 | __author__ = 'yuhenglong@google.com (Yuheng Long)' |
| 17 | |
| 18 | |
| 19 | class Task(object): |
| 20 | """A single reproducing entity. |
| 21 | |
| 22 | A single test of performance with a particular set of flags. It records the |
| 23 | flag set, the image, the check sum of the image and the cost. |
| 24 | """ |
| 25 | |
| 26 | def __init__(self, flag_set): |
| 27 | """Set up the optimization flag selection for this task. |
| 28 | |
| 29 | Args: |
| 30 | flag_set: the optimization flag set that is encapsulated by this task. |
| 31 | """ |
| 32 | self._flag_set = flag_set |
| 33 | |
Yuheng Long | 26ec76c | 2013-07-11 07:49:01 -0700 | [diff] [blame] | 34 | def ReproduceWith(self, other): |
Yuheng Long | f20cffa | 2013-06-03 18:46:00 -0700 | [diff] [blame] | 35 | """Create a new SolutionCandidate by reproduction with another. |
| 36 | |
| 37 | Mix two Tasks together to form a new Task of the same class. This is one of |
| 38 | the core functions of a GA. |
| 39 | |
| 40 | Args: |
| 41 | other: The other Task to reproduce with. |
| 42 | |
| 43 | Returns: A Task that is a mix between self and other. |
| 44 | """ |
| 45 | pass |
| 46 | |
Yuheng Long | 26ec76c | 2013-07-11 07:49:01 -0700 | [diff] [blame] | 47 | def Compile(self): |
Yuheng Long | f20cffa | 2013-06-03 18:46:00 -0700 | [diff] [blame] | 48 | """Run a compile. |
| 49 | |
| 50 | This method compile an image using the present flags, get the image, |
| 51 | test the existent of the image and gathers monitoring information, and sets |
| 52 | the internal cost (fitness) for this set of flags. |
| 53 | """ |
| 54 | pass |
| 55 | |
Yuheng Long | 26ec76c | 2013-07-11 07:49:01 -0700 | [diff] [blame] | 56 | def GetFlags(self): |
Yuheng Long | f20cffa | 2013-06-03 18:46:00 -0700 | [diff] [blame] | 57 | pass |
| 58 | |
Yuheng Long | 26ec76c | 2013-07-11 07:49:01 -0700 | [diff] [blame] | 59 | def SetFlags(self, flags): |
Yuheng Long | f20cffa | 2013-06-03 18:46:00 -0700 | [diff] [blame] | 60 | pass |
| 61 | |
Yuheng Long | 26ec76c | 2013-07-11 07:49:01 -0700 | [diff] [blame] | 62 | def GetChecksum(self): |
Yuheng Long | f20cffa | 2013-06-03 18:46:00 -0700 | [diff] [blame] | 63 | pass |
| 64 | |
Yuheng Long | 26ec76c | 2013-07-11 07:49:01 -0700 | [diff] [blame] | 65 | def SetChecksum(self, checksum): |
Yuheng Long | f20cffa | 2013-06-03 18:46:00 -0700 | [diff] [blame] | 66 | pass |
| 67 | |
Yuheng Long | 26ec76c | 2013-07-11 07:49:01 -0700 | [diff] [blame] | 68 | def GetImage(self): |
Yuheng Long | f20cffa | 2013-06-03 18:46:00 -0700 | [diff] [blame] | 69 | pass |
| 70 | |
Yuheng Long | 26ec76c | 2013-07-11 07:49:01 -0700 | [diff] [blame] | 71 | def SetImage(self, image): |
Yuheng Long | f20cffa | 2013-06-03 18:46:00 -0700 | [diff] [blame] | 72 | pass |