delphi 生成一千万15位随机字符串

大概1秒钟吧 

program Project2;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils,
  Winapi.Windows;

function GetRandomid(vlen: integer): string;
var
  i, t: integer;
  lc: array[0..14] of char;
const lchar:string ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
begin
  Result := '';
  lc := '';
  for i := 0 to vlen -1 do
  lc[i] := lchar[Random(62) + 1];
  Result := lc;
end;


var
 t,i: Integer;
 lstr: string;
begin
  try
     t := GetTickCount;
     randomize;
     for I := 1 to 10000000 do
       begin
         if i < 101 then
         Writeln(GetRandomid(15))
         else
         GetRandomid(15);
       end;
     t := GetTickCount - t;
     Writeln(Format('10000000次 %d 毫秒',[t]));
     Readln(lstr);
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.
发布了90 篇原创文章 · 获赞 33 · 访问量 21万+

猜你喜欢

转载自blog.csdn.net/y281252548/article/details/99861704