mirror of
https://github.com/git/git.git
synced 2024-11-24 02:17:02 +08:00
Merge branch 'rs/discard-index-discard-array' into maint
* rs/discard-index-discard-array: read-cache: free cache in discard_index read-cache: add simple performance test
This commit is contained in:
commit
65ed8684c4
1
.gitignore
vendored
1
.gitignore
vendored
@ -190,6 +190,7 @@
|
||||
/test-mktemp
|
||||
/test-parse-options
|
||||
/test-path-utils
|
||||
/test-read-cache
|
||||
/test-regex
|
||||
/test-revision-walking
|
||||
/test-run-command
|
||||
|
1
Makefile
1
Makefile
@ -565,6 +565,7 @@ TEST_PROGRAMS_NEED_X += test-mergesort
|
||||
TEST_PROGRAMS_NEED_X += test-mktemp
|
||||
TEST_PROGRAMS_NEED_X += test-parse-options
|
||||
TEST_PROGRAMS_NEED_X += test-path-utils
|
||||
TEST_PROGRAMS_NEED_X += test-read-cache
|
||||
TEST_PROGRAMS_NEED_X += test-regex
|
||||
TEST_PROGRAMS_NEED_X += test-revision-walking
|
||||
TEST_PROGRAMS_NEED_X += test-run-command
|
||||
|
@ -1518,8 +1518,9 @@ int discard_index(struct index_state *istate)
|
||||
free_name_hash(istate);
|
||||
cache_tree_free(&(istate->cache_tree));
|
||||
istate->initialized = 0;
|
||||
|
||||
/* no need to throw away allocated active_cache */
|
||||
free(istate->cache);
|
||||
istate->cache = NULL;
|
||||
istate->cache_alloc = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
14
t/perf/p0002-read-cache.sh
Executable file
14
t/perf/p0002-read-cache.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description="Tests performance of reading the index"
|
||||
|
||||
. ./perf-lib.sh
|
||||
|
||||
test_perf_default_repo
|
||||
|
||||
count=1000
|
||||
test_perf "read_cache/discard_cache $count times" "
|
||||
test-read-cache $count
|
||||
"
|
||||
|
||||
test_done
|
13
test-read-cache.c
Normal file
13
test-read-cache.c
Normal file
@ -0,0 +1,13 @@
|
||||
#include "cache.h"
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int i, cnt = 1;
|
||||
if (argc == 2)
|
||||
cnt = strtol(argv[1], NULL, 0);
|
||||
for (i = 0; i < cnt; i++) {
|
||||
read_cache();
|
||||
discard_cache();
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user