Git Product home page Git Product logo

latency-benchmark's Introduction

Screenshot

About the benchmark

The Web Latency Benchmark is a new kind of benchmark that tests your browser's responsiveness by directly measuring latency and jank. Visit the homepage at http://google.github.io/latency-benchmark for examples of the kinds of latency and jank that are measured.

New: Oculus Latency Tester support

The Oculus Latency Tester is a hardware device with a light sensor that can measure end-to-end latency from USB input to pixels changing on the screen. This kind of hardware-based measurement accounts for all possible sources of latency. It's the most complete and accurate measurement possible, and it's now supported by the Web Latency Benchmark. Just plug it in and you'll see a special test page.

New: Automated testing

Thanks to jmaher, the benchmark now accepts command-line arguments that enable fully automated benchmark runs, with results reported in JSON format to a server of your choosing.

How it works

The Web Latency Benchmark works by programmatically sending input events to a browser window, and using screenshot APIs to detect when the browser has finished drawing its response.

There are two main components: the latency-benchmark server (written in C/C++) and the HTML/JavaScript benchmark page. The HTML page draws a special pattern of pixels to the screen using WebGL or Canvas 2D, then makes an XMLHTTPRequest to the server to start the latency measurement. The server locates the browser window by searching a screenshot for the special pattern. Once the browser window is located, the server starts sending input events. Each time the HTML page receives an input event it encodes that information into pixels in the on-screen pattern, drawn using the canvas element. Meanwhile the server is taking screenshots every few milliseconds. By decoding the pixel pattern the server can determine to within a few milliseconds how long it takes the browser to respond to each input event.

The native reference test is special because it requires extra support from the server. Using the native APIs of each platform, the server creates a special benchmark window that draws the same pattern as the test webpage, and responds to keyboard input in the same way. To ensure fairness when compared with the browser, this window is opened in a separate process and uses OpenGL to draw the pattern on the screen. The benchmark window opens as a popup window, only 1 pixel tall and without a border or title bar, so it's almost unnoticeable.

License and distribution

The Web Latency Benchmark is licensed under the Apache License version 2.0. This is an open source project; it is not an official Google product.

Build prerequisites

Python 2.x is required on all platforms for GYP, which generates the build files.

  • Windows: GYP is currently configured to generate project files for Visual Studio 2012 (Express works). 2010 might work too if you edit generate-project-files.bat to change the version. The Windows 8 SDK is required due to the use of DXGI 1.2. It can be installed on Windows 7 and Windows Vista.
  • Mac: XCode 4 is required.
  • Linux: Clang is required. The benchmark does not compile with GCC. Other build dependencies are development headers for OpenGL, X11, and udev (for the Oculus SDK). The corresponding Debian/Ubuntu packages are libgl1-mesa-dev, xorg-dev, and libudev-dev.

Build steps

First, you need to git submodule init && git submodule update to fetch the submodules in third_party. Then, you need to run generate-project-files, which will run GYP and generate platform-specific project files in build/.

  • Windows: Open build/latency-benchmark.sln.
  • Mac: Open build/latency-benchmark.xcodeproj. For debugging you will need to edit the default scheme to change the working directory of the latency-test executable to $(PROJECT_DIR) so it can find the HTML files. You will also want to configure the debugger to ignore SIGPIPE.
  • Linux: Run the script linux-build to compile with Clang. The binary will be built at build/out/Debug/latency-benchmark. Run it in the top-level directory so it can find the HTML files. You can build the release version by defining the environment variable BUILDTYPE=Release.

You shouldn't make any changes to the XCode or Visual Studio project files directly. Instead, you should edit latency-benchmark.gyp to reflect the changes you want, and re-run the generate-project-files script to update the project files with the changes. This ensures that the project files stay in sync across platforms.

TODO

  • Bookmarklet or browser extension for injecting a hardware latency test into any web page.
  • Support for more operating systems:
    • Android
    • iOS
    • Chrome OS
  • Support jank measurement with the Oculus Latency Tester, in addition to latency measurement.
  • Fix non-Firefox browsers in automated testing mode on Windows (mousewheel scroll events not sent properly).
  • Fix IE11 in high DPI mode (test pattern scrolls off screen).
  • Disable mouse and keyboard input during the test to avoid interference.
  • Hide the mouse cursor during the test.
  • Find a way to share constants like the test timeout between JS and C.
  • Test more possible causes of jank:
    • audio/video loading
    • plugins
    • JavaScript parsing
    • GC
    • WebGL shader compilation
    • Web Worker JavaScript parsing/execution
    • GC in a worker
    • HTML parsing
    • CSS parsing
    • layout
    • DNS resolution
    • window resizing
    • image resizing
    • XHR starting/ending
    • All of the above in an iframe or popup.

latency-benchmark's People

Contributors

deepak1556 avatar igauravsehrawat avatar jdarpinian avatar jmaher avatar nikai3d avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

latency-benchmark's Issues

compile in 32 bit mode

I found that this only runs in 64 bit linux. I have a local set of changes where I remove oculus and cross compile to 32 bit. Will probably have additional changes as I look into making this work on windows.

Support Python 3 at build time

We'll have to dump GYP though. Could use CMake but I might look into building a standalone version of Chrome's gn instead.

Chrome Canary โ€“ "Failed to find test pattern on screen"

Version 33.0.1706.0 Canary
OSX 10.9
Retina Display

Tests work fine in regular Chrome.

Fails with 500 error on http://localhost:5578/test?magicPattern=8a36052d02c5645bb97fc46e

Failed to find test pattern on screen. Ensure that your browser's zoom level is set to "100%", and the top-left corner of the window is visible. If you have multiple displays, try moving the browser window to the main display.

Single built-in display. I made sure browser zoom level was set to 100% and the top-left corner is visible.

Android support

Screenshot APIs need investigation. When the Oculus SDK for Android is released, the Oculus Latency Tester can be supported as well.

Should support secondary monitors too

On Windows we only screenshot one monitor at a time. The screenshot API should be extended to allow choosing which monitor to screenshot and we should check all monitors when searching for the browser.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.