Added some debug information for LHelp starting times

git-svn-id: trunk@47986 -
This commit is contained in:
andrew 2015-02-25 01:36:03 +00:00
parent cc83db2a68
commit 3cf8301564
3 changed files with 47 additions and 11 deletions

View File

@ -5,7 +5,7 @@ object HelpForm: THelpForm
Width = 758
ActiveControl = Panel1
Caption = 'LHelp'
ClientHeight = 516
ClientHeight = 508
ClientWidth = 758
Icon.Data = {
7E04000000000100010010100000010020006804000016000000280000001000
@ -52,7 +52,7 @@ object HelpForm: THelpForm
OnKeyUp = FormKeyUp
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '1.3'
LCLVersion = '1.5'
Visible = True
object Panel1: TPanel
Left = 0
@ -238,7 +238,7 @@ object HelpForm: THelpForm
end
object PageControl: TPageControl
Left = 0
Height = 484
Height = 476
Top = 32
Width = 758
Align = alClient

View File

@ -551,7 +551,7 @@ begin
begin
Url := 'file://'+FileReq.FileName;
Res := OpenURL(URL);
debugln('got rtfile, filename '+filereq.filename);
//debugln('got rtfile, filename '+filereq.filename);
end;
rtUrl:
begin
@ -568,7 +568,7 @@ begin
Url := UrlReq.Url;
Res := OpenURL(Url);
end;
debugln('got rturl, filename '+urlreq.filerequest.filename+', url '+urlreq.url);
//debugln('got rturl, filename '+urlreq.filerequest.filename+', url '+urlreq.url);
end;
rtContext:
begin
@ -577,7 +577,7 @@ begin
Stream.Read(ConReq, SizeOf(ConReq));
Url := 'file://'+FileReq.FileName;
Res := OpenURL(Url, ConReq.HelpContext);
debugln('got rtcontext, filename '+filereq.filename+', context '+inttostr(ConReq.HelpContext));
//debugln('got rtcontext, filename '+filereq.filename+', context '+inttostr(ConReq.HelpContext));
end;
rtMisc:
begin
@ -589,7 +589,7 @@ begin
begin
MustClose:=true;
Res:= ord(srSuccess);
debugln('got rtmisc/mrClose');
//debugln('got rtmisc/mrClose');
end;
mrShow:
begin
@ -598,7 +598,7 @@ begin
WindowState := wsNormal;
RefreshState;
Res := ord(srSuccess);
debugln('got rtmisc/mrShow');
//debugln('got rtmisc/mrShow');
end;
mrVersion:
begin
@ -608,7 +608,7 @@ begin
Res := ord(srSuccess)
else
Res := ord(srError); //version not supported
debugln('got rtmisc/');
//debugln('got rtmisc/');
end;
mrBeginUpdate:
begin
@ -635,7 +635,7 @@ begin
// Unfortunately, the delay time is guesswork=>Sleep(80)?
SendResponse(Res); //send response again in case first wasn't picked up
// Keep after SendResponse to avoid timing issues (e.g. writing to log file):
debugln('Just sent TLHelpResponse code: '+inttostr(Res));
//debugln('Just sent TLHelpResponse code: '+inttostr(Res));
if MustClose then
begin

View File

@ -22,6 +22,7 @@
unit LazChmHelp;
{$mode objfpc}{$H+}
{ $DEFINE CHMLOADTIMES}
interface
@ -167,6 +168,9 @@ var
SearchPaths: TStringList; // SearchPath split to a StringList
SearchFiles: TStringList; // Files found in SearchPath
i: integer;
{$IFDEF CHMLOADTIMES}
StartTime: TDateTime;
{$ENDIF}
begin
{ Alternative:
Open registered chm help files (no online html help etc)
@ -197,6 +201,9 @@ begin
SearchPaths.Delimiter:=';';
SearchPaths.StrictDelimiter:=false;
SearchPaths.DelimitedText:=SearchPath;
{$IFDEF CHMLOADTIMES}
StartTime := Now;
{$ENDIF}
for i := 0 to SearchPaths.Count-1 do
begin
// Note: FindAllFiles has a SearchPath parameter that is a *single* directory,
@ -204,6 +211,11 @@ begin
CHMFiles.AddStrings(SearchFiles);
SearchFiles.Free;
end;
{$IFDEF CHMLOADTIMES}
DebugLn(['CHMLOADTIMES: ',Format('Searching files in %s took %d ms',[SearchPath,DateTimeToTimeStamp(Now-StartTime).Time])]);
StartTime := Now;
{$ENDIF}
fHelpConnection.BeginUpdate;
for i := 0 to CHMFiles.Count-1 do
begin
@ -216,6 +228,11 @@ begin
//Application.ProcessMessages;
end;
end;
{$IFDEF CHMLOADTIMES}
DebugLn(['CHMLOADTIMES: ',Format('Loading chm files took %d ms',[DateTimeToTimeStamp(Now-StartTime).Time])]);
{$ENDIF}
finally
fHelpConnection.EndUpdate;
@ -538,6 +555,10 @@ var
FoundFileName: String;
LHelpPath: String;
WasRunning: boolean;
{$IFDEF CHMLOADTIMES}
TotalTime: TDateTime;
StartTime: TDateTime;
{$ENDIF}
begin
if Pos('file://', Node.URL) = 1 then
begin
@ -580,7 +601,14 @@ begin
// Start server and tell it to hide
// No use setting cursor to hourglass as that may take as long as the
// waitforresponse timeout.
{$IFDEF CHMLOADTIMES}
TotalTime:=Now;
StartTime:=Now;
{$ENDIF}
fHelpConnection.StartHelpServer(HelpLabel, GetHelpExe, true);
{$IFDEF CHMLOADTIMES}
DebugLn(['CHMLOADTIMES: ',Format('Starting LHelp took %d ms',[DateTimeToTimeStamp(Now-StartTime).Time])]);
{$ENDIF}
// If the server is not already running, open all chm files after it has started
// This will allow cross-chm (LCL, FCL etc) searching and browsing in lhelp.
if not(WasRunning) then
@ -604,8 +632,13 @@ begin
end;
end;
end;
{$IFDEF CHMLOADTIMES}
StartTime := Now;
{$ENDIF}
OpenAllCHMsInSearchPath(SearchPath);
{$IFDEF CHMLOADTIMES}
DebugLn(['CHMLOADTIMES: ',Format('Searching and Loading files took %d ms',[DateTimeToTimeStamp(Now-StartTime).Time])]);
{$ENDIF}
// Instruct viewer to show its GUI
Response:=fHelpConnection.RunMiscCommand(mrShow);
if Response<>srSuccess then
@ -616,6 +649,9 @@ begin
fHelpConnection.EndUpdate;
if not WasRunning then
fHelpConnection.EndUpdate;
{$IFDEF CHMLOADTIMES}
DebugLn(['CHMLOADTIMES: ',Format('Total start time was %d ms',[DateTimeToTimeStamp(Now-TotalTime).Time])]);
{$ENDIF}
end
else
begin