diff options
Diffstat (limited to 'xmake/core')
| -rw-r--r-- | xmake/core/base/interpreter.lua | 2 | ||||
| -rw-r--r-- | xmake/core/base/profiler.lua | 29 |
2 files changed, 24 insertions, 7 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index 4e5aaf8c7..94adfd53f 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -1793,7 +1793,7 @@ function interpreter:api_builtin_includes(...) files = os.files(subpath) else -- @see https://github.com/xmake-io/xmake/issues/6026 - files = os.files(path.join(subpath, path.filename(curfile))) + files = os.files(path.join(subpath, "xmake.lua")) end if files and #files > 0 then table.join2(subpaths_matched, files) diff --git a/xmake/core/base/profiler.lua b/xmake/core/base/profiler.lua index ae0ced4fc..1cd1a1d2d 100644 --- a/xmake/core/base/profiler.lua +++ b/xmake/core/base/profiler.lua @@ -182,14 +182,20 @@ function profiler:stop() return a.totaltime > b.totaltime end) - -- show reports + -- show and save reports + local report_lines = "" + local outfile = path.join(os.tmpdir(), "perf-call-" .. os.date("%d-%m-%y-%S-%M-%H") .. ".log") for _, report in ipairs(reports) do local percent = (report.totaltime / totaltime) * 100 if percent < 1 then break end - utils.print("%6.3f, %6.2f%%, %7d, %s", report.totaltime, percent, report.callcount, self:_func_title(report.funcinfo)) + local report_line = string.format("%6.3f, %6.2f%%, %7d, %s", report.totaltime, percent, report.callcount, self:_func_title(report.funcinfo)) + report_lines = report_lines .. report_line .. "\n" + utils.print(report_line) end + utils.print("full log written to %s", outfile) + io.writefile(outfile, report_lines) elseif self:is_perf("tag") then -- sort reports, topN @@ -201,16 +207,27 @@ function profiler:stop() h:push(report) end - -- show reports + -- show and save reports local count = 0 - while count < 64 and h:length() > 0 do + local max_count = 64 + local outfile = path.join(os.tmpdir(), "perf-tag-" .. os.date("%d-%m-%y-%S-%M-%H") .. ".log") + local report_lines = "" + while h:length() > 0 do local report = h:pop() - utils.print("%6.3f, %7d, %s", report.totaltime, report.callcount, self:_tag_title(report.name, report.argv)) + local report_line = string.format("%6.3f, %7d, %s", report.totaltime, report.callcount, self:_tag_title(report.name, report.argv)) + report_lines = report_lines .. report_line .. "\n" count = count + 1 end - if h:length() > 0 then + if count <= max_count then + utils.print(report_lines) + elseif count > max_count then + local max_count_lines = {table.unpack(report_lines:split("\n"), 1, max_count)} + utils.print(table.concat(max_count_lines, "\n")) utils.print("...") + count = count + 1 end + utils.print("full log written to %s", outfile) + io.writefile(outfile, report_lines) end end |
