]> git.ipfire.org Git - thirdparty/git.git/commit - t/t5310-pack-bitmaps.sh
test-lib: introduce test_commit_bulk
authorJeff King <peff@peff.net>
Tue, 2 Jul 2019 05:16:49 +0000 (01:16 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 2 Jul 2019 17:08:40 +0000 (10:08 -0700)
commitb1c36cb84908a31ede05e5a16fbc584c7681cffb
tree19359ac8a73db724c996ef2690402bea5210b3b6
parent8dca754b1e874719a732bc9ab7b0e14b21b1bc10
test-lib: introduce test_commit_bulk

Some tests need to create a string of commits. Doing this with
test_commit is very heavy-weight, as it needs at least one process per
commit (and in fact, uses several).

For bulk creation, we can do much better by using fast-import, but it's
often a pain to generate the input. Let's provide a helper to do so.

We'll use t5310 as a guinea pig, as it has three 10-commit loops. Here
are hyperfine results before and after:

  [before]
  Benchmark #1: ./t5310-pack-bitmaps.sh --root=/var/ram/git-tests
    Time (mean ± σ):      2.846 s ±  0.305 s    [User: 3.042 s, System: 0.919 s]
    Range (min … max):    2.250 s …  3.210 s    10 runs

  [after]
  Benchmark #1: ./t5310-pack-bitmaps.sh --root=/var/ram/git-tests
    Time (mean ± σ):      2.210 s ±  0.174 s    [User: 2.570 s, System: 0.604 s]
    Range (min … max):    1.999 s …  2.590 s    10 runs

So we're over 20% faster, while making the callers slightly shorter. We
added a lot more lines in test-lib-function.sh, of course, and the
helper is way more featureful than we need here. But my hope is that it
will be flexible enough to use in more places.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t5310-pack-bitmaps.sh
t/test-lib-functions.sh