22 int main(
int argc,
char* argv[]) {
24 printf(
"usage: %s <file1> <file2...>\n", argv[0]);
29 for (
int i = 1; i < argc; ++i) {
30 const char* filename = argv[i];
32 for (
int limit = 1 << 10; limit < (1<<20); limit *= 2) {
34 for (
int rep = 0; rep < limit; ++rep) {
37 if (
ReadFile(filename, &buf, &err) < 0) {
38 printf(
"%s: %s\n", filename, err.c_str());
43 if (!parser.
Parse(&buf, &err)) {
44 printf(
"%s: %s\n", filename, err.c_str());
50 if (end - start > 100) {
51 int delta = (int)(end - start);
52 float time = delta*1000 / (float)limit;
53 printf(
"%s: %.1fus\n", filename, time);
54 times.push_back(time);
64 for (
size_t i = 0; i < times.size(); ++i) {
68 else if (times[i] > max)
72 printf(
"min %.1fus max %.1fus avg %.1fus\n",
73 min, max, total / times.size());
int main(int argc, char *argv[])
Parser for the dependency information emitted by gcc's -M flags.
bool Parse(string *content, string *err)
Parse an input file.
int64_t GetTimeMillis()
Get the current time as relative to some epoch.
signed long long int64_t
A 64-bit integer type.
int ReadFile(const string &path, string *contents, string *err)
Read a file to a string (in text mode: with CRLF conversion on Windows).