Files
hop.nvim/tests/lua/profile_helpers.lua
Chiao Chuang 6e83486f35 Load match_mappings on demand (#106)
* chore: add small profile (timing) script

Run it with `make profile`, which runs scripts doing `hop.setup` with
different settings, and print the elapsed time (in nanoseconds).

This would be helpful to determine the cost of setup.

Currently mainly target on the `match_mappings` option, when all
mappings were loaded, it increases time about 0.3 ms on my machine.

* chore: load match_mappings on demand

- In setup, only prepare an empty loaded_mappings table.

- When really using the feature (only in mappings.checkout), try load
  the wanted tables (e.g., zh_sc) on demand.

- Notify user if the loading failed. Rather than raising E5108 with lua
  not-found error (original behavior).
2026-08-14 17:19:29 +00:00

15 lines
273 B
Lua

local M = {}
---@param name string
---@param func function
function M.timing(name, func)
local t_start = vim.uv.hrtime()
func()
local t_end = vim.uv.hrtime()
local diff = t_end - t_start
print(string.format("Time elapsed: %9s\t%s\n", diff, name))
end
return M