24
24
#endif
25
25
26
26
#include " disk_interface.h"
27
+ #include " graph.h"
27
28
#include " manifest_parser.h"
28
29
#include " metrics.h"
29
30
#include " state.h"
@@ -46,11 +47,26 @@ bool WriteFakeManifests(const string& dir) {
46
47
return err == 0 ;
47
48
}
48
49
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
+
50
69
const char kManifestDir [] = " build/manifest_perftest" ;
51
- RealFileReader file_reader;
52
- vector<int > times;
53
- string err;
54
70
55
71
if (!WriteFakeManifests (kManifestDir )) {
56
72
fprintf (stderr, " Failed to write test data\n " );
@@ -60,6 +76,9 @@ int main() {
60
76
chdir (kManifestDir );
61
77
62
78
const int kNumRepetitions = 5 ;
79
+ RealFileReader file_reader;
80
+ vector<int > times;
81
+ string err;
63
82
for (int i = 0 ; i < kNumRepetitions ; ++i) {
64
83
int64_t start = GetTimeMillis ();
65
84
@@ -69,9 +88,16 @@ int main() {
69
88
fprintf (stderr, " Failed to read test data: %s\n " , err.c_str ());
70
89
return 1 ;
71
90
}
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 ();
72
98
73
99
int delta = (int )(GetTimeMillis () - start);
74
- printf (" %dms\n " , delta);
100
+ printf (" %dms (hash: %x) \n " , delta, optimization_guard );
75
101
times.push_back (delta);
76
102
}
77
103
0 commit comments