Scott2B
Scott2B

Reputation: 59

Google Apps Script Rhino vs V8 Performance (343ms v 45,042ms)

I created a google apps script deployed as a web app executed as "user_deploying" and accessible by "anyone_anonymos". Executing this with Rhino takes 343ms and executing this with V8 takes 45,042ms, as calculated at the Marks in the below code. Why the difference and how can I increase the performance of V8, specifically Mark II?

Execution time averages in ms (rhino/V8):

the code:

// GET SCENARIO LIST
function getScenarioQuickList() {

  var start = new Date().getTime();

  var conn = Jdbc.getCloudSqlConnection('jdbc:google:mysql://...', user, userPwd);

  var query = 'SELECT a.`lvl`, a.`pubShort`, a.`scenTitle`, a.`pdfLink`';
    query += 'FROM `SA` a WHERE a.`scenId` <> "ZZZ99998" AND a.`scenId` <> "ZZZ99999" ORDER BY a.`scenId`;';
      
  var stmt = conn.prepareStatement(query);
  
  var results = stmt.executeQuery();
  
  var scenList = [];

  console.log(new Date().getTime()-start);  // mark 1
  
  // Push results to array

  start = new Date().getTime();

  while (results.next()) {
    scenList.push({
      'lvl': results.getString(1),
      'pubShort': results.getString(2),
      'scenTitle': results.getString(3),
      'pdfLink': results.getString(4),
    }); // close push
  } // close while
  
  console.log(new Date().getTime()-start); // mark 2

  start = new Date().getTime();

  results.close();
  stmt.close();
  conn.close();
  
  console.log(new Date().getTime()-start); // mark 3

  return scenList;

}

Upvotes: 2

Views: 384

Answers (1)

Iamblichus
Iamblichus

Reputation: 19339

This might be a bug:

I have been able to reproduce this behavior for methods corresponding to JdbcResultSet, especially when iterating through decent-sized results. The execution times in V8 are in many cases be much higher than in Rhino.

Interestingly, this seems to be intermittent, as sometimes the performance is similar.

Reported in Issue Tracker:

Taking all this into account, I have gone ahead and reported this behavior in Issue Tracker:

Anyone affected by this, please consider subscribing to this issue by starring it in order to keep track of this and to help prioritizing it.

Upvotes: 1

Related Questions