~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/benchmarks/bench_cache_utf8.py

(robertc) Partial fix for bug #39542 - allow lightweight checkouts over http.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006 by Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
 
# it under the terms of the GNU General Public License as published by
5
 
# the Free Software Foundation; either version 2 of the License, or
6
 
# (at your option) any later version.
 
4
# it under the terms of the GNU General Public License version 2 as published by
 
5
# the Free Software Foundation.
7
6
#
8
7
# This program is distributed in the hope that it will be useful,
9
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
11
#
13
12
# You should have received a copy of the GNU General Public License
14
13
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
 
14
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
15
 
18
16
"""Tests for encoding performance."""
19
17
 
35
33
 
36
34
 
37
35
class EncodingBenchmark(Benchmark):
38
 
    """Benchmark the time to encode strings."""
39
36
 
40
37
    def setUp(self):
41
38
        super(EncodingBenchmark, self).setUp()
107
104
 
108
105
    def test_encode_1k_by_1k_unicode(self):
109
106
        """Test encoding 5 revisions 100k times"""
110
 
        revisions = [u'\u062c\u0648\u062c\u0648' +
 
107
        revisions = ['\u062c\u0648\u062c\u0648' +
111
108
                     unicode(osutils.rand_chars(60)) for x in xrange(1000)]
112
109
        self.time(self.encode_multi, revisions, 1000)
113
110
 
114
111
    def test_encode_1k_by_1k_unicode_cached(self):
115
112
        """Test encoding 5 revisions 100k times"""
116
 
        revisions = [u'\u062c\u0648\u062c\u0648' +
 
113
        revisions = ['\u062c\u0648\u062c\u0648' +
117
114
                     unicode(osutils.rand_chars(60)) for x in xrange(1000)]
118
115
        self.time(self.encode_cached_multi, revisions, 1000)
119
116
 
120
 
    def test_encode_500K_by_1_ascii(self):
121
 
        revisions = [unicode("test%07d" % x) for x in xrange(500000)]
122
 
        self.time(self.encode_multi, revisions, 1)
123
 
 
124
 
    def test_encode_500K_by_1_ascii_cached(self):
125
 
        revisions = [unicode("test%07d" % x) for x in xrange(500000)]
126
 
        self.time(self.encode_cached_multi, revisions, 1)
127
 
 
128
 
    def test_encode_500K_by_1_unicode(self):
129
 
        revisions = [u'\u062c\u0648\u062c\u0648' +
130
 
                     unicode("%07d" % x) for x in xrange(500000)]
131
 
        self.time(self.encode_multi, revisions, 1)
132
 
 
133
 
    def test_encode_500K_by_1_unicode_cached(self):
134
 
        revisions = [u'\u062c\u0648\u062c\u0648' +
135
 
                     unicode("%07d" % x) for x in xrange(500000)]
136
 
        self.time(self.encode_cached_multi, revisions, 1)
137
 
 
138
117
 
139
118
class DecodingBenchmarks(Benchmark):
140
 
    """Benchmark the time to decode strings."""
141
119
 
142
120
    def setUp(self):
143
121
        super(DecodingBenchmarks, self).setUp()
193
171
 
194
172
    def test_decode_1k_by_1k_unicode(self):
195
173
        """Test decoding 5 revisions 100k times"""
196
 
        revisions = [(u'\u062c\u0648\u062c\u0648' +
 
174
        revisions = [('\u062c\u0648\u062c\u0648' +
197
175
                      unicode(osutils.rand_chars(60))).encode('utf8')
198
176
                     for x in xrange(1000)]
199
177
        self.time(self.decode_multi, revisions, 1000)
200
178
 
201
179
    def test_decode_1k_by_1k_unicode_cached(self):
202
180
        """Test decoding 5 revisions 100k times"""
203
 
        revisions = [(u'\u062c\u0648\u062c\u0648' +
 
181
        revisions = [('\u062c\u0648\u062c\u0648' +
204
182
                      unicode(osutils.rand_chars(60))).encode('utf8')
205
183
                     for x in xrange(1000)]
206
184
        self.time(self.decode_cached_multi, revisions, 1000)
207
 
 
208
 
    def test_decode_500K_by_1_ascii(self):
209
 
        revisions = [("test%07d" % x) for x in xrange(500000)]
210
 
        self.time(self.decode_multi, revisions, 1)
211
 
 
212
 
    def test_decode_500K_by_1_ascii_cached(self):
213
 
        revisions = [("test%07d" % x) for x in xrange(500000)]
214
 
        self.time(self.decode_cached_multi, revisions, 1)
215
 
 
216
 
    def test_decode_500K_by_1_unicode(self):
217
 
        revisions = [(u'\u062c\u0648\u062c\u0648' +
218
 
                      unicode("%07d" % x)).encode('utf-8')
219
 
                     for x in xrange(500000)]
220
 
        self.time(self.decode_multi, revisions, 1)
221
 
 
222
 
    def test_decode_500K_by_1_unicode_cached(self):
223
 
        revisions = [(u'\u062c\u0648\u062c\u0648' +
224
 
                      unicode("%07d" % x)).encode('utf-8')
225
 
                     for x in xrange(500000)]
226
 
        self.time(self.decode_cached_multi, revisions, 1)