Prechádzať zdrojové kódy

+ -B added to get timing info

git-svn-id: trunk@8618 -
florian 18 rokov pred
rodič
commit
f1d131ab83
3 zmenil súbory, kde vykonal 56 pridanie a 2 odobranie
  1. 1 0
      .gitattributes
  2. 39 0
      tests/utils/bench.pp
  3. 16 2
      tests/utils/dotest.pp

+ 1 - 0
.gitattributes

@@ -7229,6 +7229,7 @@ tests/units/popuperr.pp svneol=native#text/plain
 tests/units/win32err.pp svneol=native#text/plain
 tests/units/win32err.pp svneol=native#text/plain
 tests/utils/Makefile svneol=native#text/plain
 tests/utils/Makefile svneol=native#text/plain
 tests/utils/Makefile.fpc svneol=native#text/plain
 tests/utils/Makefile.fpc svneol=native#text/plain
+tests/utils/bench.pp svneol=native#text/plain
 tests/utils/dbdigest.pp svneol=native#text/plain
 tests/utils/dbdigest.pp svneol=native#text/plain
 tests/utils/dbtests.pp svneol=native#text/plain
 tests/utils/dbtests.pp svneol=native#text/plain
 tests/utils/digest.pp svneol=native#text/plain
 tests/utils/digest.pp svneol=native#text/plain

+ 39 - 0
tests/utils/bench.pp

@@ -0,0 +1,39 @@
+{
+    This file is part of the Free Pascal test suite.
+    Copyright (c) 1999-2002 by the Free Pascal development team.
+
+    This program makes the compilation and
+    execution of individual test sources.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+{$mode objfpc}
+unit bench;
+
+
+  interface
+
+    function GetMicroSTicks : int64;
+
+  implementation
+
+    uses
+      sysutils;
+
+    function GetMicroSTicks : int64;
+      var
+         h,m,s,s1000 : word;
+      begin
+         decodetime(time,h,m,s,s1000);
+         result:=(int64(h)*3600000+int64(m)*60000+int64(s)*1000+int64(s1000))*1000;
+      end;
+
+
+end.
+

+ 16 - 2
tests/utils/dotest.pp

@@ -22,7 +22,8 @@ uses
 {$endif}
 {$endif}
   teststr,
   teststr,
   testu,
   testu,
-  redir;
+  redir,
+  bench;
 
 
 {$ifdef go32v2}
 {$ifdef go32v2}
   {$define LIMIT83FS}
   {$define LIMIT83FS}
@@ -75,6 +76,7 @@ const
   DoAll : boolean = false;
   DoAll : boolean = false;
   DoUsual : boolean = true;
   DoUsual : boolean = true;
   TargetDir : string = '';
   TargetDir : string = '';
+  BenchmarkInfo : boolean = false;
   ExtraCompilerOpts : string = '';
   ExtraCompilerOpts : string = '';
   DelExecutable : boolean = false;
   DelExecutable : boolean = false;
   RemoteAddr : string = '';
   RemoteAddr : string = '';
@@ -692,17 +694,22 @@ var
   TestRemoteExe,
   TestRemoteExe,
   TestExe  : string;
   TestExe  : string;
   execres  : boolean;
   execres  : boolean;
-
+  EndTicks,
+  StartTicks : int64;
   function ExecuteRemote(const prog,args:string):boolean;
   function ExecuteRemote(const prog,args:string):boolean;
     begin
     begin
       Verbose(V_Debug,'RemoteExecuting '+Prog+' '+args);
       Verbose(V_Debug,'RemoteExecuting '+Prog+' '+args);
+      StartTicks:=GetMicroSTicks;
       ExecuteRemote:=ExecuteRedir(prog,args,'',EXELogFile,'stdout');
       ExecuteRemote:=ExecuteRedir(prog,args,'',EXELogFile,'stdout');
+      EndTicks:=GetMicroSTicks;
     end;
     end;
 
 
   function ExecuteEmulated(const prog,args:string):boolean;
   function ExecuteEmulated(const prog,args:string):boolean;
     begin
     begin
       Verbose(V_Debug,'EmulatorExecuting '+Prog+' '+args);
       Verbose(V_Debug,'EmulatorExecuting '+Prog+' '+args);
+      StartTicks:=GetMicroSTicks;
       ExecuteEmulated:=ExecuteRedir(prog,args,'',FullExeLogFile,'stdout');
       ExecuteEmulated:=ExecuteRedir(prog,args,'',FullExeLogFile,'stdout');
+      EndTicks:=GetMicroSTicks;
    end;
    end;
 
 
 begin
 begin
@@ -756,10 +763,12 @@ begin
       {$I+}
       {$I+}
       ioresult;
       ioresult;
       { don't redirect interactive and graph programs }
       { don't redirect interactive and graph programs }
+      StartTicks:=GetMicroSTicks;
       if Config.IsInteractive or Config.UsesGraph then
       if Config.IsInteractive or Config.UsesGraph then
         execres:=ExecuteRedir(CurrDir+SplitFileName(TestExe),'','','','')
         execres:=ExecuteRedir(CurrDir+SplitFileName(TestExe),'','','','')
       else
       else
         execres:=ExecuteRedir(CurrDir+SplitFileName(TestExe),'','',FullExeLogFile,'stdout');
         execres:=ExecuteRedir(CurrDir+SplitFileName(TestExe),'','',FullExeLogFile,'stdout');
+      EndTicks:=GetMicroSTicks;
       {$I-}
       {$I-}
        ChDir(OldDir);
        ChDir(OldDir);
       {$I+}
       {$I+}
@@ -768,6 +777,10 @@ begin
 
 
   { Error during execution? }
   { Error during execution? }
   Verbose(V_Debug,'Exitcode '+ToStr(ExecuteResult));
   Verbose(V_Debug,'Exitcode '+ToStr(ExecuteResult));
+  if BenchmarkInfo then
+    begin
+      Verbose(V_Normal,'Execution took '+ToStr(EndTicks-StartTicks)+' us');
+    end;
   if (not execres) and (ExecuteResult=0) then
   if (not execres) and (ExecuteResult=0) then
     begin
     begin
       AddLog(FailLogFile,TestName);
       AddLog(FailLogFile,TestName);
@@ -833,6 +846,7 @@ var
     writeln('dotest [Options] <File>');
     writeln('dotest [Options] <File>');
     writeln;
     writeln;
     writeln('Options can be:');
     writeln('Options can be:');
+    writeln('  -B            output benchmark information');
     writeln('  -C<compiler>  set compiler to use');
     writeln('  -C<compiler>  set compiler to use');
     writeln('  -V            verbose');
     writeln('  -V            verbose');
     writeln('  -E            execute test also');
     writeln('  -E            execute test also');