aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/driver.cc
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/driver.cc')
-rw-r--r--kernel/driver.cc31
1 files changed, 29 insertions, 2 deletions
diff --git a/kernel/driver.cc b/kernel/driver.cc
index e52e1fb0e..436fda48c 100644
--- a/kernel/driver.cc
+++ b/kernel/driver.cc
@@ -33,6 +33,7 @@
#include <string.h>
#include <limits.h>
#include <errno.h>
+#include <inttypes.h>
#if defined (__linux__) || defined(__FreeBSD__)
# include <sys/resource.h>
@@ -210,6 +211,7 @@ int main(int argc, char **argv)
std::string scriptfile = "";
std::string depsfile = "";
std::string topmodule = "";
+ std::string perffile = "";
bool scriptfile_tcl = false;
bool print_banner = true;
bool print_stats = true;
@@ -353,7 +355,7 @@ int main(int argc, char **argv)
}
int opt;
- while ((opt = getopt(argc, argv, "MXAQTVSgm:f:Hh:b:o:p:l:L:qv:tds:c:W:w:e:r:D:P:E:x:")) != -1)
+ while ((opt = getopt(argc, argv, "MXAQTVSgm:f:Hh:b:o:p:l:L:qv:tds:c:W:w:e:r:D:P:E:x:B:")) != -1)
{
switch (opt)
{
@@ -488,6 +490,9 @@ int main(int argc, char **argv)
case 'x':
log_experimentals_ignored.insert(optarg);
break;
+ case 'B':
+ perffile = optarg;
+ break;
default:
fprintf(stderr, "Run '%s -h' for help.\n", argv[0]);
exit(1);
@@ -674,6 +679,29 @@ int main(int argc, char **argv)
}
log("%s\n", out_count ? "" : " no commands executed");
}
+ if(!perffile.empty())
+ {
+ FILE *f = fopen(perffile.c_str(), "wt");
+ if (f == nullptr)
+ log_error("Can't open performance log file for writing: %s\n", strerror(errno));
+
+ fprintf(f, "{\n");
+ fprintf(f, " \"generator\": \"%s\",\n", yosys_version_str);
+ fprintf(f, " \"total_ns\": %" PRIu64 ",\n", total_ns);
+ fprintf(f, " \"passes\": {");
+
+ bool first = true;
+ for (auto it = timedat.rbegin(); it != timedat.rend(); it++) {
+ if (!first)
+ fprintf(f, ",");
+ fprintf(f, "\n \"%s\": {\n", std::get<2>(*it).c_str());
+ fprintf(f, " \"runtime_ns\": %" PRIu64 ",\n", std::get<0>(*it));
+ fprintf(f, " \"num_calls\": %u\n", std::get<1>(*it));
+ fprintf(f, " }");
+ first = false;
+ }
+ fprintf(f, "\n }\n}\n");
+ }
}
#if defined(YOSYS_ENABLE_COVER) && (defined(__linux__) || defined(__FreeBSD__))
@@ -724,4 +752,3 @@ int main(int argc, char **argv)
}
#endif /* EMSCRIPTEN */
-