Forum Discussion

Blake_Bryce's avatar
Blake_Bryce
Occasional Contributor
8 years ago

Why is Javascript ReadLine() performance 100000% slower than Jscript?

I am in the process of converting our SmokeTest to javascript and we have a db error log we parse for Ora-errors. Before the conversion to javascript - this process took 12 seconds. Now using SmartBear's own documentation the same function is taking 3min+. Am I doing something wrong?? 

 

let counter = 0;
let logMethod = "Warning";
const ForReading = 1;

let FSObject = Sys.OleObject("Scripting.FileSystemObject");
let file = FSObject.OpenTextFile(ProjectSuite.Variables.FCINSTALLPATH+"\\Setup\\__createdb.log", ForReading);
while(! file.AtEndOfStream)
{
let lineToBeRead = file.ReadLine();
compare = lineToBeRead.search("ORA-");
if(compare > -1)
{
secureRole = lineToBeRead.search("28405");
if(secureRole == -1) 
{
if(logMethod == "Errors" || logMethod == "errors")
Log.Error("Line " + counter +": " + lineToBeRead);
if(logMethod == "Warnings" || logMethod == "warnings")
Log.Warning("Line " + counter +": " + lineToBeRead);
}
else
{
Log.Message("Line " + counter +": " + lineToBeRead);
}
}
counter++;
}
file.Close();

7 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Do you have the JScript code pre-conversion that you can share? It is interesting that, if you really didn't change that much, that the performance would take that much of a hit.

    I noticed you're using the Scripting.FileSystemObject.  Not that this is the cause, but you can achieve much of the same functionality using the objects built into TestComplete of aqFile and aqFileSystem. Rather than using external objects, you might get better performance using something "native" to TC. 

    • Blake_Bryce's avatar
      Blake_Bryce
      Occasional Contributor

      I have tried using both methods - aqFile and the above. The performance is atrocious.

      Here is our Jscript code - 
      var pathToTXT = ProjectSuite.Variables.FCINSTALLPATH+"\\Setup\\__createdb.log";
      var logMethod = "Warning";
      if(!aqFile.Exists(pathToTXT))
      {
      Log.Error(pathToTXT+" does not exist.");
      return;
      }
      else
      var openTXT = aqFile.OpenTextFile(pathToTXT, aqFile.faReadWrite, aqFile.ctANSI); //open createdb text file

      var lineToBeRead;
      var compare;
      var secureRole;
      var counter = 0;
      openTXT.Cursor = 0;
      while(!openTXT.IsEndOfFile())
      {
      lineToBeRead = openTXT.ReadLine();
      compare = lineToBeRead.search("ORA-");
      if(compare > -1)
      {
      secureRole = lineToBeRead.search("28405");
      if(secureRole == -1) //This will ignore thie specific errror
      {
      if(logMethod == "Errors" || logMethod == "errors")
      Log.Error("Line " + counter +": " + lineToBeRead);
      if(logMethod == "Warnings" || logMethod == "warnings")
      Log.Warning("Line " + counter +": " + lineToBeRead);
      }
      else
      {
      Log.Message("Line " + counter +": " + lineToBeRead);
      }
      }
      counter++;
      }
      openTXT.Close();

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Hrm.... yep, looks pretty much like the same code so, technically speaking, there's nothing code-wise that would account for the performance hit.  

        This seems to be a problem with the TC engine. Just to check, there has been no other environment changes between the two versions of the code?  I'm assuming that the conversion is due to you changing from TC 11 to TC 12. Are you running on the same machine as you were before? There are no other processes running on the machine that could impact JavaScript performance?

        If all this stuff checks out... best thing I can suggest is to open a support ticket with the SmartBear folks.