~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tools/weavebench.py

  • Committer: Martin Pool
  • Date: 2005-07-15 22:55:36 UTC
  • Revision ID: mbp@sourcefrog.net-20050715225536-47d68404108e4eb8
- shell script to set up a weave merge test case

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /usr/bin/python
2
2
 
3
3
# Copyright (C) 2005 Canonical Ltd
4
 
#
 
4
 
5
5
# This program is free software; you can redistribute it and/or modify
6
6
# it under the terms of the GNU General Public License as published by
7
7
# the Free Software Foundation; either version 2 of the License, or
8
8
# (at your option) any later version.
9
 
#
 
9
 
10
10
# This program is distributed in the hope that it will be useful,
11
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
13
# GNU General Public License for more details.
14
 
#
 
14
 
15
15
# You should have received a copy of the GNU General Public License
16
16
# along with this program; if not, write to the Free Software
17
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
18
 
19
19
 
20
20
"""Weave algorithms benchmark"""
23
23
from bzrlib.weave import Weave
24
24
from bzrlib.weavefile import write_weave
25
25
from bzrlib.progress import ProgressBar
26
 
from random import randrange, randint, seed
 
26
from random import randrange, randint
27
27
import tempfile
28
28
import hotshot, hotshot.stats
29
29
import sys
30
30
 
31
31
WEAVE_NAME = "bench.weave"
32
 
NUM_REVS = 2000
33
 
 
34
 
seed(0)
 
32
NUM_REVS = 10000
35
33
 
36
34
def build():
37
 
    pb = ProgressBar(show_eta=False)
 
35
    pb = ProgressBar()
38
36
 
39
37
    wf = Weave()
40
38
    lines = []
51
49
            if lines:
52
50
                del lines[randrange(0, len(lines))]
53
51
 
54
 
        rev_id = wf.add("%s" % i, parents, lines)
 
52
        rev_id = wf.add(parents, lines)
55
53
        parents = [rev_id]
56
54
 
57
55
    write_weave(wf, file(WEAVE_NAME, 'wb'))
91
89
            
92
90
 
93
91
if '-p' in sys.argv[1:]:
94
 
    opt_p = True
95
 
    sys.argv.remove('-p')
96
 
else:
97
 
    opt_p = False
98
 
 
99
 
if len(sys.argv) > 1:
100
 
    NUM_REVS = int(sys.argv[1])
101
 
 
102
 
if opt_p:
103
92
    profileit(build)
104
93
else:
105
94
    build()