1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
-- 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
|