()
| 146 | |
| 147 | |
| 148 | def main(): |
| 149 | parser = argparse.ArgumentParser(description=__doc__) |
| 150 | parser.add_argument( |
| 151 | "--features", |
| 152 | metavar="F[,F]*", |
| 153 | default=defaultFeatures, |
| 154 | help="Comma separated list of features to print. " + featuresDescription, |
| 155 | ) |
| 156 | parser.add_argument("--total", action="store_true", help="Add total time row.") |
| 157 | parser.add_argument("--gp", action="store_true", help="Print GNUPlot format.") |
| 158 | parser.add_argument("--no-header", action="store_true", help="Omit the header row.") |
| 159 | parser.add_argument("--threshold", metavar="T", default=0.0, type=float, help="Threshold of percentage difference.") |
| 160 | parser.add_argument("--reference", metavar="R", help="Reference profile file name.") |
| 161 | parser.add_argument("name", metavar="filename", help="Profile file.") |
| 162 | args = parser.parse_args() |
| 163 | |
| 164 | global allFeatures |
| 165 | features = args.features.split(",") |
| 166 | for f in features: |
| 167 | if not f in allFeatures: |
| 168 | print("Feature {} not recognized".format(f)) |
| 169 | return |
| 170 | |
| 171 | count = args.gp and not hasNames(features) |
| 172 | |
| 173 | profile = None |
| 174 | reference = None |
| 175 | |
| 176 | with open(args.name) as f: |
| 177 | profile = json.load(f) |
| 178 | profileCount = profile[0]["count"] |
| 179 | profile = profile[1:] |
| 180 | |
| 181 | if args.reference: |
| 182 | with open(args.reference) as f: |
| 183 | reference = json.load(f) |
| 184 | referenceCount = reference[0]["count"] |
| 185 | reference = reference[1:] |
| 186 | allFeatures = mergeHeaders(allFeatures) |
| 187 | features = mergeHeaders(features, hasNames(features)) |
| 188 | |
| 189 | if not args.no_header: |
| 190 | if reference: |
| 191 | comment = "#" if args.gp else "" |
| 192 | print(comment + "reference count: {} - profile count: {}".format(referenceCount, profileCount)) |
| 193 | pu.printHeader(allFeatures, features, args.gp, count) |
| 194 | |
| 195 | if reference: |
| 196 | profile = alignData(reference, profile, args.threshold) |
| 197 | |
| 198 | if args.total: |
| 199 | profile.append(totalData(allFeatures, profile)) |
| 200 | if reference: |
| 201 | total = profile[len(profile) - 1] |
| 202 | total["% difference"] = (total["averageMs"] / total["refAverageMs"] - 1) * 100 |
| 203 | |
| 204 | profile = pu.filterData(profile, allFeatures, features) |
| 205 |
no test coverage detected