你也可用下面这个试一试。var pc, pcs: PChar
ps, sWatch: string
npos,i,s,t: Integer
ticktock: Cardinal;begin ps:= '-abcd-efgh-ijkl-mnop-efgh-ijkl-mnop-efgh-ijkl-mnop-efgh-ijkl-mnop'
ps:= ps+ps+ps+ps
pc:= @ps[1]
npos:= 1
ticktock:= GetTickCount();//Method 1: for s := 1 to 100000 do begin pc:= @ps[1]
for i:= 1 to Length(ps) do begin if (pc^= '-')then begin inc(pc);// ShowMessage(pc)
//这里是打印,但应用中可能是复制或操作。// mmo1.Lines.Add(pc)
end
inc(pc)
end
end;//Method 2:// for t := 1 to 100000 do// begin// npos:= 1;// while (npos< Length(ps)-4) do// begin// npos:= PosEx('-', ps, npos);// Inc(npos);// sWatch:= Copy(ps, npos, Length(ps));//// mmo1.Lines.Add(sWatch);// end;// end
ticktock:= GetTickCount() - ticktock
ShowMessage(IntToStr(ticktock));end;