diff options
author | Fabien Sanglard <sanglardf@google.com> | 2019-02-21 15:13:29 -0800 |
---|---|---|
committer | Fabien Sanglard <sanglardf@google.com> | 2019-03-05 15:09:27 -0800 |
commit | 2d34e76daceaac41a8c578d7fa02aca864019dbb (patch) | |
tree | bd46b9065635728d88f2a6f40236c442ecad5f12 /tools/aapt2/io | |
parent | 63ebfcba5d62de4db9cfeb627ac98a4bc65ef425 (diff) |
Add --trace_folder to aapt2
Add a tracing API and instrument key functions in order to profile
aapt2 bottleneck. The API allows to generate systrace fragment files.
Impact on performance is neglibible with each Trace requiring less
than 1us and the final Flush operation at the end of a command
requiring around 40us.
Bug: None
Test: None
Change-Id: I51b564d3694e9384679f43b878b32295527dddf6
Diffstat (limited to 'tools/aapt2/io')
-rw-r--r-- | tools/aapt2/io/Util.cpp | 6 | ||||
-rw-r--r-- | tools/aapt2/io/ZipArchive.cpp | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/tools/aapt2/io/Util.cpp b/tools/aapt2/io/Util.cpp index 97516322c4cb..ce6d9352180d 100644 --- a/tools/aapt2/io/Util.cpp +++ b/tools/aapt2/io/Util.cpp @@ -18,6 +18,8 @@ #include "google/protobuf/io/zero_copy_stream_impl_lite.h" +#include "trace/TraceBuffer.h" + using ::android::StringPiece; using ::google::protobuf::io::ZeroCopyOutputStream; @@ -26,6 +28,7 @@ namespace io { bool CopyInputStreamToArchive(IAaptContext* context, InputStream* in, const std::string& out_path, uint32_t compression_flags, IArchiveWriter* writer) { + TRACE_CALL(); if (context->IsVerbose()) { context->GetDiagnostics()->Note(DiagMessage() << "writing " << out_path << " to archive"); } @@ -40,6 +43,7 @@ bool CopyInputStreamToArchive(IAaptContext* context, InputStream* in, const std: bool CopyFileToArchive(IAaptContext* context, io::IFile* file, const std::string& out_path, uint32_t compression_flags, IArchiveWriter* writer) { + TRACE_CALL(); std::unique_ptr<io::IData> data = file->OpenAsData(); if (!data) { context->GetDiagnostics()->Error(DiagMessage(file->GetSource()) << "failed to open file"); @@ -57,6 +61,7 @@ bool CopyFileToArchivePreserveCompression(IAaptContext* context, io::IFile* file bool CopyProtoToArchive(IAaptContext* context, ::google::protobuf::MessageLite* proto_msg, const std::string& out_path, uint32_t compression_flags, IArchiveWriter* writer) { + TRACE_CALL(); if (context->IsVerbose()) { context->GetDiagnostics()->Note(DiagMessage() << "writing " << out_path << " to archive"); } @@ -83,6 +88,7 @@ bool CopyProtoToArchive(IAaptContext* context, ::google::protobuf::MessageLite* } bool Copy(OutputStream* out, InputStream* in) { + TRACE_CALL(); const void* in_buffer; size_t in_len; while (in->Next(&in_buffer, &in_len)) { diff --git a/tools/aapt2/io/ZipArchive.cpp b/tools/aapt2/io/ZipArchive.cpp index 427dc92505d4..f6aaa1280a61 100644 --- a/tools/aapt2/io/ZipArchive.cpp +++ b/tools/aapt2/io/ZipArchive.cpp @@ -20,6 +20,7 @@ #include "ziparchive/zip_archive.h" #include "Source.h" +#include "trace/TraceBuffer.h" #include "util/Files.h" #include "util/Util.h" @@ -93,6 +94,7 @@ ZipFileCollection::ZipFileCollection() : handle_(nullptr) {} std::unique_ptr<ZipFileCollection> ZipFileCollection::Create( const StringPiece& path, std::string* out_error) { + TRACE_CALL(); constexpr static const int32_t kEmptyArchive = -6; std::unique_ptr<ZipFileCollection> collection = |