Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | # Copyright 2011 Google Inc. All Rights Reserved. |
| 4 | |
| 5 | import sys |
| 6 | import textwrap |
| 7 | from settings_factory import BenchmarkSettings |
| 8 | from settings_factory import GlobalSettings |
| 9 | from settings_factory import LabelSettings |
| 10 | |
| 11 | |
| 12 | class Help(object): |
| 13 | def GetUsage(self): |
| 14 | return """%s [OPTIONS] [ACTION] EXPERIMENT_FILE""" % (sys.argv[0]) |
| 15 | |
| 16 | def _WrapLine(self, line): |
| 17 | return "\n".join(textwrap.wrap(line, 80)) |
| 18 | |
| 19 | def _GetFieldDescriptions(self, fields): |
| 20 | res = "" |
| 21 | for field_name in fields: |
| 22 | field = fields[field_name] |
| 23 | res += "Field:\t\t%s\n" % field.name |
| 24 | res += self._WrapLine("Description:\t%s" % field.description) + "\n" |
| 25 | res += "Type:\t\t%s\n" % type(field).__name__.replace("Field", "") |
| 26 | res += "Required:\t%s\n" % field.required |
| 27 | if field.default: |
| 28 | res += "Default:\t%s\n" % field.default |
| 29 | res += "\n" |
| 30 | return res |
| 31 | |
| 32 | def GetHelp(self): |
| 33 | global_fields = self._GetFieldDescriptions(GlobalSettings("").fields) |
| 34 | benchmark_fields = self._GetFieldDescriptions(BenchmarkSettings("").fields) |
| 35 | label_fields = self._GetFieldDescriptions(LabelSettings("").fields) |
| 36 | |
| 37 | return """%s is a script for running performance experiments on ChromeOS. It |
| 38 | allows one to run ChromeOS Autotest benchmarks over several images and compare |
| 39 | the results to determine whether there is a performance difference. |
| 40 | |
| 41 | Comparing several images using %s is referred to as running an |
| 42 | "experiment". An "experiment file" is a configuration file which holds all the |
| 43 | information that describes the experiment and how it should be run. An example |
| 44 | of a simple experiment file is below: |
| 45 | |
| 46 | --------------------------------- test.exp --------------------------------- |
| 47 | name: my_experiment |
| 48 | board: x86-alex |
| 49 | remote: chromeos-alex5 172.18.122.132 |
| 50 | |
| 51 | benchmark: PageCycler { |
| 52 | iterations: 3 |
| 53 | } |
| 54 | |
| 55 | my_first_image { |
| 56 | chromeos_image: /usr/local/chromeos-1/chromiumos_image.bin |
| 57 | } |
| 58 | |
| 59 | my_second_image { |
| 60 | chromeos_image: /usr/local/chromeos-2/chromiumos_image.bin |
| 61 | } |
| 62 | ---------------------------------------------------------------------------- |
| 63 | |
| 64 | This experiment file names the experiment "my_experiment". It will be run |
| 65 | on the board x86-alex. Benchmarks will be run using two remote devices, |
| 66 | one is a device specified by a hostname and the other is a device specified |
| 67 | by it's IP address. Benchmarks will be run in parallel across these devices. |
| 68 | There is currently no way to specify which benchmark will run on each device. |
| 69 | |
| 70 | We define one "benchmark" that will be run, PageCycler. This benchmark has one |
| 71 | "field" which specifies how many iterations it will run for. |
| 72 | |
| 73 | We specify 2 "labels" or images which will be compared. The PageCycler benchmark |
| 74 | will be run on each of these images 3 times and a result table will be output |
| 75 | which compares the two. |
| 76 | |
| 77 | The full list of fields that can be specified are as follows: |
| 78 | ================= |
| 79 | Global Fields |
| 80 | ================= |
| 81 | %s |
| 82 | ================= |
| 83 | Benchmark Fields |
| 84 | ================= |
| 85 | %s |
| 86 | ================= |
| 87 | Label Fields |
| 88 | ================= |
| 89 | %s |
| 90 | |
| 91 | Note that global fields are overidden by label or benchmark fields, if they can |
| 92 | be specified in both places. Fields that are specified as arguments override |
| 93 | fields specified in experiment files. |
| 94 | |
| 95 | %s is invoked by passing it a path to an experiment file, as well as an action |
| 96 | to execute on that experiment file. The possible actions to use are: |
| 97 | |
| 98 | run\t\tRun the experiment and cache the results. |
| 99 | |
| 100 | table\t\tDisplay cached results of an experiment, without running anything. |
| 101 | |
| 102 | email\t\tEmail a summary of the results to the user. |
| 103 | |
| 104 | do\t\tThe default action. Executes the following actions: run, table, email. |
| 105 | """ % (sys.argv[0], sys.argv[0], global_fields, |
| 106 | benchmark_fields, label_fields, sys.argv[0]) |