cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div class="box" id='stim'></div>
<div id="message"></div>
            
          
!
            
              .box {
  width:100px;
  height:100px;
  background:red;
  margin-right:10px;
  display:inline-block;
}




            
          
!
            
              var stim = $('#stim')


var timings = {
  start_dur: [],
  end_dur: []
}

var stim_duration = 6 // frames. approx 100ms 

var iterations = 100

let loop = ()=> {
  let init_time = performance.now()
  let start_time, end_time
  var tl = tl || new TimelineLite({useFrames:true})
  tl.set(stim, {css:{'visibility':'hidden'}})
  tl.to($("#stim"), stim_duration, {css:{'visibility':'visible'}, 
                        onStart:() =>{
                            start_time = performance.now()
                        }, 
                        onComplete:() =>{
                          end_time = performance.now()
                          timings['start_dur'].push( start_time - init_time)
                          timings['end_dur'].push(end_time - start_time)
                          console.log(iterations)  
                          iterations--
                          tl.kill()
                          if(iterations>0) loop()
                          else summarise()
                          
                        }
                       }, 0);
}

loop()

                    console.log(timings)
function info(txt){
  $("#message").append("<br>"+txt)
}


var stats = ( function () {
    var api = {}

    api.two_stderr = function(data){
        var count = data.length;
        if(count.length<2) return 0;
        var stdev = api.stdev(data);

        return 2 * stdev / Math.sqrt(count);
    }

    api.mean = function(data){
        var total = 0;
        for(var i=0;i<data.length;i++){
            total += parseFloat(data[i]);
        }
        return total / data.length;
    };

    api.sum = function(data){
        var total = 0;
        for(var i = 0;i<data.length;i++){
            total+=data[i];
        }
        return total;
    }

    api.stdev = function(data){
        if(data.length<2) return 0;
        var avg = api.mean(data);

        var squareDiffs = data.map(function(value){
            var diff = value - avg;
            var sqrDiff = diff * diff;
            return sqrDiff;
        });

        var total = api.sum(squareDiffs);

        return Math.sqrt(total / (data.length-1))

    }

    return api
}());


info(['stat_descriptor', 'av', 'stdev', 'min', 'max'].join('&emsp;&emsp;'))

function summarise(){

  for(let stat_descriptor in timings){
    var list = timings[stat_descriptor]
    var stat_descriptions = [stat_descriptor, 
                             stats.mean(list),
                             stats.stdev(list),
                             Math.min(...list),
                             Math.max(...list)
                            ]
    info(stat_descriptions.join('&emsp;&emsp;'))
  }
}
            
          
!
999px
Loading ..................

Console