Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F132206
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/scripts/benchmark.lua b/scripts/benchmark.lua
index 457b671..56c3377 100644
--- a/scripts/benchmark.lua
+++ b/scripts/benchmark.lua
@@ -1,48 +1,64 @@
package.path = "lua/?.lua;" .. package.path
local libivy = require "ivy.libivy"
+local vim_mock = require "ivy.vim_mock"
+local window = require "ivy.window"
local benchmark = function(name, n, callback)
local status = {
running_total = 0,
min = 999999999999999999,
max = -0000000000000000,
}
for _ = 1, n do
local start_time = os.clock()
callback()
local running_time = os.clock() - start_time
status.running_total = status.running_total + running_time
if status.min > running_time then
status.min = running_time
end
if status.max < running_time then
status.max = running_time
end
end
print(
string.format(
- "| %-30s | %09.6f (s) | %09.6f (s) | %09.6f (s) | %09.6f (s) |",
+ "| %-41s | %09.6f (s) | %09.6f (s) | %09.6f (s) | %09.6f (s) |",
name,
status.running_total,
status.running_total / n,
status.min,
status.max
)
)
end
-print "| Name | Total | Average | Min | Max |"
-print "|--------------------------------|---------------|---------------|---------------|---------------|"
+print "| Name | Total | Average | Min | Max |"
+print "|-------------------------------------------|---------------|---------------|---------------|---------------|"
benchmark("ivy_match(file.lua) 1000000x", 1000000, function()
libivy.ivy_match("file.lua", "some/long/path/to/file/file.lua")
end)
libivy.ivy_init "/tmp/ivy-trees/kubernetes"
benchmark("ivy_files(kubernetes) 100x", 100, function()
libivy.ivy_files("file.go", "/tmp/ivy-trees/kubernetes")
end)
+
+-- Mock the vim API so we can run `vim.` functions. Override the
+-- `nvim_buf_set_lines` function, this is so very slow. It saves all of the
+-- lines so we can assert on them in the tests. For benchmarking we don't need
+-- any of this, we can't control the vim internals.
+vim_mock.reset()
+_G.vim.api.nvim_buf_set_lines = function() end
+
+window.initialize()
+
+benchmark("ivy_files_with_set_items(kubernetes) 100x", 100, function()
+ local items = libivy.ivy_files(".go", "/tmp/ivy-trees/kubernetes")
+ window.set_items(items)
+end)
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, May 8, 4:30 PM (1 w, 15 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
8953
Default Alt Text
(2 KB)
Attached To
Mode
R1 ivy.nvim
Attached
Detach File
Event Timeline
Log In to Comment