summaryrefslogtreecommitdiff
path: root/samples/pdfium_test.cc
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2017-07-11 16:42:43 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-13 14:41:45 +0000
commit95ea778b4411bbd46b21f93e391f3bbd3e798342 (patch)
treee7e998b59a5aae06ac2cda17065ac7a879a906ce /samples/pdfium_test.cc
parent17453d03c3bdd18a893ae86058a6184939aee026 (diff)
downloadpdfium-95ea778b4411bbd46b21f93e391f3bbd3e798342.tar.xz
Added Callgrind instrumentation delimiters to pdfium_test.
Change-Id: I664497b5bab640e642bde3f80aaeb62467237407 Reviewed-on: https://pdfium-review.googlesource.com/7281 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'samples/pdfium_test.cc')
-rw-r--r--samples/pdfium_test.cc32
1 files changed, 31 insertions, 1 deletions
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index 85cc0d3526..93821d963a 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -37,6 +37,10 @@
#include <unistd.h>
#endif
+#ifdef ENABLE_CALLGRIND
+#include <valgrind/callgrind.h>
+#endif // ENABLE_CALLGRIND
+
#ifdef PDF_ENABLE_V8
#include "v8/include/libplatform/libplatform.h"
#include "v8/include/v8.h"
@@ -76,13 +80,20 @@ struct Options {
: show_config(false),
show_metadata(false),
send_events(false),
+#ifdef ENABLE_CALLGRIND
+ callgrind_delimiters(false),
+#endif // ENABLE_CALLGRIND
pages(false),
md5(false),
- output_format(OUTPUT_NONE) {}
+ output_format(OUTPUT_NONE) {
+ }
bool show_config;
bool show_metadata;
bool send_events;
+#ifdef ENABLE_CALLGRIND
+ bool callgrind_delimiters;
+#endif // ENABLE_CALLGRIND
bool pages;
bool md5;
OutputFormat output_format;
@@ -624,6 +635,10 @@ bool ParseCommandLine(const std::vector<std::string>& args,
options->show_metadata = true;
} else if (cur_arg == "--send-events") {
options->send_events = true;
+#ifdef ENABLE_CALLGRIND
+ } else if (cur_arg == "--callgrind-delim") {
+ options->callgrind_delimiters = true;
+#endif // ENABLE_CALLGRIND
} else if (cur_arg == "--ppm") {
if (options->output_format != OUTPUT_NONE) {
fprintf(stderr, "Duplicate or conflicting --ppm argument\n");
@@ -1201,8 +1216,12 @@ static void ShowConfig() {
static const char kUsageString[] =
"Usage: pdfium_test [OPTION] [FILE]...\n"
" --show-config - print build options and exit\n"
+ " --show-metadata - print the file metadata\n"
" --show-structure - print the structure elements from the document\n"
" --send-events - send input described by .evt file\n"
+#ifdef ENABLE_CALLGRIND
+ " --callgrind-delim - delimit interesting section when using callgrind\n"
+#endif // ENABLE_CALLGRIND
" --bin-dir=<path> - override path to v8 external data\n"
" --font-dir=<path> - override path to external fonts\n"
" --scale=<number> - scale output size by number (e.g. 0.5)\n"
@@ -1281,6 +1300,12 @@ int main(int argc, const char* argv[]) {
if (!file_contents)
continue;
fprintf(stderr, "Rendering PDF file %s.\n", filename.c_str());
+
+#ifdef ENABLE_CALLGRIND
+ if (options.callgrind_delimiters)
+ CALLGRIND_START_INSTRUMENTATION;
+#endif // ENABLE_CALLGRIND
+
std::string events;
if (options.send_events) {
std::string event_filename = filename;
@@ -1301,6 +1326,11 @@ int main(int argc, const char* argv[]) {
}
}
RenderPdf(filename, file_contents.get(), file_length, options, events);
+
+#ifdef ENABLE_CALLGRIND
+ if (options.callgrind_delimiters)
+ CALLGRIND_STOP_INSTRUMENTATION;
+#endif // ENABLE_CALLGRIND
}
FPDF_DestroyLibrary();