grokbuild.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/env python
  2. # Copyright (c) 2010-2011 Nokia Corporation and/or its subsidiary(-ies).
  3. # All rights reserved.
  4. # This component and the accompanying materials are made available
  5. # under the terms of the License "Eclipse Public License v1.0"
  6. # which accompanies this distribution, and is available
  7. # at the URL "http://www.eclipse.org/legal/epl-v10.html".
  8. """
  9. Gathers performance metrics from the logs of a complex multi-step build.
  10. Supports Helium 9 at the moment with Helium 13 coming soon [?].
  11. Can also extract useful data from emake annotation files.
  12. """
  13. import datetime
  14. import optparse
  15. import os
  16. import re
  17. import sys
  18. # raptor packages are in ../python relative to this script
  19. sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "python"))
  20. import allo.helium
  21. parser = optparse.OptionParser(prog = "grokbuild",
  22. usage = """%prog [-h | options] path_to_EPOCROOT
  23. The build logs are usually in $EPOCROOT/output/logs""")
  24. parser.add_option("--maxagents", type="int", default=30,
  25. help="The number of simultaneous agents used in the build. You need to "
  26. "supply this if --emake-class was used rather than --emake-maxagents "
  27. "since this is then a property of the build cluster and is not usually "
  28. "recorded in the logs. The default is %default.")
  29. parser.add_option("--output", default="-",
  30. help="The name of the output file to store the grok results in. A value "
  31. "of '-' can be used to write to the standard output. The default "
  32. "is '%default'.")
  33. (options, args) = parser.parse_args()
  34. if len(args) == 0:
  35. sys.stderr.write("Need at least one argument: a path to the logs.\n")
  36. sys.exit(-1)
  37. epocroot = args[0]
  38. sys.stderr.write("Gathering Performance Metrics for %s\n" % epocroot)
  39. b = allo.helium.HeliumLogDir(epocroot, options)
  40. if options.output == "-":
  41. b.write(sys.stdout)
  42. else:
  43. with open(options.output, "w") as stream:
  44. b.write(stream)