1
# Copyright (C) 2006 by Canonical Ltd
1
# Copyright (C) 2006 Canonical Ltd
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 version 2 as published by
5
# the Free Software Foundation.
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.
7
8
# This program is distributed in the hope that it will be useful,
8
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
14
# along with this program; if not, write to the Free Software
14
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
18
"""Tests for encoding performance."""
18
20
from bzrlib import (
105
107
def test_encode_1k_by_1k_unicode(self):
106
108
"""Test encoding 5 revisions 100k times"""
107
revisions = ['\u062c\u0648\u062c\u0648' +
109
revisions = [u'\u062c\u0648\u062c\u0648' +
108
110
unicode(osutils.rand_chars(60)) for x in xrange(1000)]
109
111
self.time(self.encode_multi, revisions, 1000)
111
113
def test_encode_1k_by_1k_unicode_cached(self):
112
114
"""Test encoding 5 revisions 100k times"""
113
revisions = ['\u062c\u0648\u062c\u0648' +
115
revisions = [u'\u062c\u0648\u062c\u0648' +
114
116
unicode(osutils.rand_chars(60)) for x in xrange(1000)]
115
117
self.time(self.encode_cached_multi, revisions, 1000)
119
def test_encode_500K_by_1_ascii(self):
120
revisions = [unicode("test%07d" % x) for x in xrange(500000)]
121
self.time(self.encode_multi, revisions, 1)
123
def test_encode_500K_by_1_ascii_cached(self):
124
revisions = [unicode("test%07d" % x) for x in xrange(500000)]
125
self.time(self.encode_cached_multi, revisions, 1)
127
def test_encode_500K_by_1_unicode(self):
128
revisions = [u'\u062c\u0648\u062c\u0648' +
129
unicode("%07d" % x) for x in xrange(500000)]
130
self.time(self.encode_multi, revisions, 1)
132
def test_encode_500K_by_1_unicode_cached(self):
133
revisions = [u'\u062c\u0648\u062c\u0648' +
134
unicode("%07d" % x) for x in xrange(500000)]
135
self.time(self.encode_cached_multi, revisions, 1)
118
137
class DecodingBenchmarks(Benchmark):
172
191
def test_decode_1k_by_1k_unicode(self):
173
192
"""Test decoding 5 revisions 100k times"""
174
revisions = [('\u062c\u0648\u062c\u0648' +
193
revisions = [(u'\u062c\u0648\u062c\u0648' +
175
194
unicode(osutils.rand_chars(60))).encode('utf8')
176
195
for x in xrange(1000)]
177
196
self.time(self.decode_multi, revisions, 1000)
179
198
def test_decode_1k_by_1k_unicode_cached(self):
180
199
"""Test decoding 5 revisions 100k times"""
181
revisions = [('\u062c\u0648\u062c\u0648' +
200
revisions = [(u'\u062c\u0648\u062c\u0648' +
182
201
unicode(osutils.rand_chars(60))).encode('utf8')
183
202
for x in xrange(1000)]
184
203
self.time(self.decode_cached_multi, revisions, 1000)
205
def test_decode_500K_by_1_ascii(self):
206
revisions = [("test%07d" % x) for x in xrange(500000)]
207
self.time(self.decode_multi, revisions, 1)
209
def test_decode_500K_by_1_ascii_cached(self):
210
revisions = [("test%07d" % x) for x in xrange(500000)]
211
self.time(self.decode_cached_multi, revisions, 1)
213
def test_decode_500K_by_1_unicode(self):
214
revisions = [(u'\u062c\u0648\u062c\u0648' +
215
unicode("%07d" % x)).encode('utf-8')
216
for x in xrange(500000)]
217
self.time(self.decode_multi, revisions, 1)
219
def test_decode_500K_by_1_unicode_cached(self):
220
revisions = [(u'\u062c\u0648\u062c\u0648' +
221
unicode("%07d" % x)).encode('utf-8')
222
for x in xrange(500000)]
223
self.time(self.decode_cached_multi, revisions, 1)