|
144 | 144 | function M:help()
|
145 | 145 | self:append("Help", "LazyH2"):nl():nl()
|
146 | 146 |
|
| 147 | + self:append("You can press "):append("<CR>", "LazySpecial"):append(" on a plugin to show its details."):nl() |
147 | 148 | self:append("You can press "):append("<CR>", "LazySpecial"):append(" on a plugin to show its details."):nl()
|
148 | 149 |
|
149 | 150 | self:append("Most properties can be hovered with ")
|
@@ -459,28 +460,63 @@ end
|
459 | 460 |
|
460 | 461 | function M:profile()
|
461 | 462 | self:append("Profile", "LazyH2"):nl():nl()
|
| 463 | + self |
| 464 | + :append("You can press ") |
| 465 | + :append("<C-s>", "LazySpecial") |
| 466 | + :append(" to change sorting between chronological order & time taken.") |
| 467 | + :nl() |
| 468 | + self |
| 469 | + :append("Press ") |
| 470 | + :append("<C-f>", "LazySpecial") |
| 471 | + :append(" to filter profiling entries that took more time than a given threshold") |
| 472 | + :nl() |
| 473 | + |
| 474 | + self:nl() |
462 | 475 | local symbols = {
|
463 | 476 | "●",
|
464 | 477 | "➜",
|
465 | 478 | "★",
|
466 | 479 | "‒",
|
467 | 480 | }
|
468 | 481 |
|
| 482 | + ---@param a LazyProfile |
| 483 | + ---@param b LazyProfile |
| 484 | + local function sort(a, b) |
| 485 | + return a.time > b.time |
| 486 | + end |
| 487 | + |
| 488 | + ---@param entry LazyProfile |
| 489 | + local function get_children(entry) |
| 490 | + ---@type LazyProfile[] |
| 491 | + local children = entry |
| 492 | + |
| 493 | + if self.view.state.profile.sort_time_taken then |
| 494 | + children = {} |
| 495 | + for _, child in ipairs(entry) do |
| 496 | + children[#children + 1] = child |
| 497 | + end |
| 498 | + table.sort(children, sort) |
| 499 | + end |
| 500 | + return children |
| 501 | + end |
| 502 | + |
469 | 503 | ---@param entry LazyProfile
|
470 | 504 | local function _profile(entry, depth)
|
| 505 | + if entry.time / 1e6 < self.view.state.profile.threshold then |
| 506 | + return |
| 507 | + end |
471 | 508 | local data = type(entry.data) == "string" and { source = entry.data } or entry.data
|
472 | 509 | data.time = entry.time
|
473 | 510 | local symbol = symbols[depth] or symbols[#symbols]
|
474 |
| - self:append((" "):rep(depth)):append(" " .. symbol, "LazySpecial"):append(" ") |
| 511 | + self:append((" "):rep(depth)):append(symbol, "LazySpecial"):append(" ") |
475 | 512 | self:reason(data, { time_right = true })
|
476 | 513 | self:nl()
|
477 |
| - |
478 |
| - for _, child in ipairs(entry) do |
| 514 | + for _, child in ipairs(get_children(entry)) do |
479 | 515 | _profile(child, depth + 1)
|
480 | 516 | end
|
481 | 517 | end
|
482 | 518 |
|
483 |
| - for _, entry in ipairs(Util._profiles[1]) do |
| 519 | + for _, entry in ipairs(get_children(Util._profiles[1])) do |
484 | 520 | _profile(entry, 1)
|
485 | 521 | end
|
486 | 522 | end
|
|
0 commit comments