1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-01 14:57:52 +01:00
git/t/perf
René Scharfe 564e94e619 perf: add basic sort performance test
Add a sort command to test-string-list that reads lines from stdin,
stores them in a string_list and then sorts it.  Use it in a simple
perf test script to measure the performance of string_list_sort().

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-01-23 11:02:37 -08:00
..
.gitignore
aggregate.perl t/perf: make runner work even if Git is not installed 2015-09-25 10:44:59 -07:00
Makefile
min_time.perl
p0000-perf-lib-sanity.sh
p0001-rev-list.sh t/perf: time rev-list with UNINTERESTING commits 2014-01-21 14:46:17 -08:00
p0002-read-cache.sh read-cache: add simple performance test 2013-06-09 17:03:00 -07:00
p0003-delta-base-cache.sh t/perf: add basic perf tests for delta base cache 2016-08-23 15:26:16 -07:00
p0071-sort.sh perf: add basic sort performance test 2017-01-23 11:02:37 -08:00
p3400-rebase.sh p3400: make test script executable 2016-08-29 12:57:16 -07:00
p3404-rebase-interactive.sh perf: run "rebase -i" under perf 2016-05-13 11:07:12 -07:00
p4000-diff-algorithms.sh
p4001-diff-no-index.sh diff: don't read index when --no-index is given 2013-12-12 12:23:02 -08:00
p4211-line-log.sh p4211: explicitly disable renames in no-rename test 2016-06-22 13:47:55 -07:00
p5302-pack-index.sh p5302-pack-index.sh: use the $( ... ) construct for command substitution 2014-04-23 15:17:03 -07:00
p5303-many-packs.sh t/perf: add tests for many-pack scenarios 2016-07-29 11:05:06 -07:00
p5310-pack-bitmaps.sh pack-objects: use reachability bitmap index when generating non-stdout pack 2016-09-12 13:47:41 -07:00
p5550-fetch-tags.sh fetch: use "quick" has_sha1_file for tag following 2016-10-14 11:31:32 -07:00
p7000-filter-branch.sh filter-branch: skip index read/write when possible 2015-11-06 09:35:49 -08:00
p7300-clean.sh resolve_gitlink_ref: ignore non-repository paths 2016-01-25 11:42:13 -08:00
p7810-grep.sh
perf-lib.sh Merge branch 'jk/perf-any-version' 2016-07-11 10:31:06 -07:00
README t/perf: fix regression in testing older versions of git 2016-06-22 13:47:16 -07:00
run t/perf/run: copy config.mak.autogen & friends to build area 2016-09-15 13:41:11 -07:00

Git performance tests
=====================

This directory holds performance testing scripts for git tools.  The
first part of this document describes the various ways in which you
can run them.

When fixing the tools or adding enhancements, you are strongly
encouraged to add tests in this directory to cover what you are
trying to fix or enhance.  The later part of this short document
describes how your test scripts should be organized.


Running Tests
-------------

The easiest way to run tests is to say "make".  This runs all
the tests on the current git repository.

    === Running 2 tests in this tree ===
    [...]
    Test                                     this tree
    ---------------------------------------------------------
    0001.1: rev-list --all                   0.54(0.51+0.02)
    0001.2: rev-list --all --objects         6.14(5.99+0.11)
    7810.1: grep worktree, cheap regex       0.16(0.16+0.35)
    7810.2: grep worktree, expensive regex   7.90(29.75+0.37)
    7810.3: grep --cached, cheap regex       3.07(3.02+0.25)
    7810.4: grep --cached, expensive regex   9.39(30.57+0.24)

You can compare multiple repositories and even git revisions with the
'run' script:

    $ ./run . origin/next /path/to/git-tree p0001-rev-list.sh

where . stands for the current git tree.  The full invocation is

    ./run [<revision|directory>...] [--] [<test-script>...]

A '.' argument is implied if you do not pass any other
revisions/directories.

You can also manually test this or another git build tree, and then
call the aggregation script to summarize the results:

    $ ./p0001-rev-list.sh
    [...]
    $ GIT_BUILD_DIR=/path/to/other/git ./p0001-rev-list.sh
    [...]
    $ ./aggregate.perl . /path/to/other/git ./p0001-rev-list.sh

aggregate.perl has the same invocation as 'run', it just does not run
anything beforehand.

You can set the following variables (also in your config.mak):

    GIT_PERF_REPEAT_COUNT
	Number of times a test should be repeated for best-of-N
	measurements.  Defaults to 3.

    GIT_PERF_MAKE_OPTS
	Options to use when automatically building a git tree for
	performance testing.  E.g., -j6 would be useful.

    GIT_PERF_REPO
    GIT_PERF_LARGE_REPO
	Repositories to copy for the performance tests.  The normal
	repo should be at least git.git size.  The large repo should
	probably be about linux.git size for optimal results.
	Both default to the git.git you are running from.

You can also pass the options taken by ordinary git tests; the most
useful one is:

--root=<directory>::
	Create "trash" directories used to store all temporary data during
	testing under <directory>, instead of the t/ directory.
	Using this option with a RAM-based filesystem (such as tmpfs)
	can massively speed up the test suite.


Naming Tests
------------

The performance test files are named as:

	pNNNN-commandname-details.sh

where N is a decimal digit.  The same conventions for choosing NNNN as
for normal tests apply.


Writing Tests
-------------

The perf script starts much like a normal test script, except it
sources perf-lib.sh:

	#!/bin/sh
	#
	# Copyright (c) 2005 Junio C Hamano
	#

	test_description='xxx performance test'
	. ./perf-lib.sh

After that you will want to use some of the following:

	test_perf_default_repo  # sets up a "normal" repository
	test_perf_large_repo    # sets up a "large" repository

	test_perf_default_repo sub  # ditto, in a subdir "sub"

        test_checkout_worktree  # if you need the worktree too

At least one of the first two is required!

You can use test_expect_success as usual. In both test_expect_success
and in test_perf, running "git" points to the version that is being
perf-tested. The $MODERN_GIT variable points to the git wrapper for the
currently checked-out version (i.e., the one that matches the t/perf
scripts you are running).  This is useful if your setup uses commands
that only work with newer versions of git than what you might want to
test (but obviously your new commands must still create a state that can
be used by the older version of git you are testing).

For actual performance tests, use

	test_perf 'descriptive string' '
		command1 &&
		command2
	'

test_perf spawns a subshell, for lack of better options.  This means
that

* you _must_ export all variables that you need in the subshell

* you _must_ flag all variables that you want to persist from the
  subshell with 'test_export':

	test_perf 'descriptive string' '
		foo=$(git rev-parse HEAD) &&
		test_export foo
	'

  The so-exported variables are automatically marked for export in the
  shell executing the perf test.  For your convenience, test_export is
  the same as export in the main shell.

  This feature relies on a bit of magic using 'set' and 'source'.
  While we have tried to make sure that it can cope with embedded
  whitespace and other special characters, it will not work with
  multi-line data.