6 from pybench
import Test
7 from string
import join
9 class ConcatUnicode(Test
):
17 # Make sure the strings are *not* interned
18 s
= unicode(join(map(str,range(100))))
19 t
= unicode(join(map(str,range(1,101))))
21 for i
in xrange(self
.rounds
):
84 s
= unicode(join(map(str,range(100))))
85 t
= unicode(join(map(str,range(1,101))))
87 for i
in xrange(self
.rounds
):
91 class CompareUnicode(Test
):
99 # Make sure the strings are *not* interned
100 s
= unicode(join(map(str,range(10))))
101 t
= unicode(join(map(str,range(10))) + "abc")
103 for i
in xrange(self
.rounds
):
166 s
= unicode(join(map(str,range(10))))
167 t
= unicode(join(map(str,range(10))) + "abc")
169 for i
in xrange(self
.rounds
):
173 class CreateUnicodeWithConcat(Test
):
181 for i
in xrange(self
.rounds
):
244 for i
in xrange(self
.rounds
):
248 class UnicodeSlicing(Test
):
256 s
= unicode(join(map(str,range(100))))
258 for i
in xrange(self
.rounds
):
302 s
= unicode(join(map(str,range(100))))
304 for i
in xrange(self
.rounds
):
309 class UnicodeMappings(Test
):
312 operations
= 3 * (5 + 4 + 2 + 1)
317 s
= join(map(unichr,range(20)),'')
318 t
= join(map(unichr,range(100)),'')
319 u
= join(map(unichr,range(500)),'')
320 v
= join(map(unichr,range(1000)),'')
322 for i
in xrange(self
.rounds
):
374 s
= join(map(unichr,range(20)),'')
375 t
= join(map(unichr,range(100)),'')
376 u
= join(map(unichr,range(500)),'')
377 v
= join(map(unichr,range(1000)),'')
379 for i
in xrange(self
.rounds
):
382 class UnicodePredicates(Test
):
390 data
= (u
'abc', u
'123', u
' ', u
'\u1234\u2345\u3456', u
'\uFFFF'*10)
393 for i
in xrange(self
.rounds
):
394 s
= data
[i
% len_data
]
448 data
= (u
'abc', u
'123', u
' ', u
'\u1234\u2345\u3456', u
'\uFFFF'*10)
451 for i
in xrange(self
.rounds
):
452 s
= data
[i
% len_data
]
459 class UnicodeProperties(Test
):
467 data
= (u
'a', u
'1', u
' ', u
'\u1234', u
'\uFFFF')
469 digit
= unicodedata
.digit
470 numeric
= unicodedata
.numeric
471 decimal
= unicodedata
.decimal
472 category
= unicodedata
.category
473 bidirectional
= unicodedata
.bidirectional
474 decomposition
= unicodedata
.decomposition
475 mirrored
= unicodedata
.mirrored
476 combining
= unicodedata
.combining
478 for i
in xrange(self
.rounds
):
480 c
= data
[i
% len_data
]
529 data
= (u
'a', u
'1', u
' ', u
'\u1234', u
'\uFFFF')
531 digit
= unicodedata
.digit
532 numeric
= unicodedata
.numeric
533 decimal
= unicodedata
.decimal
534 category
= unicodedata
.category
535 bidirectional
= unicodedata
.bidirectional
536 decomposition
= unicodedata
.decomposition
537 mirrored
= unicodedata
.mirrored
538 combining
= unicodedata
.combining
540 for i
in xrange(self
.rounds
):
542 c
= data
[i
% len_data
]