SlideShare ist ein Scribd-Unternehmen logo
1 von 59
Downloaden Sie, um offline zu lesen
• Philip Tellis

•                        .com
• philip@lognormal.com
• @bluesmoon
• geek paranoid speedfreak
• http://bluesmoon.info/




     NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   1
I <3 JavaScript




NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   2
So much that I wore Mustache socks to my wedding




        NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   3
I’m a Speedfreak (the network kind)




NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   4
We measure real user website performance




NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   5
This talk is (mostly) about how we abuse JavaScript to do it




    NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   6
Abusing JavaScript to Measure Web
            Performance

       Philip Tellis / philip@lognormal.com


           NY #WebPerf Meetup / 2012-09-13




NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   7
First, a note about the code




                      Note that in the code that follows,

                                     + new Date

                                    is equivalent to

                           new Date().getTime()




         NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   8
1
                           Latency



NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   9
Arrange the following in order of increasing signal latency over
a fixed distance:
  • Electricity through copper
  • Smoke Signals
  • Light through Fibre
  • Pulsar




       NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   10
1 Blinking Lights


        It takes about 16ms for light to get from SF to NYC
                       (24ms through fibre)

                                          ...




        NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   11
1 Blinking Lights


        It takes about 16ms for light to get from SF to NYC
                       (24ms through fibre)

           Though it takes about 100ms to ping... why?




        NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   11
1 HTTP




         NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   12
So to measure latency, we need to send 1 packet each way, and
                           time it




     NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   13
1   Network latency in JavaScript




      var ts, rtt, img = new Image;
      img.onload=function() { rtt=(+new Date - ts) };
      ts = +new Date;
      img.src="/1x1.gif";




         NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   14
1 Notes


    • 1x1 gif is 35 bytes
    • including HTTP headers, is smaller than a TCP packet
    • Fires onload on all browsers
    • 0 byte image fires onerror
    • which is indistinguishable from network error




          NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   15
2
                TCP handshake



NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   16
2 ACK-ACK-ACK




      NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   17
2 Connection: keep-alive




        NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   18
2   Network latency & TCP handshake in JavaScript
    var t=[], tcp, rtt;
    var ld = function() {
        t.push(+new Date);
        if(t.length > 2) // run 2 times
          done();
        else {
          var img = new Image;
          img.onload = ld;
          img.src="/1x1.gif?" + Math.random()
                               + ’=’ + new Date;
        }
    };
    var done = function() {
       rtt=t[2]-t[1];
       tcp=t[1]-t[0]-rtt;
    };
    ld();
         NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   19
Notice that we’ve ignored DNS lookup time here... how would
                      you measure it?




     NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   20
Network Throughput
                            3
NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   21
3 Measuring Network Throughput



                                   data_length
                                  download_time




        NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   22
Should you fly a 747 or a 737?



       • A 747 seats 400+ passengers
       • A 737 seats about 150
       • Both take about the same time to fly from SFO to BOS
       • A 747 takes longer to load and unload than 3 737s in
           parallel




   The best selling aircraft to date is the 737




                NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   23
3   Network Throughput in JavaScript




    // Assume global object
    // image={ url: ..., size: ... }
    var ts, rtt, bw, img = new Image;
    img.onload=function() {
       rtt=(+new Date - ts);
       bw = image.size*1000/rtt;     // rtt is in ms
    };
    ts = +new Date;
    img.src=image.url;




         NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   24
3 Measuring Network Throughput



       If it were that simple, I wouldn’t be doing this talk.




        NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   25
3 TCP Slow Start




        NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   26
3 Measuring Network Throughput



   So to make the best use of bandwidth, we need resources that fit
                         in a TCP window




         NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   27
3 There is no single size that will tax all available networks




   http://www.yuiblog.com/blog/2010/04/08/analyzing-bandwidth-and-latency/




               NY #WebPerf Meetup / 2012-09-13        Abusing JavaScript to Measure Web Performance   28
3   Network Throughput in JavaScript – Take 2

    // image object is now an array of multiple images
    var i=0;
    var ld = function() {
       if(i>0)
          image[i-1].end = +new Date;
       if(i >= image.length)
          done();
       else {
          var img = new Image;
          img.onload = ld;
          image[i].start = +new Date;
          img.src=image[i].url;
       }
       i++;
    };

         NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   29
3 Measuring Network Throughput



        Slow network connection, meet really huge image




        NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   30
3   Network Throughput in JavaScript – Take 3




       var img = new Image;
       img.onload = ld;
       image[i].start = +new Date;
       image[i].timer =
             setTimeout(function() {
                            image[i].expired=true
                        },
                        image[i].timeout);
       img.src=image[i].url;




         NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   31
3   Network Throughput in JavaScript – Take 3




    if(i>0) {
       image[i-1].end = +new Date;
       clearTimeout(image[i-1].timer);
    }




         NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   32
3   Network Throughput in JavaScript – Take 3




    if(i >= image.length
          || (i > 0 && image[i-1].expired)) {
       done();
    }




         NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   33
3 Measuring Network Throughput



                                  Are we done yet?




        NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   34
3 Measuring Network Throughput



                                  Are we done yet?
                                      sure...




        NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   34
3 Measuring Network Throughput



    Except network throughput is different every time you test it




        NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   35
Statistics to the Rescue




flickr/sophistechate/4264466015/
                    NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   36
3 Measuring Network Throughput



            The code for that is NOT gonna fit on a slide




        NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   37
But this is sort of what we see world-wide




         NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   38
And it’s different for different countries




   This is India




          NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   39
4     DNS



NY #WebPerf Meetup / 2012-09-13    Abusing JavaScript to Measure Web Performance   40
4 Measuring DNS



                time_with_dns − time_without_dns




       NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   41
4   Measuring DNS in JavaScript
    var t=[], dns, ip, hosts=[’http://hostname.com/’,
                               ’http://ip.ad.dr.ess/’];
    var ld = function() {
        t.push(+new Date);
        if(t.length > hosts.length)
          done();
        else {
          var img = new Image;
          img.onload = ld;
          img.src=hosts[t.length-1] + "/1x1.gif";
        }
    };
    var done = function() {
       ip=t[2]-t[1];
       dns=t[1]-t[0]-ip;
    };
    ld();
         NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   42
4 Measuring DNS


    • What if the IP changes?
    • What if DNS is cached?
    • What if you map DNS based on geo location?




        NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   43
4   Wildcard DNS Entries




                             *.foo.com → IP address




         NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   44
4   Measuring DNS in JavaScript – take 2

    var base_url="http://*.foo.com/",
        timers = {}, gen_url="";

    function start() {
      var random = Math.random().toString(36),
          cache_bust = Math.random(),
          img = new Image();

        gen_url = base_url.replace(/*/, random);

        img.onload = A_loaded;

        timers.start = +new Date;
        img.src = gen_url + "image-l.gif?t=" + cache_bust;
    }

           NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   45
4   Measuring DNS in JavaScript – take 2



    function A_loaded() {
      var cache_bust = Math.random(),
          img = new Image();

        img.onload = B_loaded;

        timers.a_loaded = +new Date;
        img.src = gen_url + "image-l.gif?t=" + cache_bust;
    }


    I’ll let you figure out B_loaded



           NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   46
4 Measuring DNS



                Full code in boomerang’s DNS plugin




       NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   47
5     IPv6



NY #WebPerf Meetup / 2012-09-13    Abusing JavaScript to Measure Web Performance   48
5 Measuring IPv6 support and latency


    1   Try to load image from IPv6 host
          • If timeout or error, then no IPv6 support
          • If successful, then calculate latency and proceed
    2   Try to load image from hostname that resolves only to IPv6
        host
          • If timeout or error, then DNS server doesn’t support IPv6
          • If successful, calculate latency




          NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   49
5 Measuring IPv6 support and latency



                  Full code in boomerang’s IPv6 plugin
                       Note, only run this if you know IPv6 is supported by the client




        NY #WebPerf Meetup / 2012-09-13           Abusing JavaScript to Measure Web Performance   50
6
                       Other Stuff



NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   51
6   Other Stuff We Measure




     • NavTiming – navtiming.js
     • navigation.connection.type – mobile.js
     • window.performance.memory – memory.js –
       Chrome 22 reporting now.
     • Number of DOM nodes and byte size of HTML –
       memory.js




         NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   52
And we try to do it fast




NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   53
–
                            .done()



NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   54
Code/References




    • http://lognormal.github.com/boomerang/doc/
      (BSD Licensed)
    • www.lognormal.com




        NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   55
• Philip Tellis

•                        .com
• philip@lognormal.com
• @bluesmoon
• geek paranoid speedfreak
• http://bluesmoon.info/




     NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   56
Thank you
                   Ask me about a discount code




NY #WebPerf Meetup / 2012-09-13   Abusing JavaScript to Measure Web Performance   57

Weitere ähnliche Inhalte

Ähnlich wie Abusing JavaScript to measure Web Performance, or, "how does boomerang work?"

Abusing JavaScript to Measure Web Performance
Abusing JavaScript to Measure Web PerformanceAbusing JavaScript to Measure Web Performance
Abusing JavaScript to Measure Web PerformancePhilip Tellis
 
Analysing network characteristics with JavaScript
Analysing network characteristics with JavaScriptAnalysing network characteristics with JavaScript
Analysing network characteristics with JavaScriptPhilip Tellis
 
Messing with JavaScript and the DOM to measure network characteristics
Messing with JavaScript and the DOM to measure network characteristicsMessing with JavaScript and the DOM to measure network characteristics
Messing with JavaScript and the DOM to measure network characteristicsPhilip Tellis
 
Web Performance Optimization @Develer
Web Performance Optimization @DevelerWeb Performance Optimization @Develer
Web Performance Optimization @DevelerMassimo Iacolare
 
How's relevant JMeter to me - DevConf (Letterkenny)
How's relevant JMeter to me - DevConf (Letterkenny)How's relevant JMeter to me - DevConf (Letterkenny)
How's relevant JMeter to me - DevConf (Letterkenny)Giulio Vian
 
Monitoring web application response times^lj a hybrid approach for windows
Monitoring web application response times^lj a hybrid approach for windowsMonitoring web application response times^lj a hybrid approach for windows
Monitoring web application response times^lj a hybrid approach for windowsMark Friedman
 
AB Testing, Ads and other 3rd party tags - London WebPerf - March 2018
AB Testing, Ads and other 3rd party tags - London WebPerf - March 2018AB Testing, Ads and other 3rd party tags - London WebPerf - March 2018
AB Testing, Ads and other 3rd party tags - London WebPerf - March 2018Andy Davies
 
Forensic tools for in-depth performance investigations
Forensic tools for in-depth performance investigations Forensic tools for in-depth performance investigations
Forensic tools for in-depth performance investigations SOASTA
 
Forensic Tools for In-Depth Performance Investigations
Forensic Tools for In-Depth Performance InvestigationsForensic Tools for In-Depth Performance Investigations
Forensic Tools for In-Depth Performance InvestigationsNicholas Jansma
 
Mongodb beijingconf yottaa_3.3
Mongodb beijingconf yottaa_3.3Mongodb beijingconf yottaa_3.3
Mongodb beijingconf yottaa_3.3Yottaa
 
Make It Fast - Using Modern Browser Performance APIs to Monitor and Improve t...
Make It Fast - Using Modern Browser Performance APIs to Monitor and Improve t...Make It Fast - Using Modern Browser Performance APIs to Monitor and Improve t...
Make It Fast - Using Modern Browser Performance APIs to Monitor and Improve t...Nicholas Jansma
 
Why is this ASP.NET web app running slowly?
Why is this ASP.NET web app running slowly?Why is this ASP.NET web app running slowly?
Why is this ASP.NET web app running slowly?Mark Friedman
 
Metrics, metrics everywhere (but where the heck do you start?)
Metrics, metrics everywhere (but where the heck do you start?) Metrics, metrics everywhere (but where the heck do you start?)
Metrics, metrics everywhere (but where the heck do you start?) SOASTA
 
Metrics, metrics everywhere (but where the heck do you start?)
Metrics, metrics everywhere (but where the heck do you start?)Metrics, metrics everywhere (but where the heck do you start?)
Metrics, metrics everywhere (but where the heck do you start?)Tammy Everts
 
Velocity NYC: Metrics, metrics everywhere (but where the heck do you start?)
Velocity NYC: Metrics, metrics everywhere (but where the heck do you start?)Velocity NYC: Metrics, metrics everywhere (but where the heck do you start?)
Velocity NYC: Metrics, metrics everywhere (but where the heck do you start?)Cliff Crocker
 
Apache Beam and Google Cloud Dataflow - IDG - final
Apache Beam and Google Cloud Dataflow - IDG - finalApache Beam and Google Cloud Dataflow - IDG - final
Apache Beam and Google Cloud Dataflow - IDG - finalSub Szabolcs Feczak
 

Ähnlich wie Abusing JavaScript to measure Web Performance, or, "how does boomerang work?" (20)

Abusing JavaScript to Measure Web Performance
Abusing JavaScript to Measure Web PerformanceAbusing JavaScript to Measure Web Performance
Abusing JavaScript to Measure Web Performance
 
Analysing network characteristics with JavaScript
Analysing network characteristics with JavaScriptAnalysing network characteristics with JavaScript
Analysing network characteristics with JavaScript
 
Messing with JavaScript and the DOM to measure network characteristics
Messing with JavaScript and the DOM to measure network characteristicsMessing with JavaScript and the DOM to measure network characteristics
Messing with JavaScript and the DOM to measure network characteristics
 
Web Leaps Forward
Web Leaps ForwardWeb Leaps Forward
Web Leaps Forward
 
Web Performance Optimization @Develer
Web Performance Optimization @DevelerWeb Performance Optimization @Develer
Web Performance Optimization @Develer
 
How's relevant JMeter to me - DevConf (Letterkenny)
How's relevant JMeter to me - DevConf (Letterkenny)How's relevant JMeter to me - DevConf (Letterkenny)
How's relevant JMeter to me - DevConf (Letterkenny)
 
Monitoring web application response times^lj a hybrid approach for windows
Monitoring web application response times^lj a hybrid approach for windowsMonitoring web application response times^lj a hybrid approach for windows
Monitoring web application response times^lj a hybrid approach for windows
 
AB Testing, Ads and other 3rd party tags - London WebPerf - March 2018
AB Testing, Ads and other 3rd party tags - London WebPerf - March 2018AB Testing, Ads and other 3rd party tags - London WebPerf - March 2018
AB Testing, Ads and other 3rd party tags - London WebPerf - March 2018
 
Forensic tools for in-depth performance investigations
Forensic tools for in-depth performance investigations Forensic tools for in-depth performance investigations
Forensic tools for in-depth performance investigations
 
Forensic Tools for In-Depth Performance Investigations
Forensic Tools for In-Depth Performance InvestigationsForensic Tools for In-Depth Performance Investigations
Forensic Tools for In-Depth Performance Investigations
 
Node js
Node jsNode js
Node js
 
Mongodb beijingconf yottaa_3.3
Mongodb beijingconf yottaa_3.3Mongodb beijingconf yottaa_3.3
Mongodb beijingconf yottaa_3.3
 
Make It Fast - Using Modern Browser Performance APIs to Monitor and Improve t...
Make It Fast - Using Modern Browser Performance APIs to Monitor and Improve t...Make It Fast - Using Modern Browser Performance APIs to Monitor and Improve t...
Make It Fast - Using Modern Browser Performance APIs to Monitor and Improve t...
 
Using Embulk at Treasure Data
Using Embulk at Treasure DataUsing Embulk at Treasure Data
Using Embulk at Treasure Data
 
Why is this ASP.NET web app running slowly?
Why is this ASP.NET web app running slowly?Why is this ASP.NET web app running slowly?
Why is this ASP.NET web app running slowly?
 
Metrics, metrics everywhere (but where the heck do you start?)
Metrics, metrics everywhere (but where the heck do you start?) Metrics, metrics everywhere (but where the heck do you start?)
Metrics, metrics everywhere (but where the heck do you start?)
 
Metrics, metrics everywhere (but where the heck do you start?)
Metrics, metrics everywhere (but where the heck do you start?)Metrics, metrics everywhere (but where the heck do you start?)
Metrics, metrics everywhere (but where the heck do you start?)
 
Velocity NYC: Metrics, metrics everywhere (but where the heck do you start?)
Velocity NYC: Metrics, metrics everywhere (but where the heck do you start?)Velocity NYC: Metrics, metrics everywhere (but where the heck do you start?)
Velocity NYC: Metrics, metrics everywhere (but where the heck do you start?)
 
Apache Beam and Google Cloud Dataflow - IDG - final
Apache Beam and Google Cloud Dataflow - IDG - finalApache Beam and Google Cloud Dataflow - IDG - final
Apache Beam and Google Cloud Dataflow - IDG - final
 
Keynote I
Keynote IKeynote I
Keynote I
 

Mehr von Philip Tellis

Improving D3 Performance with CANVAS and other Hacks
Improving D3 Performance with CANVAS and other HacksImproving D3 Performance with CANVAS and other Hacks
Improving D3 Performance with CANVAS and other HacksPhilip Tellis
 
Frontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonFrontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonPhilip Tellis
 
Frontend Performance: De débutant à Expert à Fou Furieux
Frontend Performance: De débutant à Expert à Fou FurieuxFrontend Performance: De débutant à Expert à Fou Furieux
Frontend Performance: De débutant à Expert à Fou FurieuxPhilip Tellis
 
Frontend Performance: Expert to Crazy Person
Frontend Performance: Expert to Crazy PersonFrontend Performance: Expert to Crazy Person
Frontend Performance: Expert to Crazy PersonPhilip Tellis
 
Beyond Page Level Metrics
Beyond Page Level MetricsBeyond Page Level Metrics
Beyond Page Level MetricsPhilip Tellis
 
Frontend Performance: Beginner to Expert to Crazy Person (San Diego Web Perf ...
Frontend Performance: Beginner to Expert to Crazy Person (San Diego Web Perf ...Frontend Performance: Beginner to Expert to Crazy Person (San Diego Web Perf ...
Frontend Performance: Beginner to Expert to Crazy Person (San Diego Web Perf ...Philip Tellis
 
Frontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonFrontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonPhilip Tellis
 
Frontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonFrontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonPhilip Tellis
 
Frontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonFrontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonPhilip Tellis
 
RUM Distillation 101 -- Part I
RUM Distillation 101 -- Part IRUM Distillation 101 -- Part I
RUM Distillation 101 -- Part IPhilip Tellis
 
Improving 3rd Party Script Performance With IFrames
Improving 3rd Party Script Performance With IFramesImproving 3rd Party Script Performance With IFrames
Improving 3rd Party Script Performance With IFramesPhilip Tellis
 
The Statistics of Web Performance Analysis
The Statistics of Web Performance AnalysisThe Statistics of Web Performance Analysis
The Statistics of Web Performance AnalysisPhilip Tellis
 
A Node.JS bag of goodies for analyzing Web Traffic
A Node.JS bag of goodies for analyzing Web TrafficA Node.JS bag of goodies for analyzing Web Traffic
A Node.JS bag of goodies for analyzing Web TrafficPhilip Tellis
 
Boomerang: How fast do users think your site is?
Boomerang: How fast do users think your site is?Boomerang: How fast do users think your site is?
Boomerang: How fast do users think your site is?Philip Tellis
 
Boomerang at FOSS.IN/2010
Boomerang at FOSS.IN/2010Boomerang at FOSS.IN/2010
Boomerang at FOSS.IN/2010Philip Tellis
 
Measuring the web with Boomerang (YUIConf 2010)
Measuring the web with Boomerang (YUIConf 2010)Measuring the web with Boomerang (YUIConf 2010)
Measuring the web with Boomerang (YUIConf 2010)Philip Tellis
 

Mehr von Philip Tellis (20)

Improving D3 Performance with CANVAS and other Hacks
Improving D3 Performance with CANVAS and other HacksImproving D3 Performance with CANVAS and other Hacks
Improving D3 Performance with CANVAS and other Hacks
 
Frontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonFrontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy Person
 
Frontend Performance: De débutant à Expert à Fou Furieux
Frontend Performance: De débutant à Expert à Fou FurieuxFrontend Performance: De débutant à Expert à Fou Furieux
Frontend Performance: De débutant à Expert à Fou Furieux
 
Frontend Performance: Expert to Crazy Person
Frontend Performance: Expert to Crazy PersonFrontend Performance: Expert to Crazy Person
Frontend Performance: Expert to Crazy Person
 
Beyond Page Level Metrics
Beyond Page Level MetricsBeyond Page Level Metrics
Beyond Page Level Metrics
 
Frontend Performance: Beginner to Expert to Crazy Person (San Diego Web Perf ...
Frontend Performance: Beginner to Expert to Crazy Person (San Diego Web Perf ...Frontend Performance: Beginner to Expert to Crazy Person (San Diego Web Perf ...
Frontend Performance: Beginner to Expert to Crazy Person (San Diego Web Perf ...
 
Frontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonFrontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy Person
 
Frontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonFrontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy Person
 
Frontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonFrontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy Person
 
mmm... beacons
mmm... beaconsmmm... beacons
mmm... beacons
 
RUM Distillation 101 -- Part I
RUM Distillation 101 -- Part IRUM Distillation 101 -- Part I
RUM Distillation 101 -- Part I
 
Improving 3rd Party Script Performance With IFrames
Improving 3rd Party Script Performance With IFramesImproving 3rd Party Script Performance With IFrames
Improving 3rd Party Script Performance With IFrames
 
Extending Boomerang
Extending BoomerangExtending Boomerang
Extending Boomerang
 
The Statistics of Web Performance Analysis
The Statistics of Web Performance AnalysisThe Statistics of Web Performance Analysis
The Statistics of Web Performance Analysis
 
Rum for Breakfast
Rum for BreakfastRum for Breakfast
Rum for Breakfast
 
A Node.JS bag of goodies for analyzing Web Traffic
A Node.JS bag of goodies for analyzing Web TrafficA Node.JS bag of goodies for analyzing Web Traffic
A Node.JS bag of goodies for analyzing Web Traffic
 
Input sanitization
Input sanitizationInput sanitization
Input sanitization
 
Boomerang: How fast do users think your site is?
Boomerang: How fast do users think your site is?Boomerang: How fast do users think your site is?
Boomerang: How fast do users think your site is?
 
Boomerang at FOSS.IN/2010
Boomerang at FOSS.IN/2010Boomerang at FOSS.IN/2010
Boomerang at FOSS.IN/2010
 
Measuring the web with Boomerang (YUIConf 2010)
Measuring the web with Boomerang (YUIConf 2010)Measuring the web with Boomerang (YUIConf 2010)
Measuring the web with Boomerang (YUIConf 2010)
 

Kürzlich hochgeladen

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 

Kürzlich hochgeladen (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 

Abusing JavaScript to measure Web Performance, or, "how does boomerang work?"

  • 1. • Philip Tellis • .com • philip@lognormal.com • @bluesmoon • geek paranoid speedfreak • http://bluesmoon.info/ NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 1
  • 2. I <3 JavaScript NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 2
  • 3. So much that I wore Mustache socks to my wedding NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 3
  • 4. I’m a Speedfreak (the network kind) NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 4
  • 5. We measure real user website performance NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 5
  • 6. This talk is (mostly) about how we abuse JavaScript to do it NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 6
  • 7. Abusing JavaScript to Measure Web Performance Philip Tellis / philip@lognormal.com NY #WebPerf Meetup / 2012-09-13 NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 7
  • 8. First, a note about the code Note that in the code that follows, + new Date is equivalent to new Date().getTime() NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 8
  • 9. 1 Latency NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 9
  • 10. Arrange the following in order of increasing signal latency over a fixed distance: • Electricity through copper • Smoke Signals • Light through Fibre • Pulsar NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 10
  • 11. 1 Blinking Lights It takes about 16ms for light to get from SF to NYC (24ms through fibre) ... NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 11
  • 12. 1 Blinking Lights It takes about 16ms for light to get from SF to NYC (24ms through fibre) Though it takes about 100ms to ping... why? NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 11
  • 13. 1 HTTP NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 12
  • 14. So to measure latency, we need to send 1 packet each way, and time it NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 13
  • 15. 1 Network latency in JavaScript var ts, rtt, img = new Image; img.onload=function() { rtt=(+new Date - ts) }; ts = +new Date; img.src="/1x1.gif"; NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 14
  • 16. 1 Notes • 1x1 gif is 35 bytes • including HTTP headers, is smaller than a TCP packet • Fires onload on all browsers • 0 byte image fires onerror • which is indistinguishable from network error NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 15
  • 17. 2 TCP handshake NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 16
  • 18. 2 ACK-ACK-ACK NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 17
  • 19. 2 Connection: keep-alive NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 18
  • 20. 2 Network latency & TCP handshake in JavaScript var t=[], tcp, rtt; var ld = function() { t.push(+new Date); if(t.length > 2) // run 2 times done(); else { var img = new Image; img.onload = ld; img.src="/1x1.gif?" + Math.random() + ’=’ + new Date; } }; var done = function() { rtt=t[2]-t[1]; tcp=t[1]-t[0]-rtt; }; ld(); NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 19
  • 21. Notice that we’ve ignored DNS lookup time here... how would you measure it? NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 20
  • 22. Network Throughput 3 NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 21
  • 23. 3 Measuring Network Throughput data_length download_time NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 22
  • 24. Should you fly a 747 or a 737? • A 747 seats 400+ passengers • A 737 seats about 150 • Both take about the same time to fly from SFO to BOS • A 747 takes longer to load and unload than 3 737s in parallel The best selling aircraft to date is the 737 NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 23
  • 25. 3 Network Throughput in JavaScript // Assume global object // image={ url: ..., size: ... } var ts, rtt, bw, img = new Image; img.onload=function() { rtt=(+new Date - ts); bw = image.size*1000/rtt; // rtt is in ms }; ts = +new Date; img.src=image.url; NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 24
  • 26. 3 Measuring Network Throughput If it were that simple, I wouldn’t be doing this talk. NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 25
  • 27. 3 TCP Slow Start NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 26
  • 28. 3 Measuring Network Throughput So to make the best use of bandwidth, we need resources that fit in a TCP window NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 27
  • 29. 3 There is no single size that will tax all available networks http://www.yuiblog.com/blog/2010/04/08/analyzing-bandwidth-and-latency/ NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 28
  • 30. 3 Network Throughput in JavaScript – Take 2 // image object is now an array of multiple images var i=0; var ld = function() { if(i>0) image[i-1].end = +new Date; if(i >= image.length) done(); else { var img = new Image; img.onload = ld; image[i].start = +new Date; img.src=image[i].url; } i++; }; NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 29
  • 31. 3 Measuring Network Throughput Slow network connection, meet really huge image NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 30
  • 32. 3 Network Throughput in JavaScript – Take 3 var img = new Image; img.onload = ld; image[i].start = +new Date; image[i].timer = setTimeout(function() { image[i].expired=true }, image[i].timeout); img.src=image[i].url; NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 31
  • 33. 3 Network Throughput in JavaScript – Take 3 if(i>0) { image[i-1].end = +new Date; clearTimeout(image[i-1].timer); } NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 32
  • 34. 3 Network Throughput in JavaScript – Take 3 if(i >= image.length || (i > 0 && image[i-1].expired)) { done(); } NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 33
  • 35. 3 Measuring Network Throughput Are we done yet? NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 34
  • 36. 3 Measuring Network Throughput Are we done yet? sure... NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 34
  • 37. 3 Measuring Network Throughput Except network throughput is different every time you test it NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 35
  • 38. Statistics to the Rescue flickr/sophistechate/4264466015/ NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 36
  • 39. 3 Measuring Network Throughput The code for that is NOT gonna fit on a slide NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 37
  • 40. But this is sort of what we see world-wide NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 38
  • 41. And it’s different for different countries This is India NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 39
  • 42. 4 DNS NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 40
  • 43. 4 Measuring DNS time_with_dns − time_without_dns NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 41
  • 44. 4 Measuring DNS in JavaScript var t=[], dns, ip, hosts=[’http://hostname.com/’, ’http://ip.ad.dr.ess/’]; var ld = function() { t.push(+new Date); if(t.length > hosts.length) done(); else { var img = new Image; img.onload = ld; img.src=hosts[t.length-1] + "/1x1.gif"; } }; var done = function() { ip=t[2]-t[1]; dns=t[1]-t[0]-ip; }; ld(); NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 42
  • 45. 4 Measuring DNS • What if the IP changes? • What if DNS is cached? • What if you map DNS based on geo location? NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 43
  • 46. 4 Wildcard DNS Entries *.foo.com → IP address NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 44
  • 47. 4 Measuring DNS in JavaScript – take 2 var base_url="http://*.foo.com/", timers = {}, gen_url=""; function start() { var random = Math.random().toString(36), cache_bust = Math.random(), img = new Image(); gen_url = base_url.replace(/*/, random); img.onload = A_loaded; timers.start = +new Date; img.src = gen_url + "image-l.gif?t=" + cache_bust; } NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 45
  • 48. 4 Measuring DNS in JavaScript – take 2 function A_loaded() { var cache_bust = Math.random(), img = new Image(); img.onload = B_loaded; timers.a_loaded = +new Date; img.src = gen_url + "image-l.gif?t=" + cache_bust; } I’ll let you figure out B_loaded NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 46
  • 49. 4 Measuring DNS Full code in boomerang’s DNS plugin NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 47
  • 50. 5 IPv6 NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 48
  • 51. 5 Measuring IPv6 support and latency 1 Try to load image from IPv6 host • If timeout or error, then no IPv6 support • If successful, then calculate latency and proceed 2 Try to load image from hostname that resolves only to IPv6 host • If timeout or error, then DNS server doesn’t support IPv6 • If successful, calculate latency NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 49
  • 52. 5 Measuring IPv6 support and latency Full code in boomerang’s IPv6 plugin Note, only run this if you know IPv6 is supported by the client NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 50
  • 53. 6 Other Stuff NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 51
  • 54. 6 Other Stuff We Measure • NavTiming – navtiming.js • navigation.connection.type – mobile.js • window.performance.memory – memory.js – Chrome 22 reporting now. • Number of DOM nodes and byte size of HTML – memory.js NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 52
  • 55. And we try to do it fast NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 53
  • 56. .done() NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 54
  • 57. Code/References • http://lognormal.github.com/boomerang/doc/ (BSD Licensed) • www.lognormal.com NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 55
  • 58. • Philip Tellis • .com • philip@lognormal.com • @bluesmoon • geek paranoid speedfreak • http://bluesmoon.info/ NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 56
  • 59. Thank you Ask me about a discount code NY #WebPerf Meetup / 2012-09-13 Abusing JavaScript to Measure Web Performance 57