blob: b1319ca15078b7be1b916bd50fb6dea7c161aad0 [file] [log] [blame]
Yuheng Long16d7a522013-07-19 16:29:13 -07001# 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 Longf20cffa2013-06-03 18:46:00 -07005"""A reproducing entity.
6
Yuheng Long49358b72013-07-10 14:45:29 -07007Part of the Chrome build flags optimization.
8
Yuheng Longf20cffa2013-06-03 18:46:00 -07009The Task class is used by different modules. Each module fills in the
10corresponding information into a Task instance. Class Task contains the bit set
11representing the flags selection. The builder module is responsible for filling
12the image and the checksum field of a Task. The executor module will put the
13execution output to the execution field.
14"""
15
16__author__ = 'yuhenglong@google.com (Yuheng Long)'
17
18
19class 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 Long26ec76c2013-07-11 07:49:01 -070034 def ReproduceWith(self, other):
Yuheng Longf20cffa2013-06-03 18:46:00 -070035 """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 Long26ec76c2013-07-11 07:49:01 -070047 def Compile(self):
Yuheng Longf20cffa2013-06-03 18:46:00 -070048 """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 Long26ec76c2013-07-11 07:49:01 -070056 def GetFlags(self):
Yuheng Longf20cffa2013-06-03 18:46:00 -070057 pass
58
Yuheng Long26ec76c2013-07-11 07:49:01 -070059 def SetFlags(self, flags):
Yuheng Longf20cffa2013-06-03 18:46:00 -070060 pass
61
Yuheng Long26ec76c2013-07-11 07:49:01 -070062 def GetChecksum(self):
Yuheng Longf20cffa2013-06-03 18:46:00 -070063 pass
64
Yuheng Long26ec76c2013-07-11 07:49:01 -070065 def SetChecksum(self, checksum):
Yuheng Longf20cffa2013-06-03 18:46:00 -070066 pass
67
Yuheng Long26ec76c2013-07-11 07:49:01 -070068 def GetImage(self):
Yuheng Longf20cffa2013-06-03 18:46:00 -070069 pass
70
Yuheng Long26ec76c2013-07-11 07:49:01 -070071 def SetImage(self, image):
Yuheng Longf20cffa2013-06-03 18:46:00 -070072 pass