Recent

Author Topic: fcl-web: req. start time attribute  (Read 1420 times)

vincococka

  • Full Member
  • ***
  • Posts: 101
fcl-web: req. start time attribute
« on: August 16, 2015, 03:47:42 pm »
Hi all,

because of lack for ARequest start time, here is small patch for fcl-web that implements it during TRequest object creation phase.
It can be used for example:
- performance tracing in production (imlement procedure AfterResponse that logs request/reply duration)
- performance metrics inside Actions -during action you can use multiple times Application.log ...

You can read request start time via:
Code: [Select]
AResponse.Request.TimeStart
Patch against FPC trunk:
Code: [Select]
--- packages/fcl-web/src/base/httpdefs.pp       (revision 31326)
+++ packages/fcl-web/src/base/httpdefs.pp       (working copy)
@@ -415,6 +415,7 @@
     FServerPort : String;
     FContentRead : Boolean;
     FContent : String;
+    FTimeStart : QWord;
     function GetLocalPathPrefix: string;
     function GetFirstHeaderLine: String;
   Protected
@@ -457,6 +458,7 @@
     Property ContentRange : String Index ord(hhContentRange) Read GetHeaderValue Write SetHeaderValue;
     Property TE : String Index ord(hhTE) Read GetHeaderValue Write SetHeaderValue;
     Property Upgrade : String Index ord(hhUpgrade) Read GetHeaderValue Write SetHeaderValue;
+    Property TimeStart:QWord Read FTimeStart; // Request arrival time
   end;


@@ -1416,6 +1418,7 @@
   FFiles:=CreateUploadedFiles;
   FFiles.FRequest:=Self;
   FLocalPathPrefix:='-';
+  FTimeStart:=GetTickCount64;
 end;

 function TRequest.CreateUploadedFiles: TUploadedFiles;
« Last Edit: August 16, 2015, 06:04:51 pm by vincococka »
---
  Guide me God and I`ll find you

 

TinyPortal © 2005-2018