Changeset 166462 in webkit


Ignore:
Timestamp:
Mar 30, 2014 9:53:53 AM (10 years ago)
Author:
mark.lam@apple.com
Message:

LongSpider 3d-morph result check is inappropriate.
<https://webkit.org/b/130928>

Reviewed by Filip Pizlo.

The LongSpider 3d-morph component expected result check is incorrect.
The existing test checks if the leading digit of a sum starts with "-1".
However, it turned out that the expected sum is in the order of
-1.8735013540549517e-16 (i.e. very close to 0). With small errors in
the terms of the sum adding up, it is very easy for the resultant sum
to fluctuate. There is no guarantee that the resultant sum's most
significant digit will start with -1 either.

The fix is to do a tolerance check on all the terms of the sum as well
as the total sum value instead. The tolerance should be more lenient
for the sum which accumulates error from the individual terms, then for
individual terms.

  • LongSpider/3d-morph.js:

(expect):

Location:
trunk/PerformanceTests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/PerformanceTests/ChangeLog

    r166416 r166462  
     12014-03-29  Mark Lam  <mark.lam@apple.com>
     2
     3        LongSpider 3d-morph result check is inappropriate.
     4        <https://webkit.org/b/130928>
     5
     6        Reviewed by Filip Pizlo.
     7
     8        The LongSpider 3d-morph component expected result check is incorrect.
     9        The existing test checks if the leading digit of a sum starts with "-1".
     10        However, it turned out that the expected sum is in the order of
     11        -1.8735013540549517e-16 (i.e. very close to 0).  With small errors in
     12        the terms of the sum adding up, it is very easy for the resultant sum
     13        to fluctuate.  There is no guarantee that the resultant sum's most
     14        significant digit will start with -1 either.
     15
     16        The fix is to do a tolerance check on all the terms of the sum as well
     17        as the total sum value instead.  The tolerance should be more lenient
     18        for the sum which accumulates error from the individual terms, then for
     19        individual terms.
     20
     21        * LongSpider/3d-morph.js:
     22        (expect):
     23
    1242014-03-28  Zoltan Horvath  <zoltan@webkit.org>
    225
  • trunk/PerformanceTests/LongSpider/3d-morph.js

    r165676 r166462  
    4949}
    5050
    51 testOutput = 0;
    52 for (var i = 0; i < nx; i++)
    53     testOutput += a[3*(i*nx+i)+1];
    54 a = null;
    55 
    5651// This has to be an approximate test since ECMAscript doesn't formally specify
    5752// what sin() returns. Even if it did specify something like for example what Java 7
     
    5954// would not be able to do an exact test here since that would allow for just enough
    6055// low-bit slop to create possibly big errors due to testOutput being a sum.
    61 var expected = "-1";
    62 if (("" + testOutput).indexOf(expected) != 0)
    63     throw "Error: bad test output: expected leading digit to be " + expected + " but got " + testOutput;
     56
     57var expectedResults = [
     58    { value: 0.018662099703860055, total: 0.018662099703860055 }, // 0
     59    { value: 0, total: 0.018662099703860055 }, // 1
     60    { value: -0.018662099703860055, total: 0 }, // 2
     61    { value: -0.03650857609997156, total: -0.03650857609997156 }, // 3
     62    { value: -0.05275945253292943, total: -0.08926802863290098 }, // 4
     63    { value: -0.06670448772225647, total: -0.15597251635515746 }, // 5
     64    { value: -0.07773421671447613, total: -0.23370673306963358 }, // 6
     65    { value: -0.08536658742611654, total: -0.3190733204957501 }, // 7
     66    { value: -0.08926802863290098, total: -0.40834134912865105 }, // 8
     67    { value: -0.089268028632901, total: -0.49760937776155206 }, // 9
     68    { value: -0.08536658742611655, total: -0.5829759651876686 }, // 10
     69    { value: -0.07773421671447614, total: -0.6607101819021447 }, // 11
     70    { value: -0.06670448772225651, total: -0.7274146696244013 }, // 12
     71    { value: -0.052759452532929435, total: -0.7801741221573307 }, // 13
     72    { value: -0.03650857609997158, total: -0.8166826982573023 }, // 14
     73    { value: -0.018662099703860093, total: -0.8353447979611625 }, // 15
     74    { value: -1.0992398059873222e-17, total: -0.8353447979611625 }, // 16
     75    { value: 0.018662099703860034, total: -0.8166826982573024 }, // 17
     76    { value: 0.036508576099971525, total: -0.780174122157331 }, // 18
     77    { value: 0.052759452532929414, total: -0.7274146696244015 }, // 19
     78    { value: 0.06670448772225647, total: -0.660710181902145 }, // 20
     79    { value: 0.0777342167144761, total: -0.5829759651876689 }, // 21
     80    { value: 0.08536658742611654, total: -0.4976093777615524 }, // 22
     81    { value: 0.08926802863290098, total: -0.4083413491286514 }, // 23
     82    { value: 0.089268028632901, total: -0.3190733204957504 }, // 24
     83    { value: 0.08536658742611655, total: -0.23370673306963383 }, // 25
     84    { value: 0.07773421671447615, total: -0.1559725163551577 }, // 26
     85    { value: 0.06670448772225653, total: -0.08926802863290116 }, // 27
     86    { value: 0.052759452532929435, total: -0.036508576099971726 }, // 28
     87    { value: 0.03650857609997163, total: -9.71445146547012e-17 }, // 29
     88    { value: 0.018662099703860107, total: 0.01866209970386001 }, // 30
     89    { value: 2.1984796119746444e-17, total: 0.01866209970386003 }, // 31
     90    { value: -0.018662099703859986, total: 4.5102810375396984e-17 }, // 32
     91    { value: -0.03650857609997152, total: -0.036508576099971476 }, // 33
     92    { value: -0.05275945253292941, total: -0.08926802863290088 }, // 34
     93    { value: -0.06670448772225643, total: -0.1559725163551573 }, // 35
     94    { value: -0.0777342167144761, total: -0.2337067330696334 }, // 36
     95    { value: -0.08536658742611652, total: -0.31907332049574993 }, // 37
     96    { value: -0.08926802863290098, total: -0.40834134912865094 }, // 38
     97    { value: -0.089268028632901, total: -0.49760937776155195 }, // 39
     98    { value: -0.08536658742611655, total: -0.5829759651876685 }, // 40
     99    { value: -0.07773421671447617, total: -0.6607101819021446 }, // 41
     100    { value: -0.06670448772225658, total: -0.7274146696244012 }, // 42
     101    { value: -0.05275945253292945, total: -0.7801741221573306 }, // 43
     102    { value: -0.03650857609997164, total: -0.8166826982573022 }, // 44
     103    { value: -0.018662099703860194, total: -0.8353447979611625 }, // 45
     104    { value: -3.2977194179619666e-17, total: -0.8353447979611625 }, // 46
     105    { value: 0.018662099703859975, total: -0.8166826982573024 }, // 47
     106    { value: 0.036508576099971435, total: -0.7801741221573311 }, // 48
     107    { value: 0.0527594525329294, total: -0.7274146696244017 }, // 49
     108    { value: 0.06670448772225643, total: -0.6607101819021453 }, // 50
     109    { value: 0.07773421671447606, total: -0.5829759651876691 }, // 51
     110    { value: 0.08536658742611652, total: -0.4976093777615526 }, // 52
     111    { value: 0.08926802863290097, total: -0.40834134912865167 }, // 53
     112    { value: 0.08926802863290101, total: -0.31907332049575066 }, // 54
     113    { value: 0.08536658742611655, total: -0.2337067330696341 }, // 55
     114    { value: 0.07773421671447617, total: -0.15597251635515794 }, // 56
     115    { value: 0.06670448772225658, total: -0.08926802863290136 }, // 57
     116    { value: 0.052759452532929456, total: -0.0365085760999719 }, // 58
     117    { value: 0.03650857609997165, total: -2.498001805406602e-16 }, // 59
     118    { value: 0.018662099703860208, total: 0.018662099703859958 }, // 60
     119    { value: 4.396959223949289e-17, total: 0.018662099703860003 }, // 61
     120    { value: -0.01866209970385996, total: 4.163336342344337e-17 }, // 62
     121    { value: -0.03650857609997142, total: -0.03650857609997138 }, // 63
     122    { value: -0.0527594525329294, total: -0.08926802863290079 }, // 64
     123    { value: -0.06670448772225641, total: -0.1559725163551572 }, // 65
     124    { value: -0.07773421671447604, total: -0.23370673306963324 }, // 66
     125    { value: -0.08536658742611652, total: -0.31907332049574977 }, // 67
     126    { value: -0.08926802863290097, total: -0.4083413491286507 }, // 68
     127    { value: -0.08926802863290101, total: -0.49760937776155173 }, // 69
     128    { value: -0.08536658742611655, total: -0.5829759651876683 }, // 70
     129    { value: -0.07773421671447618, total: -0.6607101819021445 }, // 71
     130    { value: -0.06670448772225658, total: -0.727414669624401 }, // 72
     131    { value: -0.05275945253292948, total: -0.7801741221573305 }, // 73
     132    { value: -0.036508576099971664, total: -0.8166826982573022 }, // 74
     133    { value: -0.018662099703860215, total: -0.8353447979611625 }, // 75
     134    { value: -5.496199029936611e-17, total: -0.8353447979611625 }, // 76
     135    { value: 0.01866209970385995, total: -0.8166826982573026 }, // 77
     136    { value: 0.036508576099971414, total: -0.7801741221573312 }, // 78
     137    { value: 0.05275945253292938, total: -0.7274146696244018 }, // 79
     138    { value: 0.0667044877222563, total: -0.6607101819021455 }, // 80
     139    { value: 0.07773421671447604, total: -0.5829759651876695 }, // 81
     140    { value: 0.08536658742611652, total: -0.49760937776155295 }, // 82
     141    { value: 0.08926802863290097, total: -0.408341349128652 }, // 83
     142    { value: 0.08926802863290101, total: -0.319073320495751 }, // 84
     143    { value: 0.08536658742611655, total: -0.23370673306963444 }, // 85
     144    { value: 0.07773421671447626, total: -0.1559725163551582 }, // 86
     145    { value: 0.0667044877222566, total: -0.08926802863290159 }, // 87
     146    { value: 0.05275945253292948, total: -0.036508576099972115 }, // 88
     147    { value: 0.036508576099971816, total: -2.983724378680108e-16 }, // 89
     148    { value: 0.018662099703860225, total: 0.018662099703859927 }, // 90
     149    { value: 6.595438835923933e-17, total: 0.018662099703859993 }, // 91
     150    { value: -0.018662099703859788, total: 2.0469737016526324e-16 }, // 92
     151    { value: -0.0365085760999714, total: -0.0365085760999712 }, // 93
     152    { value: -0.052759452532929366, total: -0.08926802863290056 }, // 94
     153    { value: -0.06670448772225629, total: -0.15597251635515685 }, // 95
     154    { value: -0.07773421671447604, total: -0.2337067330696329 }, // 96
     155    { value: -0.08536658742611652, total: -0.31907332049574944 }, // 97
     156    { value: -0.08926802863290095, total: -0.4083413491286504 }, // 98
     157    { value: -0.08926802863290101, total: -0.4976093777615514 }, // 99
     158    { value: -0.08536658742611657, total: -0.5829759651876679 }, // 100
     159    { value: -0.07773421671447626, total: -0.6607101819021441 }, // 101
     160    { value: -0.06670448772225661, total: -0.7274146696244007 }, // 102
     161    { value: -0.052759452532929484, total: -0.7801741221573302 }, // 103
     162    { value: -0.03650857609997182, total: -0.816682698257302 }, // 104
     163    { value: -0.01866209970386024, total: -0.8353447979611622 }, // 105
     164    { value: -7.694678641911255e-17, total: -0.8353447979611623 }, // 106
     165    { value: 0.018662099703859774, total: -0.8166826982573026 }, // 107
     166    { value: 0.0365085760999714, total: -0.7801741221573312 }, // 108
     167    { value: 0.05275945253292936, total: -0.7274146696244018 }, // 109
     168    { value: 0.06670448772225629, total: -0.6607101819021455 }, // 110
     169    { value: 0.07773421671447603, total: -0.5829759651876695 }, // 111
     170    { value: 0.08536658742611652, total: -0.49760937776155295 }, // 112
     171    { value: 0.08926802863290095, total: -0.408341349128652 }, // 113
     172    { value: 0.08926802863290101, total: -0.319073320495751 }, // 114
     173    { value: 0.08536658742611657, total: -0.2337067330696344 }, // 115
     174    { value: 0.07773421671447626, total: -0.15597251635515813 }, // 116
     175    { value: 0.06670448772225661, total: -0.08926802863290152 }, // 117
     176    { value: 0.0527594525329295, total: -0.036508576099972025 }, // 118
     177    { value: 0.03650857609997184, total: -1.8735013540549517e-16 }, // 119
     178];
     179
     180var valueError = 0.00000000000001;
     181var totalError = 0.0000000000001;
     182
     183function expect(i, value, total) {
     184    var data = expectedResults;
     185    var valueDiff = Math.abs(value - data[i].value);
     186    var totalDiff = Math.abs(total - data[i].total);
     187
     188    var err = null;
     189    if (valueDiff > valueError && totalDiff > totalError)
     190        err = "    [" + i + "] value a:" + value + " e:" + data[i].value + " | d:" + valueDiff + ", total a:" + total + " e:" + data[i].total + " | d: " + totalDiff;
     191    else if (valueDiff > valueError)
     192        err = "    [" + i + "] value a:" + value + " e:" + data[i].value + " | d:" + valueDiff;
     193    else if (totalDiff > totalError)
     194        err = "    [" + i + "] total a:" + total + " e:" + data[i].total + " | d: " + totalDiff;
     195
     196    if (err)
     197        throw err;
     198}
     199
     200testOutput = 0;
     201for (var i = 0; i < nx; i++) {
     202    var value = a[3*(i*nx+i)+1];
     203    testOutput += value;
     204    expect(i, value, testOutput);
     205}
     206a = null;
Note: See TracChangeset for help on using the changeset viewer.