-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgit.erl
executable file
·41 lines (29 loc) · 1.18 KB
/
git.erl
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
#!/usr/bin/env escript
-mode(compile).
-define(D(X), io:format("git.erl:~p ~240p~n", [?LINE, X])).
-define(DBG(Fmt,X), io:format("git.erl:~p "++Fmt++"~n", [?LINE| X])).
-define(IS_HEX(A), ((A >= $0 andalso A =< $9) orelse (A >= $A andalso A =< $F) orelse (A >= $a andalso A =< $f)).
test1(0, _Git) -> ok;
test1(N, Git) ->
{ok, Git1, blob, Blob} = gitty:show(Git, "master:src/gitty.app.src"),
size(Blob) == 228 orelse error({invalid_size, size(Blob)}),
test1(N - 1, Git1).
test2(0) -> ok;
test2(N) ->
Blob = git:show(".git", "src/gitty.app.src"),
size(Blob) == 228 orelse error({invalid_size, size(Blob)}),
test2(N - 1).
main([]) ->
code:add_pathz("ebin"),
N = 1000,
{_T1, ok} = timer:tc(fun() -> test1(N, ".git") end),
{_T2, ok} = timer:tc(fun() -> test2(N) end),
% ?D(gitty:show("test/dot_git", "d8c6431e0a82b6b1bd4db339ee536f8bd4099c8f")),
?DBG("Cached access: ~.3f, non-cached access: ~.3f", [_T1 / 1000000, _T2 / 1000000]),
% ?D(gitty:list(".git", "")),
% ?D(gitty:list("test/small_git", "master:")),
% ?D(gitty:list("../grit/test/dot_git_spaces", "master:")),
% {ok, _Git, _List} = gitty:list("test/dot_git", "nonpack:test"),
% ?D(Git),
% ?D(_List),
ok.