47 TimeStamp mtime = disk_interface.
Stat(dir +
"/build.ninja", err);
51 string command =
"python misc/write_fake_manifests.py " + dir;
52 printf(
"Creating manifest data..."); fflush(stdout);
53 int exit_code = system(command.c_str());
56 *err =
"Failed to run " + command;
57 return exit_code == 0;
65 if (!parser.
Load(
"build.ninja", &err)) {
66 fprintf(stderr,
"Failed to read test data: %s\n", err.c_str());
72 int optimization_guard = 0;
73 if (measure_command_evaluation)
74 for (
size_t i = 0; i < state.
edges_.size(); ++i)
75 optimization_guard += state.
edges_[i]->EvaluateCommand().size();
76 return optimization_guard;
79 int main(
int argc,
char* argv[]) {
80 bool measure_command_evaluation =
true;
82 while ((opt =
getopt(argc, argv,
const_cast<char*
>(
"fh"))) != -1) {
85 measure_command_evaluation =
false;
89 printf(
"usage: manifest_parser_perftest\n"
92 " -f only measure manifest load time, not command evaluation time\n"
98 const char kManifestDir[] =
"build/manifest_perftest";
102 fprintf(stderr,
"Failed to write test data: %s\n", err.c_str());
106 if (chdir(kManifestDir) < 0)
107 Fatal(
"chdir: %s", strerror(errno));
109 const int kNumRepetitions = 5;
111 for (
int i = 0; i < kNumRepetitions; ++i) {
113 int optimization_guard =
LoadManifests(measure_command_evaluation);
115 printf(
"%dms (hash: %x)\n", delta, optimization_guard);
116 times.push_back(delta);
119 int min = *min_element(times.begin(), times.end());
120 int max = *max_element(times.begin(), times.end());
121 float total = accumulate(times.begin(), times.end(), 0.0f);
122 printf(
"min %dms max %dms avg %.1fms\n", min, max, total / times.size());
int getopt(int argc, char **argv, char *optstring)
int main(int argc, char *argv[])
int LoadManifests(bool measure_command_evaluation)
bool WriteFakeManifests(const string &dir, string *err)
int64_t GetTimeMillis()
Get the current time as relative to some epoch.
bool Load(const std::string &filename, std::string *err, Lexer *parent=NULL)
Load and parse a file.
Implementation of DiskInterface that actually hits the disk.
TimeStamp Stat(const std::string &path, std::string *err) const override
stat() a file, returning the mtime, or 0 if missing and -1 on other errors.
Global state (file status) for a single run.
std::vector< Edge * > edges_
All the edges of the graph.
void Fatal(const char *msg,...)
Log a fatal message and exit.
signed long long int64_t
A 64-bit integer type.