Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 8d43f6b

Browse files
committed
Manifest perftest: Also measure command evaluation time.
1 parent 993803e commit 8d43f6b

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

src/manifest_parser_perftest.cc

+31-5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#endif
2525

2626
#include "disk_interface.h"
27+
#include "graph.h"
2728
#include "manifest_parser.h"
2829
#include "metrics.h"
2930
#include "state.h"
@@ -46,11 +47,26 @@ bool WriteFakeManifests(const string& dir) {
4647
return err == 0;
4748
}
4849

49-
int main() {
50+
int main(int argc, char* argv[]) {
51+
bool measure_command_evaluation = true;
52+
int opt;
53+
while ((opt = getopt(argc, argv, const_cast<char*>("fh"))) != -1) {
54+
switch (opt) {
55+
case 'f':
56+
measure_command_evaluation = false;
57+
break;
58+
case 'h':
59+
default:
60+
printf("usage: manifest_parser_perftest\n"
61+
"\n"
62+
"options:\n"
63+
" -f only measure manifest load time, not command evaluation time\n"
64+
);
65+
return 1;
66+
}
67+
}
68+
5069
const char kManifestDir[] = "build/manifest_perftest";
51-
RealFileReader file_reader;
52-
vector<int> times;
53-
string err;
5470

5571
if (!WriteFakeManifests(kManifestDir)) {
5672
fprintf(stderr, "Failed to write test data\n");
@@ -60,6 +76,9 @@ int main() {
6076
chdir(kManifestDir);
6177

6278
const int kNumRepetitions = 5;
79+
RealFileReader file_reader;
80+
vector<int> times;
81+
string err;
6382
for (int i = 0; i < kNumRepetitions; ++i) {
6483
int64_t start = GetTimeMillis();
6584

@@ -69,9 +88,16 @@ int main() {
6988
fprintf(stderr, "Failed to read test data: %s\n", err.c_str());
7089
return 1;
7190
}
91+
// Doing an empty build involves reading the manifest and evaluating all
92+
// commands required for the requested targets. So include command
93+
// evaluation in the perftest by default.
94+
int optimization_guard = 0;
95+
if (measure_command_evaluation)
96+
for (size_t i = 0; i < state.edges_.size(); ++i)
97+
optimization_guard += state.edges_[i]->EvaluateCommand().size();
7298

7399
int delta = (int)(GetTimeMillis() - start);
74-
printf("%dms\n", delta);
100+
printf("%dms (hash: %x)\n", delta, optimization_guard);
75101
times.push_back(delta);
76102
}
77103

0 commit comments

Comments
 (0)