Performance, Games, and Distributed Testing in JavaScript

jeresig
Measuring Performance,
  JavaScript Games,
and Distributed Testing
                  John Resig
 http://ejohn.org - http://twitter.com/jeresig
Measuring
Performance
Analyzing Performance
    Optimizing performance is a huge
✦
    concern: Faster code = happy users!
    Measure execution time
✦

    Loop the code a few times
✦

    Measure the difference:
✦
    ✦ (new Date).getTime();
Stack Profiling
    jQuery Stack Profiler
✦

    Look for problematic methods and plugins
✦

    http://ejohn.org/blog/deep-profiling-
✦
    jquery-apps/
Performance, Games, and Distributed Testing in JavaScript
Accuracy of
  JavaScript Time
We’re measuring the performance of
 JavaScript from within JavaScript!


  http://ejohn.org/blog/accuracy-of-javascript-time/
Performance, Games, and Distributed Testing in JavaScript
Performance, Games, and Distributed Testing in JavaScript
Performance, Games, and Distributed Testing in JavaScript
15ms intervals ONLY!

     Error Rate of 50-750%!
Performance Tools
    How can we get good numbers?
✦

    We have to go straight to the source: Use
✦
    the tools the browsers provide.
    Tools:
✦
    ✦ Firebug Profiler
    ✦ Safari Profiler
      ✦ (Part of Safari 4)
    ✦ IE 8 Profiler
Firebug Profiler
Safari 4 Profiler
IE 8 Profiler
FireUnit
    A simple JavaScript test suite embedded in
✦
    Firebug.
    http://fireunit.org/
✦
FireUnit Profile Data

                                            {
 fireunit.getProfile();                              quot;timequot;: 8.443,
                                                   quot;callsquot;: 611,
                                                   quot;dataquot;:[
                                                   {
                                                      quot;namequot;:quot;makeArray()quot;,
                                                      quot;callsquot;:1,
                                                      quot;percentquot;:23.58,
                                                      quot;ownTimequot;:1.991,
                                                      quot;timequot;:1.991,
                                                      quot;avgTimequot;:1.991,
                                                      quot;minTimequot;:1.991,
                                                      quot;maxTimequot;:1.991,
                                                      quot;fileNamequot;:quot;jquery.js (line 2059)quot;
                                                   },
                                                   // etc.
http://ejohn.org/blog/function-call-profiling/ ]}
Complexity Analysis
             Analyze complexity rather than raw time
         ✦

             jQuery Call Count Profiler (uses FireUnit)
         ✦

             Method                        Calls           Big-O
.addClass(quot;testquot;);                 542             6n
.addClass(quot;testquot;);                 592             6n
.removeClass(quot;testquot;);              754             8n
.removeClass(quot;testquot;);              610             6n
.css(quot;colorquot;, quot;redquot;);              495             5n
.css({color: quot;redquot;, border: quot;1px   887             9n
solid redquot;});
.remove();                         23772           2n+n2
.append(quot;<p>test</p>quot;);            307             3n
Complexity Analysis
               Reducing call count helps to reduce
           ✦
               complexity
               Results for 1.3.3:
           ✦

                        Method                        Calls        Big-O

              .remove();                        298           3n

              .html(quot;<p>test</p>quot;); 507                       5n

              .empty();                         200           2n



http://ejohn.org/blog/function-call-profiling/
Why JavaScript
Games Are HARD
    to Build
Browser-Based Games
    No installation required
✦

    (Will be able to play at work!)
✦
Why not Flash?
    JavaScript works everywhere
✦
    ✦ Desktop
    ✦ iPhone / Mobile Device
    ✦ Wii
    ✦ OLPC

    JavaScript is an open technology
✦
Goals of a game
    Should be Multiplayer
✦

    Can’t be casually cheated
✦

    Work well everywhere
✦

    Addictive
✦
Why Multiplayer?
    Incredibly addictive
✦
    ✦ No longer “alone”
    ✦ Enticed to continue playing
3 Styles of Games
    Strategy
✦

    Intelligence
✦

    Accuracy
✦
Strategy Games
    Require a lot of time to think
✦

    Generally last over a couple hours or days
✦

    Replayability
✦

    Hard to cheat
✦
WarFish




        http://warfish.net/
    ✦
Nile Online




      http://www.playnileonline.com/
  ✦
Strategy Games
    Very server-side heavy
✦
    ✦ Most logic hidden from the user

    Hard to cheat
✦
    ✦ Casual cheaters can’t change values
    ✦ Dedicated cheaters have to write full AI
Intelligence Games
    Player’s intelligence/knowledge challenged
✦

    Games could be quick or slow-paced
✦

    Easy to cheat
✦
    ✦ Casual cheaters can open dictionary /
      encyclopedia for answers
Word Twist




      http://wordtwist.org/
  ✦
Babble




      http://playbabble.com/
  ✦
Iron Sudoku




      http://ironsudoku.com/
  ✦
Speed/Accuracy Games
    Require low latency
✦

    Fast-paced and addictive
✦

    JavaScript completely fails
✦
    ✦ Garbage Collection cycles freeze the
      browser
    None, or few, Accuracy-centric JavaScript
✦
    games
    Experienced coders can easily cheat
✦
    ✦ (A bot to hit the keys at the right time)
Guitar Hero




    http://ejohn.org/apps/hero/
Guitar Hero
    Heavily dependent upon accuracy
✦
    ✦ (Hit the right notes at the right time)

    Garbage collection cycles absolutely kill
✦
    the game
    Rendering the play area is also difficult
✦
    ✦ And impossible in all browsers.
    ✦ (Use HTML 5 Canvas Element)
Failures on All Ends
    Strategy: Slow, secret server-side code
✦

    Intelligence: Easily cheatable
✦

    Accuracy: Too hard to implement
✦

    Optimal solution would be a combination
✦
    of the above.
    JavaScript games can’t be like other games,
✦
    have to be unique.
What can make a fun game?
    Quick play
✦

    Points
✦

    High Scores
✦

    Head-to-head competition
✦
Wordsplay




    Real-time Boggle
✦

    Head-to-head with other players
✦

          http://www.wordsplay.net/
Tringo




    Tetris + Bingo (based on a Second Life
✦
    game)
                              http://ejohn.org/tringo/
DeepLeap



    Fast-paced Scrabble-like game
✦

    Speed + Intelligence + Strategy
✦




                                 http://deepleap.org/
vs. Cheating
    All words are recorded with exact time
✦
    information
    Game is “played back” on the server to
✦
    verify score integrity using Server-Side JS


    This data can be used to simulate a multi-
✦
    player experience!
DeepLeap
    Works in multiple languages
✦
    ✦ Dictionaries pulled from OpenOffice,
      can build a Spanish version in < 5sec
    Players can challenge each other head-to-
✦
    head
    Score multiplier (carry over from Guitar
✦
    Hero)
Distributed Testing
Choose Your Browsers
Cost / Benefit




  IE 7     IE 6          FF 3    Safari 3   Opera 9.5
                  Cost          Benefit


         Draw a line in the sand.
Graded Support




   Yahoo Browser Compatibility
Browser Support Grid
           IE      Firefox   Safari   Opera Chrome


Previous   6.0       2.0      3.0      9.5


Current    7.0       3.0      3.2      9.6    1.0


 Next      8.0       3.1      4.0     10.0    2.0

                 jQuery Browser Support
Browser Support Grid
           IE       Firefox   Safari   Opera Chrome


Previous                       3.0      9.5
           6.0        2.0


Current    7.0        3.0      3.2      9.6    1.0


 Next      8.0        3.1      4.0             2.0
                                       10.0

                jQuery 1.3 Browser Support
The Scaling Problem
    The Problem:
✦
    ✦ jQuery has 6 test suites
    ✦ Run in 11 browsers
    ✦ (Not even including multiple platforms!)

    All need to be run for every commit,
✦
    patch, and plugin.
    JavaScript testing doesn’t scale well.
✦
Distributed Testing
    Hub server
✦

    Clients connect and help run tests
✦

    A simple JavaScript client that can be run
✦
    in all browsers
    ✦ Including mobile browsers!


✦ TestSwarm
FF 3.5 FF 3.5 FF 3.5
                                                  IE 6
                                                         IE 6
       FF 3                                                      IE 6
                                           Op 9
FF 3

                                                                 IE 7

                               TestSwarm
                                                                  IE 7




              Test Suite        Test Suite          Test Suite
Manual Testing
    Push tests to users who follow pre-defined
✦
    steps
    Answer ‘Yes’/’No’ questions which are
✦
    pushed back to the server.
    An effective way to distribute manual test
✦
    load to dozens of clients.
TestSwarm.com
    Incentives for top testers (t-shirts, books)
✦

    Will be opening for alpha testing very soon
✦

    Help your favorite JavaScript library
✦
    become better tested!
    http://testswarm.com
✦
Questions
    Contact:
✦
    ✦ John Resig
    ✦ http://ejohn.org/
    ✦ http://twitter.com/jeresig
1 of 54

Recommended

Building a JavaScript Library by
Building a JavaScript LibraryBuilding a JavaScript Library
Building a JavaScript Libraryjeresig
11.7K views54 slides
jQuery Proven Performance Tips & Tricks by
jQuery Proven Performance Tips & TricksjQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & TricksAddy Osmani
175.6K views87 slides
How to make Ajax work for you by
How to make Ajax work for youHow to make Ajax work for you
How to make Ajax work for youSimon Willison
44.2K views134 slides
HTML5 vs Silverlight by
HTML5 vs SilverlightHTML5 vs Silverlight
HTML5 vs SilverlightMatt Casto
4.3K views71 slides
CouchDB Google by
CouchDB GoogleCouchDB Google
CouchDB GoogleSteve Souders
1.7K views74 slides
Night Watch with QA by
Night Watch with QANight Watch with QA
Night Watch with QACarsten Sandtner
1.4K views61 slides

More Related Content

What's hot

Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJ by
Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJRealize mais com HTML 5 e CSS 3 - 16 EDTED - RJ
Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJLeonardo Balter
1.1K views83 slides
HTML5 for the Silverlight Guy by
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyDavid Padbury
2.5K views116 slides
Ugo Cei Presentation by
Ugo Cei PresentationUgo Cei Presentation
Ugo Cei PresentationRubyOnRails_dude
1.8K views36 slides
High Performance JavaScript - WebDirections USA 2010 by
High Performance JavaScript - WebDirections USA 2010High Performance JavaScript - WebDirections USA 2010
High Performance JavaScript - WebDirections USA 2010Nicholas Zakas
59.7K views105 slides
Keypoints html5 by
Keypoints html5Keypoints html5
Keypoints html5dynamis
29.7K views243 slides
High Performance Ajax Applications by
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax ApplicationsJulien Lecomte
56.7K views42 slides

What's hot(20)

Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJ by Leonardo Balter
Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJRealize mais com HTML 5 e CSS 3 - 16 EDTED - RJ
Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJ
Leonardo Balter1.1K views
HTML5 for the Silverlight Guy by David Padbury
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
David Padbury2.5K views
High Performance JavaScript - WebDirections USA 2010 by Nicholas Zakas
High Performance JavaScript - WebDirections USA 2010High Performance JavaScript - WebDirections USA 2010
High Performance JavaScript - WebDirections USA 2010
Nicholas Zakas59.7K views
Keypoints html5 by dynamis
Keypoints html5Keypoints html5
Keypoints html5
dynamis 29.7K views
High Performance Ajax Applications by Julien Lecomte
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax Applications
Julien Lecomte56.7K views
Jazz up your JavaScript: Unobtrusive scripting with JavaScript libraries by Simon Willison
Jazz up your JavaScript: Unobtrusive scripting with JavaScript librariesJazz up your JavaScript: Unobtrusive scripting with JavaScript libraries
Jazz up your JavaScript: Unobtrusive scripting with JavaScript libraries
Simon Willison48.2K views
Unit and functional testing with Siesta by Grgur Grisogono
Unit and functional testing with SiestaUnit and functional testing with Siesta
Unit and functional testing with Siesta
Grgur Grisogono4.6K views
Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011) by Nicholas Zakas
Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)
Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)
Nicholas Zakas10.1K views
Video.js - How to build and HTML5 Video Player by steveheffernan
Video.js - How to build and HTML5 Video PlayerVideo.js - How to build and HTML5 Video Player
Video.js - How to build and HTML5 Video Player
steveheffernan4.1K views
Роман Лютиков "Web Apps Performance & JavaScript Compilers" by Fwdays
Роман Лютиков "Web Apps Performance & JavaScript Compilers"Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Fwdays367 views
Making the HTML5 Video element interactive by Charles Hudson
Making the HTML5 Video element interactiveMaking the HTML5 Video element interactive
Making the HTML5 Video element interactive
Charles Hudson15.5K views
Testing nightwatch, by David Torroija by David Torroija
Testing nightwatch, by David TorroijaTesting nightwatch, by David Torroija
Testing nightwatch, by David Torroija
David Torroija1.3K views
Front end performance optimization by Stevie T
Front end performance optimizationFront end performance optimization
Front end performance optimization
Stevie T1.7K views
Java script unit testing by Mats Bryntse
Java script unit testingJava script unit testing
Java script unit testing
Mats Bryntse3K views

Viewers also liked

The JSON Saga by
The JSON SagaThe JSON Saga
The JSON Sagakaven yan
1.7K views65 slides
The Theory Of The Dom by
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Domkaven yan
2.7K views66 slides
Ajax Performance by
Ajax PerformanceAjax Performance
Ajax Performancekaven yan
1.8K views56 slides
Douglas Crockford - Programming Style and Your Brain by
Douglas Crockford - Programming Style and Your BrainDouglas Crockford - Programming Style and Your Brain
Douglas Crockford - Programming Style and Your BrainWeb Directions
4.2K views76 slides
Performance Improvements in Browsers by
Performance Improvements in BrowsersPerformance Improvements in Browsers
Performance Improvements in Browsersjeresig
12.1K views65 slides
Douglas Crockford - Ajax Security by
Douglas Crockford - Ajax SecurityDouglas Crockford - Ajax Security
Douglas Crockford - Ajax SecurityWeb Directions
21K views78 slides

Viewers also liked(15)

The JSON Saga by kaven yan
The JSON SagaThe JSON Saga
The JSON Saga
kaven yan1.7K views
The Theory Of The Dom by kaven yan
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
kaven yan2.7K views
Ajax Performance by kaven yan
Ajax PerformanceAjax Performance
Ajax Performance
kaven yan1.8K views
Douglas Crockford - Programming Style and Your Brain by Web Directions
Douglas Crockford - Programming Style and Your BrainDouglas Crockford - Programming Style and Your Brain
Douglas Crockford - Programming Style and Your Brain
Web Directions4.2K views
Performance Improvements in Browsers by jeresig
Performance Improvements in BrowsersPerformance Improvements in Browsers
Performance Improvements in Browsers
jeresig12.1K views
Douglas Crockford - Ajax Security by Web Directions
Douglas Crockford - Ajax SecurityDouglas Crockford - Ajax Security
Douglas Crockford - Ajax Security
Web Directions21K views
Good Parts of JavaScript Douglas Crockford by rajivmordani
Good Parts of JavaScript Douglas CrockfordGood Parts of JavaScript Douglas Crockford
Good Parts of JavaScript Douglas Crockford
rajivmordani4.1K views
Advanced Javascript by Adieu
Advanced JavascriptAdvanced Javascript
Advanced Javascript
Adieu8.2K views
Advanced JavaScript Concepts by Naresh Kumar
Advanced JavaScript ConceptsAdvanced JavaScript Concepts
Advanced JavaScript Concepts
Naresh Kumar10.6K views
Scalable JavaScript Application Architecture by Nicholas Zakas
Scalable JavaScript Application ArchitectureScalable JavaScript Application Architecture
Scalable JavaScript Application Architecture
Nicholas Zakas176.2K views
The DOM is a Mess @ Yahoo by jeresig
The DOM is a Mess @ YahooThe DOM is a Mess @ Yahoo
The DOM is a Mess @ Yahoo
jeresig50.6K views
The JavaScript Programming Language by guestceb98b
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
guestceb98b11.3K views
Speed Up Your JavaScript by Nicholas Zakas
Speed Up Your JavaScriptSpeed Up Your JavaScript
Speed Up Your JavaScript
Nicholas Zakas17.6K views

Similar to Performance, Games, and Distributed Testing in JavaScript

Performance Improvements In Browsers by
Performance Improvements In BrowsersPerformance Improvements In Browsers
Performance Improvements In BrowsersGoogleTecTalks
662 views65 slides
jQuery 1.3 and jQuery UI by
jQuery 1.3 and jQuery UIjQuery 1.3 and jQuery UI
jQuery 1.3 and jQuery UIjeresig
4.5K views24 slides
Ajax Tutorial by
Ajax TutorialAjax Tutorial
Ajax Tutorialoscon2007
605 views58 slides
Mocking - Visug session by
Mocking - Visug sessionMocking - Visug session
Mocking - Visug sessionMaarten Balliauw
1.3K views28 slides
Performance Improvements in Browsers by
Performance Improvements in BrowsersPerformance Improvements in Browsers
Performance Improvements in Browsersjeresig
3.9K views46 slides
iPhone Development For Experienced Web Developers by
iPhone Development For Experienced Web DevelopersiPhone Development For Experienced Web Developers
iPhone Development For Experienced Web Developerslisab517
537 views46 slides

Similar to Performance, Games, and Distributed Testing in JavaScript(20)

Performance Improvements In Browsers by GoogleTecTalks
Performance Improvements In BrowsersPerformance Improvements In Browsers
Performance Improvements In Browsers
GoogleTecTalks662 views
jQuery 1.3 and jQuery UI by jeresig
jQuery 1.3 and jQuery UIjQuery 1.3 and jQuery UI
jQuery 1.3 and jQuery UI
jeresig4.5K views
Ajax Tutorial by oscon2007
Ajax TutorialAjax Tutorial
Ajax Tutorial
oscon2007605 views
Performance Improvements in Browsers by jeresig
Performance Improvements in BrowsersPerformance Improvements in Browsers
Performance Improvements in Browsers
jeresig3.9K views
iPhone Development For Experienced Web Developers by lisab517
iPhone Development For Experienced Web DevelopersiPhone Development For Experienced Web Developers
iPhone Development For Experienced Web Developers
lisab517537 views
JavaFX Advanced by Paul Bakker
JavaFX AdvancedJavaFX Advanced
JavaFX Advanced
Paul Bakker2.3K views
Jslunch6 by Nao Haida
Jslunch6Jslunch6
Jslunch6
Nao Haida535 views
Learning jQuery @ MIT by jeresig
Learning jQuery @ MITLearning jQuery @ MIT
Learning jQuery @ MIT
jeresig1.5K views
Browser-Based testing using Selenium by ret0
Browser-Based testing using SeleniumBrowser-Based testing using Selenium
Browser-Based testing using Selenium
ret01.2K views
Mobile web-debug by FINN.no
Mobile web-debugMobile web-debug
Mobile web-debug
FINN.no651 views
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge by Guillaume Laforge
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume LaforgeGroovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
Guillaume Laforge1.1K views
Automated Frontend Testing by Neil Crosby
Automated Frontend TestingAutomated Frontend Testing
Automated Frontend Testing
Neil Crosby11.6K views
The Future of Firefox and JavaScript by jeresig
The Future of Firefox and JavaScriptThe Future of Firefox and JavaScript
The Future of Firefox and JavaScript
jeresig4.4K views
Jun Heider - Flex Application Profiling By Example by 360|Conferences
Jun Heider - Flex Application Profiling By ExampleJun Heider - Flex Application Profiling By Example
Jun Heider - Flex Application Profiling By Example
360|Conferences835 views
Presentations Unusual Java Bugs And Detecting Them Using Foss Tools by Ganesh Samarthyam
Presentations Unusual Java Bugs And Detecting Them Using Foss ToolsPresentations Unusual Java Bugs And Detecting Them Using Foss Tools
Presentations Unusual Java Bugs And Detecting Them Using Foss Tools
Ganesh Samarthyam559 views
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond by mguillem
WebTest - Efficient Functional Web Testing with HtmlUnit and BeyondWebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
mguillem5.1K views
Front end performance tip by Steve Yu
Front end performance tipFront end performance tip
Front end performance tip
Steve Yu1.7K views

More from jeresig

Does Coding Every Day Matter? by
Does Coding Every Day Matter?Does Coding Every Day Matter?
Does Coding Every Day Matter?jeresig
3K views19 slides
Accidentally Becoming a Digital Librarian by
Accidentally Becoming a Digital LibrarianAccidentally Becoming a Digital Librarian
Accidentally Becoming a Digital Librarianjeresig
1.3K views72 slides
2014: John's Favorite Thing (Neo4j) by
2014: John's Favorite Thing (Neo4j)2014: John's Favorite Thing (Neo4j)
2014: John's Favorite Thing (Neo4j)jeresig
847 views42 slides
Computer Vision as Art Historical Investigation by
Computer Vision as Art Historical InvestigationComputer Vision as Art Historical Investigation
Computer Vision as Art Historical Investigationjeresig
1K views89 slides
Hacking Art History by
Hacking Art HistoryHacking Art History
Hacking Art Historyjeresig
925 views107 slides
Using JS to teach JS at Khan Academy by
Using JS to teach JS at Khan AcademyUsing JS to teach JS at Khan Academy
Using JS to teach JS at Khan Academyjeresig
1K views25 slides

More from jeresig(20)

Does Coding Every Day Matter? by jeresig
Does Coding Every Day Matter?Does Coding Every Day Matter?
Does Coding Every Day Matter?
jeresig3K views
Accidentally Becoming a Digital Librarian by jeresig
Accidentally Becoming a Digital LibrarianAccidentally Becoming a Digital Librarian
Accidentally Becoming a Digital Librarian
jeresig1.3K views
2014: John's Favorite Thing (Neo4j) by jeresig
2014: John's Favorite Thing (Neo4j)2014: John's Favorite Thing (Neo4j)
2014: John's Favorite Thing (Neo4j)
jeresig847 views
Computer Vision as Art Historical Investigation by jeresig
Computer Vision as Art Historical InvestigationComputer Vision as Art Historical Investigation
Computer Vision as Art Historical Investigation
jeresig1K views
Hacking Art History by jeresig
Hacking Art HistoryHacking Art History
Hacking Art History
jeresig925 views
Using JS to teach JS at Khan Academy by jeresig
Using JS to teach JS at Khan AcademyUsing JS to teach JS at Khan Academy
Using JS to teach JS at Khan Academy
jeresig1K views
Applying Computer Vision to Art History by jeresig
Applying Computer Vision to Art HistoryApplying Computer Vision to Art History
Applying Computer Vision to Art History
jeresig826 views
NYARC 2014: Frick/Zeri Results by jeresig
NYARC 2014: Frick/Zeri ResultsNYARC 2014: Frick/Zeri Results
NYARC 2014: Frick/Zeri Results
jeresig2.1K views
EmpireJS: Hacking Art with Node js and Image Analysis by jeresig
EmpireJS: Hacking Art with Node js and Image AnalysisEmpireJS: Hacking Art with Node js and Image Analysis
EmpireJS: Hacking Art with Node js and Image Analysis
jeresig18.5K views
Applying Computer Vision to Art History by jeresig
Applying Computer Vision to Art HistoryApplying Computer Vision to Art History
Applying Computer Vision to Art History
jeresig3.1K views
JavaScript Libraries (Ajax Exp 2006) by jeresig
JavaScript Libraries (Ajax Exp 2006)JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)
jeresig3.1K views
Introduction to jQuery (Ajax Exp 2006) by jeresig
Introduction to jQuery (Ajax Exp 2006)Introduction to jQuery (Ajax Exp 2006)
Introduction to jQuery (Ajax Exp 2006)
jeresig2.4K views
jQuery Recommendations to the W3C (2011) by jeresig
jQuery Recommendations to the W3C (2011)jQuery Recommendations to the W3C (2011)
jQuery Recommendations to the W3C (2011)
jeresig1.7K views
jQuery Open Source Process (RIT 2011) by jeresig
jQuery Open Source Process (RIT 2011)jQuery Open Source Process (RIT 2011)
jQuery Open Source Process (RIT 2011)
jeresig1.7K views
jQuery Open Source Process (Knight Foundation 2011) by jeresig
jQuery Open Source Process (Knight Foundation 2011)jQuery Open Source Process (Knight Foundation 2011)
jQuery Open Source Process (Knight Foundation 2011)
jeresig2.2K views
jQuery Mobile by jeresig
jQuery MobilejQuery Mobile
jQuery Mobile
jeresig1.5K views
jQuery Open Source (Fronteer 2011) by jeresig
jQuery Open Source (Fronteer 2011)jQuery Open Source (Fronteer 2011)
jQuery Open Source (Fronteer 2011)
jeresig4K views
Holistic JavaScript Performance by jeresig
Holistic JavaScript PerformanceHolistic JavaScript Performance
Holistic JavaScript Performance
jeresig4K views
New Features Coming in Browsers (RIT '09) by jeresig
New Features Coming in Browsers (RIT '09)New Features Coming in Browsers (RIT '09)
New Features Coming in Browsers (RIT '09)
jeresig1.5K views
Introduction to jQuery (Ajax Exp 2007) by jeresig
Introduction to jQuery (Ajax Exp 2007)Introduction to jQuery (Ajax Exp 2007)
Introduction to jQuery (Ajax Exp 2007)
jeresig1.3K views

Recently uploaded

The Research Portal of Catalonia: Growing more (information) & more (services) by
The Research Portal of Catalonia: Growing more (information) & more (services)The Research Portal of Catalonia: Growing more (information) & more (services)
The Research Portal of Catalonia: Growing more (information) & more (services)CSUC - Consorci de Serveis Universitaris de Catalunya
73 views25 slides
Java Platform Approach 1.0 - Picnic Meetup by
Java Platform Approach 1.0 - Picnic MeetupJava Platform Approach 1.0 - Picnic Meetup
Java Platform Approach 1.0 - Picnic MeetupRick Ossendrijver
25 views39 slides
AI: mind, matter, meaning, metaphors, being, becoming, life values by
AI: mind, matter, meaning, metaphors, being, becoming, life valuesAI: mind, matter, meaning, metaphors, being, becoming, life values
AI: mind, matter, meaning, metaphors, being, becoming, life valuesTwain Liu 刘秋艳
35 views16 slides
Data-centric AI and the convergence of data and model engineering: opportunit... by
Data-centric AI and the convergence of data and model engineering:opportunit...Data-centric AI and the convergence of data and model engineering:opportunit...
Data-centric AI and the convergence of data and model engineering: opportunit...Paolo Missier
34 views40 slides
STPI OctaNE CoE Brochure.pdf by
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdfmadhurjyapb
12 views1 slide
PharoJS - Zürich Smalltalk Group Meetup November 2023 by
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023Noury Bouraqadi
120 views17 slides

Recently uploaded(20)

AI: mind, matter, meaning, metaphors, being, becoming, life values by Twain Liu 刘秋艳
AI: mind, matter, meaning, metaphors, being, becoming, life valuesAI: mind, matter, meaning, metaphors, being, becoming, life values
AI: mind, matter, meaning, metaphors, being, becoming, life values
Data-centric AI and the convergence of data and model engineering: opportunit... by Paolo Missier
Data-centric AI and the convergence of data and model engineering:opportunit...Data-centric AI and the convergence of data and model engineering:opportunit...
Data-centric AI and the convergence of data and model engineering: opportunit...
Paolo Missier34 views
STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb12 views
PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi120 views
Understanding GenAI/LLM and What is Google Offering - Felix Goh by NUS-ISS
Understanding GenAI/LLM and What is Google Offering - Felix GohUnderstanding GenAI/LLM and What is Google Offering - Felix Goh
Understanding GenAI/LLM and What is Google Offering - Felix Goh
NUS-ISS41 views
Transcript: The Details of Description Techniques tips and tangents on altern... by BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada130 views
Spesifikasi Lengkap ASUS Vivobook Go 14 by Dot Semarang
Spesifikasi Lengkap ASUS Vivobook Go 14Spesifikasi Lengkap ASUS Vivobook Go 14
Spesifikasi Lengkap ASUS Vivobook Go 14
Dot Semarang35 views
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors by sugiuralab
TouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective SensorsTouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective Sensors
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors
sugiuralab15 views
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu... by NUS-ISS
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...
NUS-ISS37 views
DALI Basics Course 2023 by Ivory Egg
DALI Basics Course  2023DALI Basics Course  2023
DALI Basics Course 2023
Ivory Egg14 views
RADIUS-Omnichannel Interaction System by RADIUS
RADIUS-Omnichannel Interaction SystemRADIUS-Omnichannel Interaction System
RADIUS-Omnichannel Interaction System
RADIUS15 views
Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum... by NUS-ISS
Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum...Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum...
Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum...
NUS-ISS34 views
SAP Automation Using Bar Code and FIORI.pdf by Virendra Rai, PMP
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdf

Performance, Games, and Distributed Testing in JavaScript

  • 1. Measuring Performance, JavaScript Games, and Distributed Testing John Resig http://ejohn.org - http://twitter.com/jeresig
  • 3. Analyzing Performance Optimizing performance is a huge ✦ concern: Faster code = happy users! Measure execution time ✦ Loop the code a few times ✦ Measure the difference: ✦ ✦ (new Date).getTime();
  • 4. Stack Profiling jQuery Stack Profiler ✦ Look for problematic methods and plugins ✦ http://ejohn.org/blog/deep-profiling- ✦ jquery-apps/
  • 6. Accuracy of JavaScript Time We’re measuring the performance of JavaScript from within JavaScript! http://ejohn.org/blog/accuracy-of-javascript-time/
  • 10. 15ms intervals ONLY! Error Rate of 50-750%!
  • 11. Performance Tools How can we get good numbers? ✦ We have to go straight to the source: Use ✦ the tools the browsers provide. Tools: ✦ ✦ Firebug Profiler ✦ Safari Profiler ✦ (Part of Safari 4) ✦ IE 8 Profiler
  • 15. FireUnit A simple JavaScript test suite embedded in ✦ Firebug. http://fireunit.org/ ✦
  • 16. FireUnit Profile Data { fireunit.getProfile(); quot;timequot;: 8.443, quot;callsquot;: 611, quot;dataquot;:[ { quot;namequot;:quot;makeArray()quot;, quot;callsquot;:1, quot;percentquot;:23.58, quot;ownTimequot;:1.991, quot;timequot;:1.991, quot;avgTimequot;:1.991, quot;minTimequot;:1.991, quot;maxTimequot;:1.991, quot;fileNamequot;:quot;jquery.js (line 2059)quot; }, // etc. http://ejohn.org/blog/function-call-profiling/ ]}
  • 17. Complexity Analysis Analyze complexity rather than raw time ✦ jQuery Call Count Profiler (uses FireUnit) ✦ Method Calls Big-O .addClass(quot;testquot;); 542 6n .addClass(quot;testquot;); 592 6n .removeClass(quot;testquot;); 754 8n .removeClass(quot;testquot;); 610 6n .css(quot;colorquot;, quot;redquot;); 495 5n .css({color: quot;redquot;, border: quot;1px 887 9n solid redquot;}); .remove(); 23772 2n+n2 .append(quot;<p>test</p>quot;); 307 3n
  • 18. Complexity Analysis Reducing call count helps to reduce ✦ complexity Results for 1.3.3: ✦ Method Calls Big-O .remove(); 298 3n .html(quot;<p>test</p>quot;); 507 5n .empty(); 200 2n http://ejohn.org/blog/function-call-profiling/
  • 19. Why JavaScript Games Are HARD to Build
  • 20. Browser-Based Games No installation required ✦ (Will be able to play at work!) ✦
  • 21. Why not Flash? JavaScript works everywhere ✦ ✦ Desktop ✦ iPhone / Mobile Device ✦ Wii ✦ OLPC JavaScript is an open technology ✦
  • 22. Goals of a game Should be Multiplayer ✦ Can’t be casually cheated ✦ Work well everywhere ✦ Addictive ✦
  • 23. Why Multiplayer? Incredibly addictive ✦ ✦ No longer “alone” ✦ Enticed to continue playing
  • 24. 3 Styles of Games Strategy ✦ Intelligence ✦ Accuracy ✦
  • 25. Strategy Games Require a lot of time to think ✦ Generally last over a couple hours or days ✦ Replayability ✦ Hard to cheat ✦
  • 26. WarFish http://warfish.net/ ✦
  • 27. Nile Online http://www.playnileonline.com/ ✦
  • 28. Strategy Games Very server-side heavy ✦ ✦ Most logic hidden from the user Hard to cheat ✦ ✦ Casual cheaters can’t change values ✦ Dedicated cheaters have to write full AI
  • 29. Intelligence Games Player’s intelligence/knowledge challenged ✦ Games could be quick or slow-paced ✦ Easy to cheat ✦ ✦ Casual cheaters can open dictionary / encyclopedia for answers
  • 30. Word Twist http://wordtwist.org/ ✦
  • 31. Babble http://playbabble.com/ ✦
  • 32. Iron Sudoku http://ironsudoku.com/ ✦
  • 33. Speed/Accuracy Games Require low latency ✦ Fast-paced and addictive ✦ JavaScript completely fails ✦ ✦ Garbage Collection cycles freeze the browser None, or few, Accuracy-centric JavaScript ✦ games Experienced coders can easily cheat ✦ ✦ (A bot to hit the keys at the right time)
  • 34. Guitar Hero http://ejohn.org/apps/hero/
  • 35. Guitar Hero Heavily dependent upon accuracy ✦ ✦ (Hit the right notes at the right time) Garbage collection cycles absolutely kill ✦ the game Rendering the play area is also difficult ✦ ✦ And impossible in all browsers. ✦ (Use HTML 5 Canvas Element)
  • 36. Failures on All Ends Strategy: Slow, secret server-side code ✦ Intelligence: Easily cheatable ✦ Accuracy: Too hard to implement ✦ Optimal solution would be a combination ✦ of the above. JavaScript games can’t be like other games, ✦ have to be unique.
  • 37. What can make a fun game? Quick play ✦ Points ✦ High Scores ✦ Head-to-head competition ✦
  • 38. Wordsplay Real-time Boggle ✦ Head-to-head with other players ✦ http://www.wordsplay.net/
  • 39. Tringo Tetris + Bingo (based on a Second Life ✦ game) http://ejohn.org/tringo/
  • 40. DeepLeap Fast-paced Scrabble-like game ✦ Speed + Intelligence + Strategy ✦ http://deepleap.org/
  • 41. vs. Cheating All words are recorded with exact time ✦ information Game is “played back” on the server to ✦ verify score integrity using Server-Side JS This data can be used to simulate a multi- ✦ player experience!
  • 42. DeepLeap Works in multiple languages ✦ ✦ Dictionaries pulled from OpenOffice, can build a Spanish version in < 5sec Players can challenge each other head-to- ✦ head Score multiplier (carry over from Guitar ✦ Hero)
  • 45. Cost / Benefit IE 7 IE 6 FF 3 Safari 3 Opera 9.5 Cost Benefit Draw a line in the sand.
  • 46. Graded Support Yahoo Browser Compatibility
  • 47. Browser Support Grid IE Firefox Safari Opera Chrome Previous 6.0 2.0 3.0 9.5 Current 7.0 3.0 3.2 9.6 1.0 Next 8.0 3.1 4.0 10.0 2.0 jQuery Browser Support
  • 48. Browser Support Grid IE Firefox Safari Opera Chrome Previous 3.0 9.5 6.0 2.0 Current 7.0 3.0 3.2 9.6 1.0 Next 8.0 3.1 4.0 2.0 10.0 jQuery 1.3 Browser Support
  • 49. The Scaling Problem The Problem: ✦ ✦ jQuery has 6 test suites ✦ Run in 11 browsers ✦ (Not even including multiple platforms!) All need to be run for every commit, ✦ patch, and plugin. JavaScript testing doesn’t scale well. ✦
  • 50. Distributed Testing Hub server ✦ Clients connect and help run tests ✦ A simple JavaScript client that can be run ✦ in all browsers ✦ Including mobile browsers! ✦ TestSwarm
  • 51. FF 3.5 FF 3.5 FF 3.5 IE 6 IE 6 FF 3 IE 6 Op 9 FF 3 IE 7 TestSwarm IE 7 Test Suite Test Suite Test Suite
  • 52. Manual Testing Push tests to users who follow pre-defined ✦ steps Answer ‘Yes’/’No’ questions which are ✦ pushed back to the server. An effective way to distribute manual test ✦ load to dozens of clients.
  • 53. TestSwarm.com Incentives for top testers (t-shirts, books) ✦ Will be opening for alpha testing very soon ✦ Help your favorite JavaScript library ✦ become better tested! http://testswarm.com ✦
  • 54. Questions Contact: ✦ ✦ John Resig ✦ http://ejohn.org/ ✦ http://twitter.com/jeresig