This repository has been archived by the owner on Oct 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First benchmark: Looking at Xgit.Repository.WorkingTree.ParseIndexFil…
…e.from_iodevice/1. (#167)
- Loading branch information
Showing
5 changed files
with
131 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[ | ||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"], | ||
inputs: ["{mix,.formatter}.exs", "{bench,config,lib,test}/**/*.{ex,exs}"], | ||
locals_without_parens: [cover: 1] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
When there's a concern about algorithmic or absolute cost of a specific implementation, | ||
let's build a microbenchmark here. As of this writing (mid-September 2019), I think the | ||
following functions need study. | ||
|
||
``` | ||
Xgit.Core.DirCache | ||
add_entries/2 | ||
fully_merged?/1 | ||
remove_entries/2 | ||
to_tree_objects/2 | ||
Xgit.Core.FilePath | ||
check_path_segment/2 | ||
check_path/2 | ||
valid?/2 | ||
Xgit.Core.Object | ||
valid?/1 | ||
Xgit.Core.Tree | ||
from_object/1 | ||
to_object/1 | ||
Xgit.Repository (permute on the implementations) | ||
get_object/2 | ||
has_all_object_ids?/2 | ||
put_loose_object/2 | ||
Xgit.Repository.WorkingTree.WriteIndexFile | ||
to_iodevice/1 | ||
``` |
92 changes: 92 additions & 0 deletions
92
bench/xgit/repository/working_tree/parse_index_file/from_iodevice.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Measure cost of Xgit.Repository.WorkingTree.ParseIndexFile.from_iodevice/1. | ||
# | ||
# EXPECTED: Cost is roughly O(n) on the number of items in the index file. | ||
# | ||
# -------------------------------------------------------------------------------------- | ||
# | ||
# $ mix run bench/xgit/repository/working_tree/parse_index_file/from_iodevice.exs | ||
# Operating System: macOS | ||
# CPU Information: Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz | ||
# Number of Available Cores: 8 | ||
# Available memory: 16 GB | ||
# Elixir 1.9.1 | ||
# Erlang 22.0.7 | ||
# | ||
# Benchmark suite executing with the following configuration: | ||
# warmup: 2 s | ||
# time: 5 s | ||
# memory time: 0 ns | ||
# parallel: 1 | ||
# inputs: 10 items, 100 items, 1000 items | ||
# Estimated total run time: 21 s | ||
# | ||
# Benchmarking parse_index_file with input 10 items... | ||
# Benchmarking parse_index_file with input 100 items... | ||
# Benchmarking parse_index_file with input 1000 items... | ||
# | ||
# ##### With input 10 items ##### | ||
# Name ips average deviation median 99th % | ||
# parse_index_file 1.14 K 880.11 μs ±7.61% 871 μs 1090.70 μs | ||
# | ||
# ##### With input 100 items ##### | ||
# Name ips average deviation median 99th % | ||
# parse_index_file 146.25 6.84 ms ±3.99% 6.81 ms 7.69 ms | ||
# | ||
# ##### With input 1000 items ##### | ||
# Name ips average deviation median 99th % | ||
# parse_index_file 14.87 67.23 ms ±1.97% 67.01 ms 73.24 ms | ||
# | ||
# -------------------------------------------------------------------------------------- | ||
|
||
alias Xgit.Repository.WorkingTree.ParseIndexFile | ||
alias Xgit.Util.TrailingHashDevice | ||
|
||
Temp.track!() | ||
|
||
make_index_file_with_n_entries = fn n -> | ||
git_dir = Temp.mkdir!() | ||
|
||
{_output, 0} = System.cmd("git", ["init"], cd: git_dir) | ||
|
||
Enum.map(1..n, fn i -> | ||
name = "0000#{i}" | ||
|
||
{_output, _0} = | ||
System.cmd( | ||
"git", | ||
[ | ||
"update-index", | ||
"--add", | ||
"--cacheinfo", | ||
"100644", | ||
"18832d35117ef2f013c4009f5b2128dfaeff354f", | ||
"a#{String.slice(name, -4, 4)}" | ||
], | ||
cd: git_dir | ||
) | ||
end) | ||
|
||
Path.join([git_dir, ".git", "index"]) | ||
end | ||
|
||
thd_open_file! = fn path -> | ||
{:ok, iodevice} = TrailingHashDevice.open_file(path) | ||
iodevice | ||
end | ||
|
||
inputs = %{ | ||
"10 items" => make_index_file_with_n_entries.(10), | ||
"100 items" => make_index_file_with_n_entries.(100), | ||
"1000 items" => make_index_file_with_n_entries.(1000) | ||
} | ||
|
||
Benchee.run( | ||
%{ | ||
"parse_index_file" => fn index_file_path -> | ||
iodevice = thd_open_file!.(index_file_path) | ||
ParseIndexFile.from_iodevice(iodevice) | ||
File.close(iodevice) | ||
end | ||
}, | ||
inputs: inputs | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters