improving the performance of Rails web Applications
Web performance testing with web driver
1. Web Performance Testing
with WebDriver
An integrated approach
Michael Klepikov
Make the Web Faster Team, Google
developers.google.com/speed
webpagetest.org
2. ■ +1s load => -7% conversion rate
■ Just better user experience
■ Mobile exacerbates slowness
■ 46% mobile users abandon after 10s
Why is it important?
3. ■ WebPageTest.org
■ Waterfall chart
■ Simulated latency
■ Many iterations for statistical validity
Page Load performance
5. Test Systems Integration
■ WebPageTest is a separate system
■ Everyone has a custom toolchain
■ Hard to integrate
■ Not a seamless developer experience
6. ■ Standard WD API:
○ Session Capabilities
○ Logging
■ Easy to enable in existing tests
■ Fits well into existing toolchains
Build it into WebDriver itself
7. ■ LoggingPreferences
in WD capabilities
// Ask Chrome to collect "performance" log
DesiredCapabilities caps = DesiredCapabilities.chrome();
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable("performance", Level.INFO);
caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
driver = new RemoteWebDriver("http://localhost:9515", caps);
WD API: Create Driver
8. ■ Plain functional test, nothing special
■ Free magic for developers!
■ Pro tip: console.time()+timeEnd(), timeStamp()
driver.get("http://www.google.com/");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("GTAC 2013");
element.submit();
WD API: Run Test
9. ■ Not part of test per se, inject:
○ In tearDown()
○ Override WebDriver.quit()
○ WebDriver HTTP-JSON proxy
log = driver.manage().logs().get("performance").getAll();
for (LogEntry entry : log) {
// WebDriver LogEntry message is a JSON string
JSONObject m = new JSONObject(entry.getMessage());
... m.getString("webview") ... // Originating WebView id
... m.getJSONObject("message") ... // Raw DevTools event
WD API: Get Performance Log
12. ■ No WD within instrumented intervals
■ Aggregate over multiple iterations!
■ Run frontend in maximum isolation
○ Mock/stub/fake backends
■ Use WebPageReplay
Stable Repeatable Results