~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/benchmarks/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-07 21:26:25 UTC
  • mto: (1908.4.6 commit-perf)
  • mto: This revision was merged to the branch mainline in revision 1923.
  • Revision ID: john@arbash-meinel.com-20060807212625-80d116ae82323e5c
Updated bench_bench tests to test exactly what we really want to test

Show diffs side-by-side

added added

removed removed

Lines of Context:
85
85
        self.build_tree(files)
86
86
        os.chdir(cwd)
87
87
 
 
88
    def _cache_kernel_like_tree(self):
 
89
        """Create the kernel_like_tree cache dir if it doesn't exist"""
 
90
        cache_dir, is_cached = self.get_cache_dir('kernel_like_tree')
 
91
        if is_cached:
 
92
            return cache_dir
 
93
        os.mkdir(cache_dir)
 
94
        self._make_kernel_files(root=cache_dir)
 
95
        self._protect_files(cache_dir)
 
96
        return cache_dir
 
97
 
88
98
    def _link_or_copy_kernel_files(self, root, do_link=True):
89
99
        """Hardlink the kernel files from the cached location.
90
100
 
101
111
            self._make_kernel_files(root=root)
102
112
            return
103
113
 
104
 
        cache_dir, is_cached = self.get_cache_dir('kernel_like_tree')
105
 
        if not is_cached:
106
 
            os.mkdir(cache_dir)
107
 
            self._make_kernel_files(root=cache_dir)
108
 
            self._protect_files(cache_dir)
 
114
        cache_dir = self._cache_kernel_like_tree()
109
115
 
110
116
        # Hardlinking the target directory is *much* faster (7s => <1s).
111
117
        osutils.copy_tree(cache_dir, root,
156
162
                if kind == 'file':
157
163
                    os.chmod(abspath, 0440)
158
164
 
 
165
    def _cache_kernel_like_added_tree(self):
 
166
        cache_dir, is_cached = self.get_cache_dir('kernel_like_added_tree')
 
167
        if is_cached:
 
168
            return cache_dir
 
169
 
 
170
        # Get a basic tree with working files
 
171
        tree = self.make_kernel_like_tree(root=cache_dir,
 
172
                                          hardlink_working=True)
 
173
        # Add everything to it
 
174
        add.smart_add_tree(tree, [cache_dir], recurse=True, save=True)
 
175
 
 
176
        self._protect_files(cache_dir+'/.bzr')
 
177
        return cache_dir
 
178
 
159
179
    def make_kernel_like_added_tree(self, root='.',
160
180
                                    hardlink_working=True):
161
181
        """Make a kernel like tree, with all files added
168
188
        # There isn't much underneath .bzr, so we don't support hardlinking
169
189
        # it. Testing showed there wasn't much gain, and there is potentially
170
190
        # a problem if someone modifies something underneath us.
171
 
        cache_dir, is_cached = self.get_cache_dir('kernel_like_added_tree')
172
 
        if not is_cached:
173
 
            # Get a basic tree with working files
174
 
            tree = self.make_kernel_like_tree(root=cache_dir,
175
 
                                              hardlink_working=True)
176
 
            # Add everything to it
177
 
            add.smart_add_tree(tree, [cache_dir], recurse=True, save=True)
178
 
 
179
 
            self._protect_files(cache_dir+'/.bzr')
 
191
        cache_dir = self._cache_kernel_like_added_tree()
180
192
 
181
193
        self._clone_tree(cache_dir, root,
182
194
                         link_working=hardlink_working)
183
195
        return workingtree.WorkingTree.open(root)
184
196
 
 
197
    def _cache_kernel_like_committed_tree(self):
 
198
        cache_dir, is_cached = self.get_cache_dir('kernel_like_committed_tree')
 
199
        if is_cached:
 
200
            return cache_dir
 
201
 
 
202
        # Get a basic tree with working files
 
203
        tree = self.make_kernel_like_added_tree(root=cache_dir,
 
204
                                                hardlink_working=True)
 
205
        tree.commit('first post', rev_id='r1')
 
206
 
 
207
        self._protect_files(cache_dir+'/.bzr')
 
208
        return cache_dir
 
209
 
185
210
    def make_kernel_like_committed_tree(self, root='.',
186
211
                                    hardlink_working=True,
187
212
                                    hardlink_bzr=False):
194
219
        :param hardlink_bzr: Hardlink the .bzr directory. For readonly 
195
220
            operations this is safe, and shaves off a lot of setup time
196
221
        """
197
 
        cache_dir, is_cached = self.get_cache_dir('kernel_like_committed_tree')
198
 
        if not is_cached:
199
 
            # Get a basic tree with working files
200
 
            tree = self.make_kernel_like_added_tree(root=cache_dir,
201
 
                                                    hardlink_working=True)
202
 
            tree.commit('first post', rev_id='r1')
203
 
 
204
 
            self._protect_files(cache_dir+'/.bzr')
 
222
        cache_dir = self._cache_kernel_like_committed_tree()
205
223
 
206
224
        # Now we have a cached tree, just copy it
207
225
        self._clone_tree(cache_dir, root,