# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1509542756 -3600
#      Wed Nov 01 14:25:56 2017 +0100
# Node ID dcd8b99f4b718f6f16a689c2eb54b9e58ebd1c97
# Parent  d611bec7719dbfde676f4f7cf43b7ba97b18ffb4
Add a test for bundling with variout size

diff --git a/benchmarks/basic_commands.py b/benchmarks/basic_commands.py
--- a/benchmarks/basic_commands.py
+++ b/benchmarks/basic_commands.py
@@ -259,3 +259,46 @@
     def time_up_tip(self, repo, n):
         self._execute("up", "-r", "tip~%d" % n)
         self._execute("up", "-r", "tip")
+
+class BundleTimeTestSuite(object):
+
+    params = [REPOS, [10, 100, 1000, 10000]]
+    param_names = ["repo", "changesets"]
+    timeout = 500
+
+    def __init__(self):
+        super(BundleTimeTestSuite, self).__init__()
+
+        self.timer = timeit.default_timer
+        self.goal_time = 10
+
+    def setup(self, repo_name, n):
+        venv = os.path.abspath(os.path.join(os.path.dirname(sys.executable), ".."))
+        self.repo_name = repo_name
+        self.hgpath = os.path.join(venv, "bin", "hg")
+        self.repo_path = os.path.join(REPOS_DIR, self.repo_name)
+
+    def _execute(self, command, *args):
+        cmd = self._prepare_cmd(command, *args)
+
+        try:
+            return self._single_execute(cmd)
+        except subprocess.CalledProcessError as error:
+            print("ERROR OUTPUT", error.output)
+            raise
+
+    def _prepare_cmd(self, command, *args):
+        cmd = [
+                self.hgpath,
+                "--cwd", self.repo_path,
+                "--traceback",
+                command,
+        ] + list(args)
+
+        return cmd
+
+    def _single_execute(self, cmd):
+        return subprocess.check_output(cmd, stderr=subprocess.STDOUT)
+
+    def time_bundle(self, repo, n):
+        self._execute("bundle", "--base", ":(-%d)" % (n+1), "/tmp/bundle.bundle")