summaryrefslogtreecommitdiffstats
path: root/src/manifest_parser_perftest.cc
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2014-04-17 05:05:32 (GMT)
committerNico Weber <nicolasweber@gmx.de>2014-04-17 05:06:56 (GMT)
commit8d43f6ba5ad7d974b70b9bff3da4b515978d7082 (patch)
treea26325a4bf9faa53ad2bfe96accf09fb4f388f84 /src/manifest_parser_perftest.cc
parent993803ed2a22c24b45d09f750e4527a05c7900c0 (diff)
downloadNinja-8d43f6ba5ad7d974b70b9bff3da4b515978d7082.zip
Ninja-8d43f6ba5ad7d974b70b9bff3da4b515978d7082.tar.gz
Ninja-8d43f6ba5ad7d974b70b9bff3da4b515978d7082.tar.bz2
Manifest perftest: Also measure command evaluation time.
Diffstat (limited to 'src/manifest_parser_perftest.cc')
-rw-r--r--src/manifest_parser_perftest.cc36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/manifest_parser_perftest.cc b/src/manifest_parser_perftest.cc
index 208d3a3..4fb6a76 100644
--- a/src/manifest_parser_perftest.cc
+++ b/src/manifest_parser_perftest.cc
@@ -24,6 +24,7 @@
#endif
#include "disk_interface.h"
+#include "graph.h"
#include "manifest_parser.h"
#include "metrics.h"
#include "state.h"
@@ -46,11 +47,26 @@ bool WriteFakeManifests(const string& dir) {
return err == 0;
}
-int main() {
+int main(int argc, char* argv[]) {
+ bool measure_command_evaluation = true;
+ int opt;
+ while ((opt = getopt(argc, argv, const_cast<char*>("fh"))) != -1) {
+ switch (opt) {
+ case 'f':
+ measure_command_evaluation = false;
+ break;
+ case 'h':
+ default:
+ printf("usage: manifest_parser_perftest\n"
+"\n"
+"options:\n"
+" -f only measure manifest load time, not command evaluation time\n"
+ );
+ return 1;
+ }
+ }
+
const char kManifestDir[] = "build/manifest_perftest";
- RealFileReader file_reader;
- vector<int> times;
- string err;
if (!WriteFakeManifests(kManifestDir)) {
fprintf(stderr, "Failed to write test data\n");
@@ -60,6 +76,9 @@ int main() {
chdir(kManifestDir);
const int kNumRepetitions = 5;
+ RealFileReader file_reader;
+ vector<int> times;
+ string err;
for (int i = 0; i < kNumRepetitions; ++i) {
int64_t start = GetTimeMillis();
@@ -69,9 +88,16 @@ int main() {
fprintf(stderr, "Failed to read test data: %s\n", err.c_str());
return 1;
}
+ // Doing an empty build involves reading the manifest and evaluating all
+ // commands required for the requested targets. So include command
+ // evaluation in the perftest by default.
+ int optimization_guard = 0;
+ if (measure_command_evaluation)
+ for (size_t i = 0; i < state.edges_.size(); ++i)
+ optimization_guard += state.edges_[i]->EvaluateCommand().size();
int delta = (int)(GetTimeMillis() - start);
- printf("%dms\n", delta);
+ printf("%dms (hash: %x)\n", delta, optimization_guard);
times.push_back(delta);
}