mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 13:19:30 +02:00
LazUtf8, another candidate for lower-casing
git-svn-id: trunk@32761 -
This commit is contained in:
parent
7802657a97
commit
44e4f5e830
@ -43,6 +43,8 @@ end;
|
|||||||
procedure AssertStringOperationUTF8LowerCase(AMsg, ALocale, AStr1, AStrExpected2: utf8string);
|
procedure AssertStringOperationUTF8LowerCase(AMsg, ALocale, AStr1, AStrExpected2: utf8string);
|
||||||
begin
|
begin
|
||||||
AssertStringOperation(AMsg, AStr1, UTF8LowerCase(AStr1, ALocale), AStrExpected2);
|
AssertStringOperation(AMsg, AStr1, UTF8LowerCase(AStr1, ALocale), AStrExpected2);
|
||||||
|
AssertStringOperation('MARTIN:'+AMsg, AStr1, UTF8LowerCaseMartin(AStr1, ALocale), AStrExpected2);
|
||||||
|
AssertStringOperation('MARTIN2:'+AMsg, AStr1, UTF8LowerCaseMartin2(AStr1, ALocale), AStrExpected2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function DateTimeToMilliseconds(aDateTime: TDateTime): Int64;
|
function DateTimeToMilliseconds(aDateTime: TDateTime): Int64;
|
||||||
@ -92,9 +94,11 @@ end;
|
|||||||
|
|
||||||
procedure TestUTF8LowerCase;
|
procedure TestUTF8LowerCase;
|
||||||
var
|
var
|
||||||
i: Integer;
|
k, j, i: Integer;
|
||||||
lStartTime, lTimeDiff: TDateTime;
|
lStartTime, lTimeDiff: TDateTime;
|
||||||
Str: UTF8String;
|
Str: UTF8String;
|
||||||
|
const
|
||||||
|
TimerLoop = 5999999;
|
||||||
begin
|
begin
|
||||||
// ASCII
|
// ASCII
|
||||||
AssertStringOperationUTF8LowerCase('ASCII UTF8LowerCase', '', 'ABCDEFGHIJKLMNOPQRSTUWVXYZ', 'abcdefghijklmnopqrstuwvxyz');
|
AssertStringOperationUTF8LowerCase('ASCII UTF8LowerCase', '', 'ABCDEFGHIJKLMNOPQRSTUWVXYZ', 'abcdefghijklmnopqrstuwvxyz');
|
||||||
@ -114,31 +118,71 @@ begin
|
|||||||
AssertStringOperationUTF8LowerCase('Chinese UTF8LowerCase 1', '', '名字叫嘉英,嘉陵江的嘉,英國的英', '名字叫嘉英,嘉陵江的嘉,英國的英');
|
AssertStringOperationUTF8LowerCase('Chinese UTF8LowerCase 1', '', '名字叫嘉英,嘉陵江的嘉,英國的英', '名字叫嘉英,嘉陵江的嘉,英國的英');
|
||||||
|
|
||||||
// Performance test
|
// Performance test
|
||||||
|
Write('Martin LowerCase- Performance test took: ');
|
||||||
|
for j := 0 to 5 do begin
|
||||||
lStartTime := Now;
|
lStartTime := Now;
|
||||||
for i := 0 to 99999 do
|
for i := 0 to TimerLoop do
|
||||||
begin
|
begin
|
||||||
//Str := UTF8LowerCaseMattias('abcdefghijklmnopqrstuwvxyz');
|
if j = 0 then Str := UTF8LowerCaseMartin('abcdefghijklmnopqrstuwvxyz');
|
||||||
//Str := UTF8LowerCaseMattias('ABCDEFGHIJKLMNOPQRSTUWVXYZ');
|
if j = 1 then Str := UTF8LowerCaseMartin('ABCDEFGHIJKLMNOPQRSTUWVXYZ');
|
||||||
//Str := UTF8LowerCaseMattias('aąbcćdeęfghijklłmnńoóprsśtuwyzźż');
|
if j = 2 then Str := UTF8LowerCaseMartin('aąbcćdeęfghijklłmnńoóprsśtuwyzźż');
|
||||||
//Str := UTF8LowerCaseMattias('AĄBCĆDEĘFGHIJKLŁMNŃOÓPRSŚTUWYZŹŻ');
|
if j = 3 then Str := UTF8LowerCaseMartin('AĄBCĆDEĘFGHIJKLŁMNŃOÓPRSŚTUWYZŹŻ');
|
||||||
//Str := UTF8LowerCaseMattias('АБВЕЁЖЗКЛМНОПРДЙГ');
|
if j = 4 then Str := UTF8LowerCaseMartin('АБВЕЁЖЗКЛМНОПРДЙГ');
|
||||||
Str := UTF8LowerCaseMattias('名字叫嘉英,嘉陵江的嘉,英國的英');
|
if j = 5 then Str := UTF8LowerCaseMartin('名字叫嘉英,嘉陵江的嘉,英國的英');
|
||||||
end;
|
end;
|
||||||
lTimeDiff := Now - lStartTime;
|
lTimeDiff := Now - lStartTime;
|
||||||
WriteLn('Mattias LowerCase Performance test took: ', DateTimeToMilliseconds(lTimeDiff), ' ms');
|
Write(Format(' %7d ms ', [DateTimeToMilliseconds(lTimeDiff)]));
|
||||||
|
end;
|
||||||
|
writeln;
|
||||||
|
Write('Martin LowerCase2 Performance test took: ');
|
||||||
|
for j := 0 to 5 do begin
|
||||||
lStartTime := Now;
|
lStartTime := Now;
|
||||||
for i := 0 to 99999 do
|
for i := 0 to TimerLoop do
|
||||||
begin
|
begin
|
||||||
//Str := UTF8LowerCase('abcdefghijklmnopqrstuwvxyz');
|
if j = 0 then Str := UTF8LowerCaseMartin2('abcdefghijklmnopqrstuwvxyz');
|
||||||
//Str := UTF8LowerCase('ABCDEFGHIJKLMNOPQRSTUWVXYZ');
|
if j = 1 then Str := UTF8LowerCaseMartin2('ABCDEFGHIJKLMNOPQRSTUWVXYZ');
|
||||||
//Str := UTF8LowerCase('aąbcćdeęfghijklłmnńoóprsśtuwyzźż');
|
if j = 2 then Str := UTF8LowerCaseMartin2('aąbcćdeęfghijklłmnńoóprsśtuwyzźż');
|
||||||
//Str := UTF8LowerCase('AĄBCĆDEĘFGHIJKLŁMNŃOÓPRSŚTUWYZŹŻ');
|
if j = 3 then Str := UTF8LowerCaseMartin2('AĄBCĆDEĘFGHIJKLŁMNŃOÓPRSŚTUWYZŹŻ');
|
||||||
//Str := UTF8LowerCase('АБВЕЁЖЗКЛМНОПРДЙГ');
|
if j = 4 then Str := UTF8LowerCaseMartin2('АБВЕЁЖЗКЛМНОПРДЙГ');
|
||||||
Str := UTF8LowerCase('名字叫嘉英,嘉陵江的嘉,英國的英');
|
if j = 5 then Str := UTF8LowerCaseMartin2('名字叫嘉英,嘉陵江的嘉,英國的英');
|
||||||
end;
|
end;
|
||||||
lTimeDiff := Now - lStartTime;
|
lTimeDiff := Now - lStartTime;
|
||||||
WriteLn('LowerCase Performance test took: ', DateTimeToMilliseconds(lTimeDiff), ' ms');
|
Write(Format(' %7d ms ', [DateTimeToMilliseconds(lTimeDiff)]));
|
||||||
|
end;
|
||||||
|
writeln;
|
||||||
|
// Performance test
|
||||||
|
Write('Mattias LowerCase- Performance test took: ');
|
||||||
|
for j := 0 to 5 do begin
|
||||||
|
lStartTime := Now;
|
||||||
|
for i := 0 to TimerLoop do
|
||||||
|
begin
|
||||||
|
if j = 0 then Str := UTF8LowerCaseMattias('abcdefghijklmnopqrstuwvxyz');
|
||||||
|
if j = 1 then Str := UTF8LowerCaseMattias('ABCDEFGHIJKLMNOPQRSTUWVXYZ');
|
||||||
|
if j = 2 then Str := UTF8LowerCaseMattias('aąbcćdeęfghijklłmnńoóprsśtuwyzźż');
|
||||||
|
if j = 3 then Str := UTF8LowerCaseMattias('AĄBCĆDEĘFGHIJKLŁMNŃOÓPRSŚTUWYZŹŻ');
|
||||||
|
if j = 4 then Str := UTF8LowerCaseMattias('АБВЕЁЖЗКЛМНОПРДЙГ');
|
||||||
|
if j = 5 then Str := UTF8LowerCaseMattias('名字叫嘉英,嘉陵江的嘉,英國的英');
|
||||||
|
end;
|
||||||
|
lTimeDiff := Now - lStartTime;
|
||||||
|
Write(Format(' %7d ms ', [DateTimeToMilliseconds(lTimeDiff)]));
|
||||||
|
end;
|
||||||
|
writeln;
|
||||||
|
Write(' LowerCase-- Performance test took: ');
|
||||||
|
for j := 0 to 5 do begin
|
||||||
|
lStartTime := Now;
|
||||||
|
for i := 0 to TimerLoop do
|
||||||
|
begin
|
||||||
|
if j = 0 then Str := UTF8LowerCase('abcdefghijklmnopqrstuwvxyz');
|
||||||
|
if j = 1 then Str := UTF8LowerCase('ABCDEFGHIJKLMNOPQRSTUWVXYZ');
|
||||||
|
if j = 2 then Str := UTF8LowerCase('aąbcćdeęfghijklłmnńoóprsśtuwyzźż');
|
||||||
|
if j = 3 then Str := UTF8LowerCase('AĄBCĆDEĘFGHIJKLŁMNŃOÓPRSŚTUWYZŹŻ');
|
||||||
|
if j = 4 then Str := UTF8LowerCase('АБВЕЁЖЗКЛМНОПРДЙГ');
|
||||||
|
if j = 5 then Str := UTF8LowerCase('名字叫嘉英,嘉陵江的嘉,英國的英');
|
||||||
|
end;
|
||||||
|
lTimeDiff := Now - lStartTime;
|
||||||
|
Write(Format(' %7d ms ', [DateTimeToMilliseconds(lTimeDiff)]));
|
||||||
|
end;
|
||||||
|
writeln;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -146,5 +190,6 @@ begin
|
|||||||
TestUTF8UpperCase();
|
TestUTF8UpperCase();
|
||||||
WriteLn('======= LowerCase =======');
|
WriteLn('======= LowerCase =======');
|
||||||
TestUTF8LowerCase();
|
TestUTF8LowerCase();
|
||||||
|
readln;
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user