|  | 
 
| [mw_shl_code=delphi,true]var FTimerService: IFMXTimerService;
 FFrameCount: Integer;
 FFPS, FRenderTime, FBeginTime, FEndTime: Extended;
 
 procedure TForm1.FormCreate(Sender: TObject);
 begin
 if FTimerService = nil then
 if not TPlatformServices.Current.SupportsPlatformService(IFMXTimerService, FTimerService) then
 raise EUnsupportedPlatformService.Create('IFMXTimerService');
 end;
 
 procedure TForm1.BeginScene;
 begin
 if FTimerService <> nil then
 FBeginTime := FTimerService.GetTick;
 end;
 
 procedure TForm1.EndScene;
 begin
 if FTimerService <> nil then
 begin
 FEndTime    := FTimerService.GetTick;
 FRenderTime := FRenderTime + (FEndTime - FBeginTime);
 FFrameCount := FFrameCount + 1;
 
 if (FFrameCount > 10) and (FRenderTime > 0) then
 begin
 FFPS        := FFrameCount / FRenderTime;
 FRenderTime := 0;
 FFrameCount := 0;
 end;
 end;
 end;
 
 procedure TForm1.Button1Click(Sender: TObject);
 begin
 TThread.CreateAnonymousThread(
 procedure
 var i: Integer;
 begin
 try
 for i:=0 to 100 do
 begin
 BeginScene;
 
 TThread.Synchronize(TThread.CurrentThread,
 procedure
 begin
 
 //----------------------------------------
 // 显示代码写在这里
 //----------------------------------------
 
 Label1.Text := FFPS.ToString;
 end);
 
 EndScene;
 end;
 finally
 end;
 end).Start;
 end;[/mw_shl_code]
 
 | 
 |