feat: add benchmarks
This commit is contained in:
parent
2c04dd79dd
commit
1ae47813d7
4 changed files with 23604 additions and 0 deletions
30
README.md
30
README.md
|
|
@ -72,6 +72,36 @@ Action can be run on selected candidates provide functionality
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Benchmarks
|
||||||
|
|
||||||
|
Benchmarks are of various tasks that ivy will do. The purpose of the benchmarks
|
||||||
|
are to give us a baseline on where to start when trying to optimize performance
|
||||||
|
in the matching and sorting, not to put ivy against other tools. When starting
|
||||||
|
to optimize, you will probably need to get a baseline on your hardware.
|
||||||
|
|
||||||
|
There are fixtures provided that will create the directory structure of the
|
||||||
|
[kubernetes](https://github.com/kubernetes/kubernetes) source code, from
|
||||||
|
somewhere arround commit sha 985c9202ccd250a5fe22c01faf0d8f83d804b9f3. This will
|
||||||
|
create a directory tree of 23511 files a relative large source tree to get a
|
||||||
|
good idea of performance. To create the source tree under
|
||||||
|
`/tmp/ivy-trees/kubernetes` run the following command. This will need to be run
|
||||||
|
for the benchmarks to run.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Create the source trees
|
||||||
|
bash ./scripts/fixtures.bash
|
||||||
|
|
||||||
|
# Run the benchmark script
|
||||||
|
luajit ./scripts/benchmark.lua
|
||||||
|
```
|
||||||
|
|
||||||
|
Current benchmark status with 8 CPU(s) Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
|
||||||
|
|
||||||
|
| Name | Total | Adverage | Min | Max |
|
||||||
|
| ---------------------------- | ------------- | ------------- | ------------- | ------------- |
|
||||||
|
| ivy_match(file.lua) 1000000x | 02.351614 (s) | 00.000002 (s) | 00.000002 (s) | 00.000042 (s) |
|
||||||
|
| ivy_files(kubneties) 100x | 32.704256 (s) | 00.327043 (s) | 00.289397 (s) | 00.344413 (s) |
|
||||||
|
|
||||||
## Other stuff you might like
|
## Other stuff you might like
|
||||||
|
|
||||||
- [ivy-mode](https://github.com/abo-abo/swiper#ivy) - An emacs package that was the inspiration for this nvim plugin
|
- [ivy-mode](https://github.com/abo-abo/swiper#ivy) - An emacs package that was the inspiration for this nvim plugin
|
||||||
|
|
|
||||||
23511
fixtures/kubernetes.txt
Normal file
23511
fixtures/kubernetes.txt
Normal file
File diff suppressed because it is too large
Load diff
48
scripts/benchmark.lua
Normal file
48
scripts/benchmark.lua
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
package.path = "lua/?.lua;" .. package.path
|
||||||
|
local libivy = require "ivy.libivy"
|
||||||
|
|
||||||
|
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) |",
|
||||||
|
name,
|
||||||
|
status.running_total,
|
||||||
|
status.running_total / n,
|
||||||
|
status.min,
|
||||||
|
status.max
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
print "| Name | Total | Adverage | 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(kubneties) 100x", 100, function()
|
||||||
|
libivy.ivy_files("file.go", "/tmp/ivy-trees/kubernetes")
|
||||||
|
end)
|
||||||
15
scripts/fixtures.bash
Normal file
15
scripts/fixtures.bash
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
while IFS= read -r file; do
|
||||||
|
fixture_file="/tmp/ivy-trees/kubernetes/$file"
|
||||||
|
fixture_dir="$(dirname $fixture_file)"
|
||||||
|
|
||||||
|
if [[ ! -d "$fixture_dir" ]]; then
|
||||||
|
mkdir -p "$fixture_dir"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f "$fixture_file" ]]; then
|
||||||
|
echo "Making $fixture_file"
|
||||||
|
touch "$fixture_file"
|
||||||
|
fi
|
||||||
|
done <"fixtures/kubernetes.txt"
|
||||||
Loading…
Reference in a new issue