[OpenLayers-Dev] Re: lib evaluation performance

Eric Lemoine eric.lemoine at camptocamp.com
Wed Nov 3 11:51:18 EDT 2010


> Hi Eric Lemoine,
>
> For other reasons I am also testing the performance of the initialization.
> To stabilize a little the sample, I remove the extraneous peaks with this
> code:
>
>        function showAvg(testName,times) {
>            function staValues(t) {
>                var s = 0, v=0;
>                for(var i=0, l=t.length; i<l; i++) {
>                    s += t[i];
>                    v += t[i]*t[i];
>                }
>                var ev ={};
>                ev.avg = (s/l);
>                // Normalized standard deviation
>                ev.nsd = Math.sqrt((v/l)-(ev.avg*ev.avg))/ev.avg;
>                ev.l = l;
>                return ev;
>            }
>            var t = times.slice(0);
>            t = t.sort(function (a,b){return a - b;}); // sort ascending
>            var ev;
>            while (true) {
>                ev = staValues(t);
>                if (ev.avg == 0 ||    // break if all values are 0
>                    ev.nsd <= 0.5 ||   // clean up of the normalized
> standard deviation is less than 0.5
>                    ev.l <= times.length * 2/3 // remove 1/3 of the sample
> maximum.
>                    ) {
>                    break;
>                }
>                console.log(testName+";", ev.avg.toFixed(1), "; max;",
> t[ev.l-1], "; nsd;", ev.nsd.toFixed(3), "; sample;", ev.l); // to monitor
> cleaning
>                t.pop(); // remove the anomalous peak produced by the
> garbage collect or other
>                t.shift(); // remove the minimum to balance the sample
>            }
>            console.log(testName+":", ev.avg.toFixed(1));
>        }
>
> used by:
>
>       showAvg("Old-style class",timesArray);
>

Nice. I'm happy to see new experiment results.

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com


More information about the Dev mailing list