(line)
| 28 | |
| 29 | |
| 30 | def decode_profile_line(line): |
| 31 | space_separated = line.split(" ") |
| 32 | if len(space_separated) == 3: |
| 33 | ts = int(space_separated[0]) |
| 34 | print(datetime.datetime.fromtimestamp(ts / 1000.0).isoformat(), space_separated[1]) |
| 35 | base64_encoded = space_separated[2] |
| 36 | elif len(space_separated) == 1: |
| 37 | base64_encoded = space_separated[0] |
| 38 | else: |
| 39 | raise Exception("Unexpected line: " + line) |
| 40 | possibly_compressed = base64.b64decode(base64_encoded) |
| 41 | # Handle both compressed and uncompressed Thrift profiles |
| 42 | try: |
| 43 | thrift = zlib.decompress(possibly_compressed) |
| 44 | except zlib.error: |
| 45 | thrift = possibly_compressed |
| 46 | |
| 47 | tree = TRuntimeProfileTree() |
| 48 | deserialize(tree, thrift, protocol_factory=TCompactProtocol.TCompactProtocolFactory()) |
| 49 | tree.validate() |
| 50 | |
| 51 | return tree |
nothing calls this directly
no test coverage detected