# HG changeset patch # User Eivind Tagseth # Date 1498727924 -7200 # Node ID 813e1f9d9c53bc244f487349013070cd9820fecd # Parent 0d5be2668d7ded83155948ddefec587db4a589e1 tests: add simple (skipped) unit tests for graph_data that may be used to measure performance Modified by Thomas De Schampheleire to have performance tests in a separate directory so it is easier to run them, and also added some documentation. diff -r 0d5be2668d7d -r 813e1f9d9c53 docs/contributing.rst --- a/docs/contributing.rst Tue Sep 20 22:01:48 2016 +0200 +++ b/docs/contributing.rst Thu Jun 29 11:18:44 2017 +0200 @@ -98,6 +98,17 @@ -s, --capture=no don't capture stdout (any stdout output will be printed immediately) +Performance tests +^^^^^^^^^^^^^^^^^ + +A number of performance tests are present in the test suite, but they are +not run in a standard test run. These tests are useful to +evaluate the impact of certain code changes with respect to performance. + +To run these tests:: + + env TEST_PERFORMANCE=1 py.test kallithea/tests/performance + Contribution guidelines ----------------------- diff -r 0d5be2668d7d -r 813e1f9d9c53 kallithea/tests/performance/test_vcs.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kallithea/tests/performance/test_vcs.py Thu Jun 29 11:18:44 2017 +0200 @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import pytest +from kallithea.model.db import Repository +from kallithea.tests.base import * + +@pytest.mark.skipif("not os.environ.has_key('TEST_PERFORMANCE')", reason="skipping performance tests, set TEST_PERFORMANCE in environment if desired") +class TestVCSPerformance(TestController): + + def graphmod(self, repo): + """ Simple test for running the graph_data function for profiling/testing performance. """ + from kallithea.lib.graphmod import graph_data + dbr = Repository.get_by_repo_name(repo) + scm_inst = dbr.scm_instance + collection = scm_inst.get_changesets(start=0, end=None, branch_name=None) + revs = [x.revision for x in collection] + jsdata = graph_data(scm_inst, revs) + + def test_graphmod_hg(self, benchmark): + self.graphmod(HG_REPO) + + def test_graphmod_git(self, benchmark): + self.graphmod(GIT_REPO)