You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

container.py 3.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. # Copyright 2020 Huawei Technologies Co., Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ============================================================================
  15. """The container of metadata used in profiler parser."""
  16. class HWTSContainer:
  17. """
  18. HWTS output container.
  19. Args:
  20. split_list (list): The split list of metadata in HWTS output file.
  21. """
  22. def __init__(self, split_list):
  23. self._op_name = ''
  24. self._duration = None
  25. self._status = split_list[0]
  26. self._task_id = split_list[6]
  27. self._cycle_counter = float(split_list[7])
  28. self._stream_id = split_list[8]
  29. @property
  30. def status(self):
  31. """Get the status of the operator, i.e. Start or End."""
  32. return self._status
  33. @property
  34. def task_id(self):
  35. """Get the task id of the operator."""
  36. return self._task_id
  37. @property
  38. def cycle_counter(self):
  39. """Get the cycle counter."""
  40. return self._cycle_counter
  41. @property
  42. def stream_id(self):
  43. """Get the stream id of the operator."""
  44. return self._stream_id
  45. @property
  46. def op_name(self):
  47. """Get the name of the operator."""
  48. return self._op_name
  49. @op_name.setter
  50. def op_name(self, name):
  51. """Set the name of the operator."""
  52. self._op_name = name
  53. @property
  54. def duration(self):
  55. """Get the duration of the operator execution."""
  56. return self._duration
  57. @duration.setter
  58. def duration(self, value):
  59. """Set the duration of the operator execution."""
  60. self._duration = value
  61. class TimelineContainer:
  62. """
  63. A container of operator computation metadata.
  64. Args:
  65. split_list (list): The split list of metadata in op_compute output file.
  66. """
  67. def __init__(self, split_list):
  68. self._op_name = split_list[0]
  69. self._stream_id = str(split_list[1])
  70. self._start_time = float(split_list[2])
  71. self._duration = float(split_list[3])
  72. self._pid = None
  73. if len(split_list) == 5:
  74. self._pid = int(split_list[4])
  75. @property
  76. def op_name(self):
  77. """Get the name of the operator."""
  78. return self._op_name
  79. @property
  80. def stream_id(self):
  81. """Get the stream id of the operator."""
  82. return self._stream_id
  83. @property
  84. def start_time(self):
  85. """Get the execution start time of the operator."""
  86. return self._start_time
  87. @property
  88. def duration(self):
  89. """Get the duration of the operator execution."""
  90. return self._duration
  91. @property
  92. def pid(self):
  93. """Get the pid of the operator execution."""
  94. return self._pid