collect.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/usr/bin/env python3
  2. #
  3. # Copyright (c) 2021 Project CHIP Authors
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. """Generate memory usage tables.
  18. This program reads memory usage information from some build artifact(s),
  19. optionally selects a subset, and writes the result.
  20. Use `--collect-method=help` to see available collection methods.
  21. Use `--output-format=help` to see available output formats.
  22. """
  23. import sys
  24. import memdf.collect
  25. import memdf.report
  26. import memdf.select
  27. def main(argv):
  28. status = 0
  29. try:
  30. config = memdf.collect.parse_args({
  31. **memdf.select.CONFIG,
  32. **memdf.report.REPORT_DEMANGLE_CONFIG,
  33. **memdf.report.OUTPUT_CONFIG
  34. }, argv)
  35. memdf.report.write_dfs(config, memdf.collect.collect_files(config))
  36. except Exception as exception:
  37. raise exception
  38. return status
  39. if __name__ == '__main__':
  40. sys.exit(main(sys.argv))