diff options
author | Nico Weber <nicolasweber@gmx.de> | 2014-04-17 05:12:30 (GMT) |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2014-04-17 05:12:30 (GMT) |
commit | 6e014f6e21205f38259eb651f81953867779bc7d (patch) | |
tree | c5f4f1c8d58da3f2373db97d272d057ec1295629 /src | |
parent | e5604290ba366ce114a070d5008c2ab69de5d59e (diff) | |
download | Ninja-6e014f6e21205f38259eb651f81953867779bc7d.zip Ninja-6e014f6e21205f38259eb651f81953867779bc7d.tar.gz Ninja-6e014f6e21205f38259eb651f81953867779bc7d.tar.bz2 |
Manifest perftest: Pull manifest parsing into own function.
Diffstat (limited to 'src')
-rw-r--r-- | src/manifest_parser_perftest.cc | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/manifest_parser_perftest.cc b/src/manifest_parser_perftest.cc index 4fb6a76..765ea1c 100644 --- a/src/manifest_parser_perftest.cc +++ b/src/manifest_parser_perftest.cc @@ -47,6 +47,25 @@ bool WriteFakeManifests(const string& dir) { return err == 0; } +int LoadManifests(bool measure_command_evaluation) { + string err; + RealFileReader file_reader; + State state; + ManifestParser parser(&state, &file_reader); + if (!parser.Load("build.ninja", &err)) { + fprintf(stderr, "Failed to read test data: %s\n", err.c_str()); + exit(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(); + return optimization_guard; +} + int main(int argc, char* argv[]) { bool measure_command_evaluation = true; int opt; @@ -76,26 +95,10 @@ int main(int argc, char* argv[]) { 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(); - - State state; - ManifestParser parser(&state, &file_reader); - if (!parser.Load("build.ninja", &err)) { - 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 optimization_guard = LoadManifests(measure_command_evaluation); int delta = (int)(GetTimeMillis() - start); printf("%dms (hash: %x)\n", delta, optimization_guard); times.push_back(delta); |