summaryrefslogtreecommitdiff
path: root/lua/tests/manual
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2021-08-20 11:11:24 -0400
committerGitHub <noreply@github.com>2021-08-20 11:11:24 -0400
commita97af306c4e9c9a6fa7c886c0ffe3079822c5203 (patch)
treef5e2b50a767e93618d0d8fdddb8a964c90633c8a /lua/tests/manual
parentd6d28dbe324de9826a579155076873888169ba0f (diff)
feat(performance): Major performance improvements using async v2 from @oberblastmeister (#987)
* start: Working w/ async jobs * short circuit to using bad finder if you pass writer.
Diffstat (limited to 'lua/tests/manual')
-rw-r--r--lua/tests/manual/all_defaults.lua22
-rw-r--r--lua/tests/manual/auto_picker.lua80
-rw-r--r--lua/tests/manual/find_and_sort_spec.lua105
-rw-r--r--lua/tests/manual/large_search.lua29
-rw-r--r--lua/tests/manual/newline_tables.lua24
-rw-r--r--lua/tests/manual/profile_for_sorters.lua70
-rw-r--r--lua/tests/manual/reference_tracker.lua50
-rw-r--r--lua/tests/manual/resolver_spec.lua62
-rw-r--r--lua/tests/manual/slow_oneshot.lua70
9 files changed, 0 insertions, 512 deletions
diff --git a/lua/tests/manual/all_defaults.lua b/lua/tests/manual/all_defaults.lua
deleted file mode 100644
index 4d39a05..0000000
--- a/lua/tests/manual/all_defaults.lua
+++ /dev/null
@@ -1,22 +0,0 @@
---[[
-vim.api.nvim_buf_set_lines(0, 4, -1, false, vim.tbl_keys(require('telescope.builtin')))
---]]
-
-require("telescope.builtin").git_files()
-RELOAD "telescope"
-require("telescope.builtin").oldfiles()
-require("telescope.builtin").grep_string()
-require("telescope.builtin").lsp_document_symbols()
-RELOAD "telescope"
-require("telescope.builtin").lsp_workspace_symbols()
-require("telescope.builtin").lsp_references()
-require("telescope.builtin").builtin()
-require("telescope.builtin").fd()
-require("telescope.builtin").command_history()
-require("telescope.builtin").search_history()
-require("telescope.builtin").live_grep()
-require("telescope.builtin").loclist()
-
--- TODO: make a function that puts stuff into quickfix.
--- that way we can test this better.
-require("telescope.builtin").quickfix()
diff --git a/lua/tests/manual/auto_picker.lua b/lua/tests/manual/auto_picker.lua
deleted file mode 100644
index 5189ba7..0000000
--- a/lua/tests/manual/auto_picker.lua
+++ /dev/null
@@ -1,80 +0,0 @@
-RELOAD "telescope"
-
-local finders = require "telescope.finders"
-local make_entry = require "telescope.make_entry"
-local previewers = require "telescope.previewers"
-local pickers = require "telescope.pickers"
-local sorters = require "telescope.sorters"
-
-local find_files = function(opts)
- opts = opts or {}
- opts.prompt_prefix = ""
-
- local find_command = opts.find_command
-
- if not find_command then
- if 1 == vim.fn.executable "fd" then
- find_command = { "fd", "--type", "f" }
- elseif 1 == vim.fn.executable "fdfind" then
- find_command = { "fdfind", "--type", "f" }
- elseif 1 == vim.fn.executable "rg" then
- find_command = { "rg", "--files" }
- end
- end
-
- if opts.cwd then
- opts.cwd = vim.fn.expand(opts.cwd)
- end
-
- opts.entry_maker = opts.entry_maker or make_entry.gen_from_file(opts)
-
- local p = pickers.new(opts, {
- prompt = "Find Files",
- finder = finders.new_oneshot_job(find_command, opts),
- previewer = previewers.cat.new(opts),
- sorter = sorters.get_fuzzy_file(),
-
- track = true,
- })
-
- local count = 0
- p:register_completion_callback(function(s)
- print(
- count,
- vim.inspect(s.stats, {
- process = function(item)
- if type(item) == "string" and item:sub(1, 1) == "_" then
- return nil
- end
-
- return item
- end,
- })
- )
-
- count = count + 1
- end)
-
- local feed = function(text, feed_opts)
- feed_opts = feed_opts or "n"
- vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(text, true, false, true), feed_opts, true)
- end
-
- p:register_completion_callback(coroutine.wrap(function()
- local input = "pickers.lua"
- for i = 1, #input do
- feed(input:sub(i, i))
- coroutine.yield()
- end
-
- vim.wait(300, function() end)
- feed("<CR>", "")
-
- coroutine.yield()
- print "STILL CALLED?"
- end))
-
- p:find()
-end
-
-find_files()
diff --git a/lua/tests/manual/find_and_sort_spec.lua b/lua/tests/manual/find_and_sort_spec.lua
deleted file mode 100644
index eec44b6..0000000
--- a/lua/tests/manual/find_and_sort_spec.lua
+++ /dev/null
@@ -1,105 +0,0 @@
-require("plenary.reload").reload_module "plenary"
-require("plenary.reload").reload_module "telescope"
-
---[[
-
-Goals:
-1. Easily test a sorter and finder to make sure we get all the results we need.
-
---]]
-
-local finders = require "telescope.finders"
-local make_entry = require "telescope.make_entry"
-local pickers = require "telescope.pickers"
-local sorters = require "telescope.sorters"
-local EntryManager = require "telescope.entry_manager"
-
-local find_and_sort_test = function(prompt, f, s)
- local info = {}
-
- local start = vim.loop.hrtime()
-
- info.filtered = 0
- info.added = 0
- info.scoring_time = 0
- info.set_entry = 0
-
- local entry_manager = EntryManager:new(25, function()
- info.set_entry = info.set_entry + 1
- end, info)
-
- local completed = false
-
- local process_result = function(entry)
- local score_start = vim.loop.hrtime()
- local score = s:score(prompt, entry)
- info.scoring_time = info.scoring_time + (vim.loop.hrtime() - score_start) / 1e9
-
- -- Filter these out here.
- if score == -1 then
- info.filtered = info.filtered + 1
- return
- end
-
- info.added = info.added + 1
- entry_manager:add_entry(s:score(prompt, entry), entry)
- end
-
- local process_complete = function()
- info.time = (vim.loop.hrtime() - start) / 1e9
-
- info.total = info.filtered + info.added
- completed = true
- end
-
- f(prompt, process_result, process_complete)
-
- -- Wait until we're done to return
- vim.wait(5000, function()
- return completed
- end, 10)
-
- return entry_manager, info
-end
-
-local info_to_csv = function(info, filename)
- local writer = io.open(filename, "a")
-
- writer:write(string.format("%.8f", info.scoring_time) .. "\t")
- writer:write(string.format("%.8f", info.time) .. "\t")
- writer:write(info.looped .. "\t")
- writer:write(info.filtered .. "\t")
- writer:write(info.added .. "\t")
- writer:write(info.inserted .. "\t")
- writer:write(info.total .. "\t")
- writer:write(info.set_entry .. "\t")
- writer:write(string.format("%.0f", collectgarbage "count") .. "\t")
- writer:write "\n"
-
- writer:close()
-end
-
-local cwd = vim.fn.expand "~/build/neovim"
-
-collectgarbage "collect"
-for _ = 1, 1 do
- -- local s = sorters.get_fuzzy_file()
- local s = sorters.get_generic_fuzzy_sorter()
- local finder = finders.new_oneshot_job({ "fdfind" }, {
- cwd = cwd,
- entry_maker = make_entry.gen_from_file { cwd = cwd },
- -- disable_devicons = true,
- -- maximum_results = 1000,
- })
-
- local res, info = find_and_sort_test("pickers.lua", finder, s)
-
- -- print(vim.inspect(res:get_entry(1)))
- -- print(vim.inspect(info))
-
- info_to_csv(info, "/home/tj/tmp/profile.csv")
-
- collectgarbage "collect"
-end
--- No skip: 2,206,186
--- Ya skip: 2,133
diff --git a/lua/tests/manual/large_search.lua b/lua/tests/manual/large_search.lua
deleted file mode 100644
index 2685214..0000000
--- a/lua/tests/manual/large_search.lua
+++ /dev/null
@@ -1,29 +0,0 @@
-RELOAD "plenary"
-RELOAD "telescope"
-
-local finders = require "telescope.finders"
-local make_entry = require "telescope.make_entry"
-local previewers = require "telescope.previewers"
-local pickers = require "telescope.pickers"
-local sorters = require "telescope.sorters"
-
-local cwd = vim.fn.expand "~/build/neovim"
-
-pickers.new({
- prompt = "Large search",
- finder = finders.new_oneshot_job({ "fdfind" }, {
- cwd = cwd,
- entry_maker = make_entry.gen_from_file { cwd = cwd },
- -- disable_devicons = true,
- -- maximum_results = 1000,
- }),
- sorter = sorters.get_fuzzy_file(),
- previewer = previewers.cat.new { cwd = cwd },
-}):find()
-
--- vim.wait(3000, function()
--- vim.cmd [[redraw!]]
--- return COMPLETED
--- end, 100)
--- vim.cmd [[bd!]]
--- vim.cmd [[stopinsert]]
diff --git a/lua/tests/manual/newline_tables.lua b/lua/tests/manual/newline_tables.lua
deleted file mode 100644
index 3be57a9..0000000
--- a/lua/tests/manual/newline_tables.lua
+++ /dev/null
@@ -1,24 +0,0 @@
-require("plenary.reload").reload_module "telescope"
-
-local finders = require "telescope.finders"
-local pickers = require "telescope.pickers"
-local sorters = require "telescope.sorters"
-local previewers = require "telescope.previewers"
-local make_entry = require "telescope.make_entry"
-
-local my_list = {
- "lua/telescope/WIP.lua",
- "lua/telescope/actions.lua",
- "lua/telescope/builtin.lua",
-}
-
-local opts = {}
-
-pickers.new(opts, {
- prompt = "Telescope Builtin",
- finder = finders.new_table {
- results = my_list,
- },
- sorter = sorters.get_generic_fuzzy_sorter(),
- previewer = previewers.cat.new(opts),
-}):find()
diff --git a/lua/tests/manual/profile_for_sorters.lua b/lua/tests/manual/profile_for_sorters.lua
deleted file mode 100644
index 05a657a..0000000
--- a/lua/tests/manual/profile_for_sorters.lua
+++ /dev/null
@@ -1,70 +0,0 @@
--- TODO: Add a ladder test.
--- 1, 2, 4, 8, 16, 32 attempts
-
-RELOAD "plenary"
--- RELOAD('telescope')
-
-local profiler = require "plenary.profile.lua_profiler"
-local Job = require "plenary.job"
-
-BIG_LIST = nil
-BIG_LIST = BIG_LIST or Job:new({ command = "fdfind", cwd = "~/build/" }):sync()
-print(#BIG_LIST)
-
-local do_profile = true
-local sorter_to_test = require("telescope.sorters").get_fuzzy_file()
-
-local strings_to_test = { "", "ev", "eval.c", "neovim/eval.c" }
-
-if do_profile then
- profiler.start()
-end
-
-local first_results = setmetatable({}, {
- __index = function(t, k)
- local obj = {}
- rawset(t, k, obj)
- return obj
- end,
-})
-
-local second_results = {}
-
-local do_iterations = function(num)
- local start
- for _, prompt in ipairs(strings_to_test) do
- start = vim.fn.reltime()
-
- for _ = 1, num do
- for _, v in ipairs(BIG_LIST) do
- sorter_to_test:score(prompt, v)
- end
- end
- -- print("First Time: ", vim.fn.reltimestr(vim.fn.reltime(start)), num, prompt)
- table.insert(first_results[prompt], vim.fn.reltimestr(vim.fn.reltime(start)))
-
- start = vim.fn.reltime()
- for _ = 1, num do
- for _, v in ipairs(BIG_LIST) do
- sorter_to_test:score(prompt, v)
- end
- end
-
- -- print("Second Time: ", vim.fn.reltimestr(vim.fn.reltime(start)), num, prompt)
- table.insert(second_results, vim.fn.reltimestr(vim.fn.reltime(start)))
- end
-end
-
-do_iterations(1)
--- do_iterations(2)
--- do_iterations(4)
--- do_iterations(8)
--- do_iterations(16)
--- do_iterations(32)
-
-print(vim.inspect(first_results))
-
-if do_profile then
- profiler.stop()
- profiler.report "/home/tj/tmp/profiler_score.txt"
-end
diff --git a/lua/tests/manual/reference_tracker.lua b/lua/tests/manual/reference_tracker.lua
deleted file mode 100644
index f9e04c9..0000000
--- a/lua/tests/manual/reference_tracker.lua
+++ /dev/null
@@ -1,50 +0,0 @@
--- local actions = require('telescope.actions')
--- local utils = require('telescope.utils')
-require "telescope"
-local finders = require "telescope.finders"
-local make_entry = require "telescope.make_entry"
-local previewers = require "telescope.previewers"
-local pickers = require "telescope.pickers"
-local sorters = require "telescope.sorters"
-
-local log = require "telescope.log"
-
-local real_opts = setmetatable({}, { __mode = "v" })
-local opts = setmetatable({}, {
- __index = function(t, k)
- log.debug("accessing:", k)
- return real_opts[k]
- end,
- __newindex = function(t, k, v)
- log.debug("setting:", k, v)
- real_opts[k] = v
- end,
-})
-
-opts.entry_maker = opts.entry_maker or make_entry.gen_from_file()
-if opts.cwd then
- opts.cwd = vim.fn.expand(opts.cwd)
-end
-
--- local get_finder_opts = function(opts)
--- local t = {}
--- t.entry_maker = table.pop(opts, 'entry_maker')
--- return t
--- end
-
--- local finder_opts = get_finder_opts(opts)
--- assert(not opts.entry_maker)
-
-local picker_config = {
- prompt = "Git File",
- finder = finders.new_oneshot_job({ "git", "ls-files", "-o", "--exclude-standard", "-c" }, opts),
- -- previewer = previewers.cat.new(opts),
- -- sorter = sorters.get_fuzzy_file(opts),
- -- sorter = sorters.get_fuzzy_file(),
-}
-
-log.debug "Done with config"
-
-local x = pickers.new(picker_config)
-x:find()
-x = nil
diff --git a/lua/tests/manual/resolver_spec.lua b/lua/tests/manual/resolver_spec.lua
deleted file mode 100644
index a03bfea..0000000
--- a/lua/tests/manual/resolver_spec.lua
+++ /dev/null
@@ -1,62 +0,0 @@
-RELOAD "telescope"
-
-local resolve = require "telescope.config.resolve"
-
-local eq = function(a, b)
- if a ~= b then
- error(string.format("Expected a == b, got: %s and %s", vim.inspect(a), vim.inspect(b)))
- end
-end
-
-local opt = nil
-
-local height_config = 0.8
-opt = resolve.win_option(height_config)
-
-eq(height_config, opt.preview)
-eq(height_config, opt.prompt)
-eq(height_config, opt.results)
-
-opt = resolve.win_option(nil, height_config)
-
-eq(height_config, opt.preview)
-eq(height_config, opt.prompt)
-eq(height_config, opt.results)
-
-local table_val = { "a" }
-opt = resolve.win_option(nil, table_val)
-eq(table_val, opt.preview)
-eq(table_val, opt.prompt)
-eq(table_val, opt.results)
-
-local prompt_override = { "a", prompt = "b" }
-opt = resolve.win_option(prompt_override)
-eq("a", opt.preview)
-eq("a", opt.results)
-eq("b", opt.prompt)
-
-local all_specified = { preview = "a", prompt = "b", results = "c" }
-opt = resolve.win_option(all_specified)
-eq("a", opt.preview)
-eq("b", opt.prompt)
-eq("c", opt.results)
-
-local some_specified = { prompt = "b", results = "c" }
-opt = resolve.win_option(some_specified, "a")
-eq("a", opt.preview)
-eq("b", opt.prompt)
-eq("c", opt.results)
-
-eq(10, resolve.resolve_height(0.1)(nil, 24, 100))
-eq(2, resolve.resolve_width(0.1)(nil, 24, 100))
-
-eq(10, resolve.resolve_width(10)(nil, 24, 100))
-eq(24, resolve.resolve_width(50)(nil, 24, 100))
-
--- local true_table = {true}
--- opt = resolve.win_option(some_specified, 'a')
--- eq('a', opt.preview)
--- eq('b', opt.prompt)
--- eq('c', opt.results)
-
-print "DONE!"
diff --git a/lua/tests/manual/slow_oneshot.lua b/lua/tests/manual/slow_oneshot.lua
deleted file mode 100644
index e16b3e1..0000000
--- a/lua/tests/manual/slow_oneshot.lua
+++ /dev/null
@@ -1,70 +0,0 @@
-RELOAD "telescope"
-
-local actions = require "telescope.actions"
-local finders = require "telescope.finders"
-local make_entry = require "telescope.make_entry"
-local previewers = require "telescope.previewers"
-local pickers = require "telescope.pickers"
-local sorters = require "telescope.sorters"
-local utils = require "telescope.utils"
-
-local slow_proc = function(opts)
- opts = opts or {}
-
- if opts.cwd then
- opts.cwd = vim.fn.expand(opts.cwd)
- end
-
- opts.entry_maker = opts.entry_maker or make_entry.gen_from_file(opts)
-
- local p = pickers.new(opts, {
- prompt = "Slow Proc",
- finder = finders.new_oneshot_job({ "./scratch/slow_proc.sh" }, opts),
- previewer = previewers.cat.new(opts),
- sorter = sorters.get_fuzzy_file(),
-
- track = true,
- })
-
- local count = 0
- p:register_completion_callback(function(s)
- print(
- count,
- vim.inspect(s.stats, {
- process = function(item)
- if type(item) == "string" and item:sub(1, 1) == "_" then
- return nil
- end
-
- return item
- end,
- })
- )
-
- count = count + 1
- end)
-
- local feed = function(text)
- vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(text, true, false, true), "n", true)
- end
-
- if false then
- p:register_completion_callback(coroutine.wrap(function()
- local input = "pickers.lua"
- for i = 1, #input do
- feed(input:sub(i, i))
- coroutine.yield()
- end
-
- vim.wait(300, function() end)
-
- vim.cmd [[:q]]
- vim.cmd [[:Messages]]
- vim.cmd [[stopinsert]]
- end))
- end
-
- p:find()
-end
-
-slow_proc()