(performance_json_path, performance_json, new_json_numbers)
| 11 | return dict(items) |
| 12 | |
| 13 | def update_performance_numbers(performance_json_path, performance_json, new_json_numbers): |
| 14 | for key, items in new_json_numbers.items(): |
| 15 | if len(key) == 0: |
| 16 | continue |
| 17 | |
| 18 | if not key in performance_json["Instructions"]: |
| 19 | logging.error("{} didn't exist in performance json file?".format(key)) |
| 20 | return 1 |
| 21 | |
| 22 | if "ExpectedInstructionCount" in items: |
| 23 | performance_json["Instructions"][key]["ExpectedInstructionCount"] = items["ExpectedInstructionCount"] |
| 24 | if "ExpectedArm64ASM" in items: |
| 25 | performance_json["Instructions"][key]["ExpectedArm64ASM"] = items["ExpectedArm64ASM"] |
| 26 | if "x86Insts" in performance_json["Instructions"][key]: |
| 27 | d = performance_json["Instructions"][key] |
| 28 | d.pop('x86InstructionCount', None) |
| 29 | d = insert_before(d, "ExpectedInstructionCount", |
| 30 | ("x86InstructionCount", len(d["x86Insts"]))) |
| 31 | performance_json["Instructions"][key] = d |
| 32 | |
| 33 | # Output to the original file. |
| 34 | with open(performance_json_path, "w") as json_file: |
| 35 | json.dump(performance_json, json_file, indent=2) |
| 36 | json_file.write("\n") |
| 37 | |
| 38 | def main(): |
| 39 | if sys.version_info[0] < 3: |
no test coverage detected