Skip to content

Commit 1ecb5ff

Browse files
René Scharfegitster
authored andcommitted
read-cache: add simple performance test
Add the helper test-read-cache, which can be used to call read_cache and discard_cache in a loop as well as a performance check based on it. Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent edca415 commit 1ecb5ff

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
190190
/test-mktemp
191191
/test-parse-options
192192
/test-path-utils
193+
/test-read-cache
193194
/test-regex
194195
/test-revision-walking
195196
/test-run-command

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ TEST_PROGRAMS_NEED_X += test-mergesort
558558
TEST_PROGRAMS_NEED_X += test-mktemp
559559
TEST_PROGRAMS_NEED_X += test-parse-options
560560
TEST_PROGRAMS_NEED_X += test-path-utils
561+
TEST_PROGRAMS_NEED_X += test-read-cache
561562
TEST_PROGRAMS_NEED_X += test-regex
562563
TEST_PROGRAMS_NEED_X += test-revision-walking
563564
TEST_PROGRAMS_NEED_X += test-run-command

t/perf/p0002-read-cache.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
test_description="Tests performance of reading the index"
4+
5+
. ./perf-lib.sh
6+
7+
test_perf_default_repo
8+
9+
count=1000
10+
test_perf "read_cache/discard_cache $count times" "
11+
test-read-cache $count
12+
"
13+
14+
test_done

test-read-cache.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include "cache.h"
2+
3+
int main (int argc, char **argv)
4+
{
5+
int i, cnt = 1;
6+
if (argc == 2)
7+
cnt = strtol(argv[1], NULL, 0);
8+
for (i = 0; i < cnt; i++) {
9+
read_cache();
10+
discard_cache();
11+
}
12+
return 0;
13+
}

0 commit comments

Comments
 (0)