tests/benchmarks/uimodels/GraphicsViewBenchmark/testautom/testscript.js
changeset 3 41300fa6a67c
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     5 **
       
     6 ** This file is part of the examples of the Qt Toolkit.
       
     7 **
       
     8 ** $QT_BEGIN_LICENSE:LGPL$
       
     9 ** No Commercial Usage
       
    10 ** This file contains pre-release code and may not be distributed.
       
    11 ** You may use this file in accordance with the terms and conditions
       
    12 ** contained in the either Technology Preview License Agreement or the
       
    13 ** Beta Release License Agreement.
       
    14 **
       
    15 ** GNU Lesser General Public License Usage
       
    16 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    17 ** General Public License version 2.1 as published by the Free Software
       
    18 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    19 ** packaging of this file.  Please review the following information to
       
    20 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    21 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    22 **
       
    23 ** In addition, as a special exception, Nokia gives you certain
       
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
       
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
       
    26 ** package.
       
    27 **
       
    28 ** GNU General Public License Usage
       
    29 ** Alternatively, this file may be used under the terms of the GNU
       
    30 ** General Public License version 3.0 as published by the Free Software
       
    31 ** Foundation and appearing in the file LICENSE.GPL included in the
       
    32 ** packaging of this file.  Please review the following information to
       
    33 ** ensure the GNU General Public License version 3.0 requirements will be
       
    34 ** met: http://www.gnu.org/copyleft/gpl.html.
       
    35 **
       
    36 ** If you are unsure which license is appropriate for your use, please
       
    37 ** contact the sales department at http://qt.nokia.com/contact.
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 // List types to test.
       
    43 var listTypeSimple = 0;
       
    44 var listTypeRecycling = 1;
       
    45 
       
    46 function Tests(tester)
       
    47 {
       
    48     this.tester = tester;
       
    49 
       
    50     //Execute tests.
       
    51     this.tests1();
       
    52 
       
    53     //Calculate the metrics from the measured results for test1
       
    54     this.metrics1();
       
    55 
       
    56     //this.tests_rotation();
       
    57     // ADD ANY NEW TEST CASES AND METRICS BELOW THIS
       
    58 }
       
    59 
       
    60 /*
       
    61   ===================
       
    62   VERY IMPORTANT NOTE
       
    63   ===================
       
    64 
       
    65   THIS SCRIPT MUST ***NEVER*** BE CHANGED/REPLACED WHEN
       
    66   RUNNING AUTOMATED PERFORMACE TESTS INTENDED FOR TREND
       
    67   TRACKING.
       
    68 
       
    69   TO ADD NEW TEST CASES, CREATE NEW TEST FUNCTIONS RUN
       
    70   AFTER THESE ONES
       
    71 */
       
    72 Tests.prototype.tests1 = function() {
       
    73 
       
    74     var slowSpeed = 2
       
    75     var normalSpeed = 8
       
    76     var fastSpeed = 64
       
    77 
       
    78     var maxScrollTime = 11000;
       
    79     var maxUpdateTime = 11000;
       
    80     var addAndRemoveItemsCount = 100;
       
    81 
       
    82     // Sizes of list that test are run.
       
    83     // We repeat small list again
       
    84     var sizes= new Array();
       
    85     sizes[0] = 50; // Small number of data/items
       
    86     sizes[1] = 500; // Large number of data/items
       
    87     sizes[2] = 50; // Small number of data/items again for regression
       
    88 
       
    89     var themeCount = this.tester.themeCount()-1;
       
    90 
       
    91     var logger = this.tester.resultLogger();
       
    92 
       
    93     var fillListResult = logger.createTestFunctionResult("fillListTest");
       
    94     var addToBeginningResult = logger.createTestFunctionResult("addToBeginningOfListTest");
       
    95     var removeFromResult = logger.createTestFunctionResult("removeFromBeginningOfListTest");
       
    96     var deleteListResult = logger.createTestFunctionResult("deleteListTest");
       
    97     var renderListResult = logger.createTestFunctionResult("renderListTest");
       
    98     var themeChangeResult = logger.createTestFunctionResult("themeChangeTest");
       
    99 
       
   100     var originalThemeId = this.tester.currentThemeId();
       
   101 
       
   102     //Empty additional tag
       
   103     var regression = "";
       
   104 
       
   105     // Test all list sizes.    
       
   106     for (var listSize = 0; listSize<sizes.length; listSize=listSize+1) {
       
   107 
       
   108     //If second 50 item list is being tested, append Regression string to the test tag.
       
   109     if(listSize == 2)
       
   110         {
       
   111         regression += String(" Regression");
       
   112         }
       
   113         
       
   114         // Test all list types
       
   115         for (var listType = listTypeSimple; listType<=listTypeRecycling; listType=listType+1) {
       
   116 
       
   117             this.tester.fillListTest(sizes[listSize], listType, fillListResult, "Fill List" + regression);
       
   118 
       
   119             this.tester.addToBeginningOfListTest(addAndRemoveItemsCount, addToBeginningResult, "Add items to beginning of list." + regression);
       
   120 
       
   121             this.tester.removeFromBeginningOfListTest(addAndRemoveItemsCount, removeFromResult, "Remove items from begining of list." + regression);
       
   122 
       
   123             // Test all themes - Blue=Simple, Lime=Complex
       
   124             for (var themeId = 0; themeId<=themeCount; themeId=themeId+1) {
       
   125                 this.tester.setTheme(themeId);
       
   126 
       
   127                 // 12 CORE SCROLL TESTS (per theme, per algorithm)
       
   128 
       
   129                 // Render to screen, Uncached, 3 scroll speed + forced update
       
   130                 this.tester.setImageBasedRendering(false);
       
   131                 this.tester.setSubtreeCache(false);
       
   132                 this.tester.setScrollStep(slowSpeed);
       
   133                 this.tester.scrollListTest(maxScrollTime, renderListResult, "Scroll Slow" + regression);
       
   134                 this.tester.setScrollStep(normalSpeed);
       
   135                 this.tester.scrollListTest(maxScrollTime, renderListResult, "Scroll Normal" + regression);
       
   136                 this.tester.setScrollStep(fastSpeed);
       
   137                 this.tester.scrollListTest(maxScrollTime, renderListResult, "Scroll Fast" + regression);
       
   138                 this.tester.forceUpdateTest(maxUpdateTime, renderListResult, "Force Update" + regression);
       
   139 
       
   140                 // Render to screen, Cached, 3 scroll speeds + forced udpate
       
   141                 this.tester.setImageBasedRendering(false);
       
   142                 this.tester.setSubtreeCache(true);
       
   143                 this.tester.setScrollStep(slowSpeed);
       
   144                 this.tester.scrollListTest(maxScrollTime, renderListResult, "Scroll Slow" + regression);
       
   145                 this.tester.setScrollStep(normalSpeed);
       
   146                 this.tester.scrollListTest(maxScrollTime, renderListResult, "Scroll Normal" + regression);
       
   147                 this.tester.setScrollStep(fastSpeed);
       
   148                 this.tester.scrollListTest(maxScrollTime, renderListResult, "Scroll Fast" + regression);
       
   149                 this.tester.forceUpdateTest(maxUpdateTime, renderListResult, "Force Update" + regression);
       
   150 
       
   151                 // Render to screen rotated 90degrees, Uncached+Cached, Medium scroll speed
       
   152                 this.tester.setImageBasedRendering(false);
       
   153                 this.tester.setTwoColumns(true); // Same amount items on screen that it's in portrait mode
       
   154                 this.tester.rotateMainWindow(90);
       
   155                 this.tester.setScrollStep(normalSpeed);
       
   156                 this.tester.setSubtreeCache(false);
       
   157                 this.tester.scrollListTest(maxScrollTime, renderListResult, "Scroll Normal Rotated" + regression);
       
   158                 this.tester.setSubtreeCache(true);
       
   159                 this.tester.scrollListTest(maxScrollTime, renderListResult, "Scroll Normal Rotated" + regression);
       
   160                 this.tester.rotateMainWindow(-90); // REVERT rotation
       
   161                 this.tester.setTwoColumns(false); // Reduce rows when moving back to portrait mode
       
   162 
       
   163                 // Render to pixmap, Uncached+Cached, Medium scroll speed
       
   164                 this.tester.setImageBasedRendering(true);
       
   165                 this.tester.setScrollStep(normalSpeed);
       
   166                 this.tester.setSubtreeCache(false);
       
   167                 this.tester.scrollListTest(maxScrollTime, renderListResult, "Scroll Normal" + regression);
       
   168                 this.tester.setSubtreeCache(true);
       
   169                 this.tester.scrollListTest(maxScrollTime, renderListResult, "Scroll Normal" + regression);
       
   170             }
       
   171 
       
   172             this.tester.setTheme(originalThemeId);
       
   173 
       
   174             // These test are run only with different list sizes and types.
       
   175             for (var tId = themeCount; tId>=0; tId=tId-1) {
       
   176                 var tag ="Change theme. From " + this.tester.currentThemeName() + " to " + this.tester.themeName(tId);
       
   177                 this.tester.themeChangeTest(tId, themeChangeResult, tag + regression);
       
   178             }
       
   179 
       
   180             this.tester.setTheme(originalThemeId);
       
   181 
       
   182             this.tester.deleteListTest(deleteListResult, "Delete list." + regression);
       
   183         }
       
   184     }
       
   185 };
       
   186 
       
   187 String.prototype.startsWith = function(str) {
       
   188     return (this.match("^"+str)==str);
       
   189 }
       
   190 
       
   191 Tests.prototype.metrics1 = function() {
       
   192 
       
   193     var addAndRemoveItemsCount = 100; // Should be same as above
       
   194 
       
   195     var resultset,i,result,target,points,metricmax,pixelcount;
       
   196     var logger = this.tester.resultLogger();
       
   197 
       
   198     var metric1 = logger.createTestFunctionResult("GraphicsView.PerformanceMetrics.1");
       
   199     // Later metrics added should use PerformanceMetrics.2, etc.
       
   200 
       
   201     //print(startupresult.benchmarks().at(0));
       
   202 
       
   203     // The metrics computed below are meant to synthesise
       
   204     // a single number from a set of related tests
       
   205     // The idea is that improvements in those areas should
       
   206     // show a boost in the relevant metric
       
   207     // Larger result is always better
       
   208     // 100 is target value but can be exceeded
       
   209     metricmax = 100.0;
       
   210     points = 0.0; // Add one for each data point to scale later
       
   211 
       
   212     response = metric1.createBenchmark();
       
   213     response.setTag("Response");
       
   214     var accum = 0.0;
       
   215     var tag;
       
   216 
       
   217     // Get the startup result
       
   218     // This only applies AFTER the main was called
       
   219     // Target of 100 milliseconds
       
   220     // If we meet them then this will contribute 1.0
       
   221     // Faster will be higher than one
       
   222     target = 100.0; // ms
       
   223     resultset = logger.getTestFunctionResult("Startup").benchmarks();
       
   224     //print("Startup count:",resultset.count());
       
   225     result = resultset.at(0);
       
   226     accum += target/(result.value()+0.00000001); // +0.0000001 to make sure we never divide by zero
       
   227     points += 1.0;
       
   228     //print(accum);
       
   229 
       
   230     // Target is 10ms setup + 0.25ms per item for all list types
       
   231     resultset = logger.getTestFunctionResult("fillListTest").benchmarks();
       
   232     i = 0;
       
   233     target = 0.25;
       
   234     for (;i<resultset.count();i++) {
       
   235         result = resultset.at(i);
       
   236         tag = result.tag();
       
   237         if (tag.startsWith("CPU")) continue;
       
   238         if (tag.startsWith("Memory")) continue;
       
   239         //print(tag,"fill: "+result.value(),result.listSize());
       
   240         accum += ((10.0 + (target*result.listSize()))/result.value());
       
   241         //print(accum);
       
   242         points += 1.0;
       
   243     }
       
   244 
       
   245     // Target is 50ms for 640x360 screen
       
   246     resultset = logger.getTestFunctionResult("themeChangeTest").benchmarks();
       
   247     i = 0;
       
   248     target = (640.0*360.0)/50.0; // target is per-pixel
       
   249     for (;i<resultset.count();i++) {
       
   250         result = resultset.at(i);
       
   251         tag = result.tag();
       
   252         if (tag.startsWith("CPU")) continue;
       
   253         if (tag.startsWith("Memory")) continue;
       
   254         pixelcount = result.width()*result.height();
       
   255         //print(tag,result.value(),((target*pixelcount)/result.value()));
       
   256         accum += ((target*pixelcount)/result.value());
       
   257         //print(accum);
       
   258         points += 1.0;
       
   259     }
       
   260 
       
   261     // addAndRemoveItemsCount items, target is 0.25ms per item
       
   262     resultset = logger.getTestFunctionResult("addToBeginningOfListTest").benchmarks();
       
   263     i = 0;
       
   264     target = 0.25*addAndRemoveItemsCount;
       
   265     for (;i<resultset.count();i++) {
       
   266         result = resultset.at(i);
       
   267         tag = result.tag();
       
   268         if (tag.startsWith("CPU")) continue;
       
   269         if (tag.startsWith("Memory")) continue;
       
   270         //print(tag,"add: "+result.value(),result.listSize(),result);
       
   271         accum += ((target)/result.value());
       
   272         //print(accum);
       
   273         points += 1.0;
       
   274     }
       
   275 
       
   276     // addAndRemoveItemsCount items, target is 0.25ms per item
       
   277     resultset = logger.getTestFunctionResult("removeFromBeginningOfListTest").benchmarks();
       
   278     i = 0;
       
   279     target = 0.25*addAndRemoveItemsCount;
       
   280     for (;i<resultset.count();i++) {
       
   281         result = resultset.at(i);
       
   282         tag = result.tag();
       
   283         if (tag.startsWith("CPU")) continue;
       
   284         if (tag.startsWith("Memory")) continue;
       
   285         //print(tag,"remove: "+result.value(),result.listSize(),result);
       
   286         accum += ((target)/result.value());
       
   287         //print(accum);
       
   288         points += 1.0;
       
   289     }
       
   290 
       
   291     // Target is 10ms general tear down + 0.1ms per item for all list types
       
   292     resultset = logger.getTestFunctionResult("deleteListTest").benchmarks();
       
   293     i = 0;
       
   294     target = 0.1;
       
   295     for (;i<resultset.count();i++) {
       
   296         result = resultset.at(i);
       
   297         tag = result.tag();
       
   298         if (tag.startsWith("CPU")) continue;
       
   299         if (tag.startsWith("Memory")) continue;
       
   300         //print(tag,"delete: "+result.value(),result.listSize());
       
   301         accum += ((10.0+(target*result.listSize()))/result.value());
       
   302         //print(accum);
       
   303         points += 1.0;
       
   304     }
       
   305 
       
   306     accum *= metricmax / points;
       
   307     //print(accum);
       
   308     response.setValue(accum);
       
   309 
       
   310     resourceusage = metric1.createBenchmark()
       
   311     resourceusage.setTag("ResourceUsage");
       
   312     resourceusage.setValue("0.5");
       
   313 
       
   314     rendering = metric1.createBenchmark();
       
   315     rendering.setTag("Rendering");
       
   316     points = 0.0; // Add one for each data point to scale later
       
   317     accum = 0.0;
       
   318     // Target is 60FPS in all cases
       
   319     resultset = logger.getTestFunctionResult("renderListTest").benchmarks();
       
   320     i = 0;
       
   321     target = 60.0;
       
   322     for (;i<resultset.count();i++) {
       
   323         result = resultset.at(i);
       
   324         tag = result.tag();
       
   325         if (tag.startsWith("CPU")) continue;
       
   326         if (tag.startsWith("Memory")) continue;
       
   327         //print("r: "+result.value(),result.value()/target);
       
   328         //print(result.benchmarkStr());
       
   329         accum += result.value()/target;
       
   330         //print(accum);
       
   331         points += 1.0;
       
   332     }
       
   333     if (points>0.0) {
       
   334         accum *= metricmax / points;
       
   335     }
       
   336     //print("Final render:",accum);
       
   337     rendering.setValue(accum);
       
   338 
       
   339     datascaling = metric1.createBenchmark()
       
   340     datascaling.setTag("DataScaling");
       
   341     datascaling.setValue("0.5");
       
   342 
       
   343     smoothness = metric1.createBenchmark()
       
   344     smoothness.setTag("Smoothness");
       
   345     smoothness.setValue("0.5");
       
   346 }
       
   347 
       
   348 Tests.prototype.tests_rotation = function() {
       
   349 
       
   350     var maxScrollTime = 11000;
       
   351 
       
   352     var logger = this.tester.resultLogger();
       
   353 
       
   354     var fillListResult = logger.createTestFunctionResult("Rotate. fillListTest");
       
   355     var scrollListResult = logger.createTestFunctionResult("Rotate. scrollListTest");
       
   356     var deleteListResult = logger.createTestFunctionResult("Rotate. deleteListTest");
       
   357     this.tester.setSubtreeCache(false);
       
   358     this.tester.setImageBasedRendering(false);
       
   359 
       
   360     for (var listType = listTypeSimple; listType<=listTypeRecycling; listType=listType+1) {
       
   361         this.tester.fillListTest(200, listType, fillListResult, "Creating and filling list.");
       
   362         this.tester.scrollListTest(maxScrollTime, scrollListResult, "Scroll list.");
       
   363         this.tester.rotateMainWindow(90);
       
   364         this.tester.setTwoColumns(true); // Same amount items on screen that it's in portrait mode
       
   365         this.tester.scrollListTest(maxScrollTime, scrollListResult, "Scroll rotated list.");
       
   366         this.tester.deleteListTest(deleteListResult, "Delete list.");
       
   367         this.tester.rotateMainWindow(-90);
       
   368         this.tester.setTwoColumns(false); // Reduce rows when moving back to portrait mode
       
   369     }
       
   370 }
       
   371