Giter VIP home page Giter VIP logo

mobster's Introduction

Mobster

Mobster is a tool that can help you get deeper understanding into the performance of web applications on mobile devices and desktop.

It is built off of the WebKit remote debugging protocol and can leverage real devices to extract data that can help you to measure and improve your mobile performance. Below are key features of Mobster.

Highlights :

  • Non-intrusive performance profiling of mobile web apps
  • Automatically detect regressions in page performance and memory usage
  • Insights into native browser events
  • Continuous integration with release process

Mobster provides a simple way for developers to record crucial web performance data on mobile devices while running automated flows. Using Mobster, developers can test the performance of their site on a variety of devices and easily detect any performance regressions. You can gather following metrics from real devices using Mobster:

  • Page timings, network resource sizes and timings
  • Internal browser / DOM events like GC, paints, and CSS recalculates
  • HTTP waterfalls
  • Memory Utilization

Getting Started

Prerequisites

  1. Check out Mobster code:

    git clone https://github.com/linkedin/mobster.git
  2. If you haven't already, install Python. You will need Python 2.6.6 or newer (but not Python 3).

    To find the version of Python installed:

    python --version
  3. Install PIP.

  4. Install the necessary Python libraries using PIP.

    cd mobster; pip install -r requirements.txt

Android-Specific Prerequisites

  1. You must have an Android device with Chrome installed. This will require Android 4.0 ICS or newer. Make sure you are running a recent version of the Chrome app.

  2. Install the Android SDK with packages corresponding to the version of Android your device is running.

  3. Enable USB debugging on the device (Settings -> Developer Options -> USB Debugging, see your device manual for details)

  4. In the Chrome settings, enable USB Debugging (Advanced -> Developer Tools -> Enable USB Web Debugging)

Run Mobster with an Android Device

  1. Execute the command below under the Android SDK folder:

     ./<Android-SDK-Folder>/platform-tools/adb forward tcp:9222 localabstract:chrome_devtools_remote
     
  2. Open Chrome on the device if it isn't already open. Note that Mobster will clear cookies and other browsing data. The tab currently being viewed will be used by Mobster to navigate to webpages.

  3. Run the main Mobster script with a sample flow in your Mobster home directory. This step is the same whether you are running Mobster with an Android device or desktop browser.

    ./bin/mobster.py -t bin/sampleinput/sample.json -p -b

    Mobster reports will be generated in the MOBSTER_HOME/report folder if no folder is specified. Run mobster.py with the "-h" option to learn more about command-line options. To learn how to make your own flows, look at the scripts in the bin/sampleinput/ directory.

Run Mobster with Desktop Chrome

  1. Close all Chrome windows. Then, start desktop Chrome with remote debugging enabled and remote debugging port set to 9222:

    Mac OS:

     open -a "Google Chrome" --args --remote-debugging-port=9222 --enable-memory-info

    Red Hat Linux (assuming google-chrome is in your PATH):

     google-chrome --remote-debugging-port=9222 

    Windows (assuming chrome.exe is in your PATH):

     chrome --remote-debugging-port=9222 

    This should open a Chrome browser window. To test if remote debugging is working, navigate to localhost:9222 in your browser and verify that a page is displayed with the title "Inspectable Pages". If not, make sure that no Chrome windows are open and then try this command again.

  2. Run the main Mobster script with a sample flow in your Mobster home directory. This step is the same whether you are running Mobster with an Android device or desktop browser.

    ./bin/mobster.py -t bin/sampleinput/sample.json -p -b

    Mobster reports will be generated in the MOBSTER_HOME/report folder if no folder is specified. Run mobster.py with the "-h" option to learn more about command-line options. To learn how to make your own flows, look at the scripts in the bin/sampleinput/ directory.

Important Note: If you use Chrome as your web browser normally, it will be annoying to run Mobster with Chrome because Mobster by default uses one of the currently open tab(s) for testing and also clears cookies, etc. This means that, at the end of a test, one of your open tab(s) will be showing the final web page from your test and you will be logged out of all websites. An easy way to avoid this problem is to run Mobster with Chromium or Chrome Canary so your normal browsing is not affected. Chrome, Chromium, and Chrome Canary can all be installed side-by-side.

Contribution

Mobster is a new project, and we are interested in building the community; we would welcome any thoughts or patches. You can reach us on the Apache mailing lists.

The Mobster code is available from git mirror:

git clone https://github.com/linkedin/mobster

Key Components -

  • WebKit Communicator - Handles low-level sending and receiving of messages. Provides a way to specify callbacks
  • Remote WebKit Client - Uses WebKitCommunicator to provide an API for sending commands to the browser and querying for data (e.g. tell the browser to navigate to a URL, get CSS profiling results)
  • FlowProfiler - Interprets the flow file specified by the user and uses WebKitClient's API to perform the actions from the flow, while recording the results

mobster's People

Contributors

armanhb avatar haricharankr avatar hariramachandra avatar riteshmaheshwari 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

Watchers

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

mobster's Issues

Add Total Page Weight to mobster report

What : We need to provide the total page weight metrics in the Mobster performance report as part of the Page Metrics table

Why : It would be useful for developers to measure the total bytes download (a.k.a. page weight ) for each page. This will help them to understand the potential implication of their feature enhancements on the performance of their pages

How : We already have the size of each component in a page under waterfall . We need to add a functionality in the visualization/reporting module to summarize the size of all the components downloaded in a page to represent the total page weight.

Excessive WARNING Messages regarding HeapSize

With the latest changes we have introduced excessive warning message during the execution of Mobster in the console. Please supress these warning messages under normal mode and print them to console only in DEBUG mode.

Sample from Console output

2013-01-09 22:53:26,297 WARNING totalHeapSize
2013-01-09 22:53:26,297 WARNING totalHeapSize
2013-01-09 22:53:26,318 WARNING totalHeapSize

Need an easy way to add support for new remote debugging commands

Right now, if you want to add to mobster the capability to use a new remote debugging command, you have to add a method (or multiple methods) which have unique behavior. We need a more general way of representing commands so additions in the future are simple.

Add Total Page Weight Metrics to the mobster report

What : We need to provide the total page weight metrics in the Mobster performance report as part of the Page Metrics table

Why : It would be useful for developers to measure the total bytes download (a.k.a. page weight ) for each page. This will help them to understand the potential implication of their feature enhancements on the performance of their pages

How : We already have the size of each component in a page under waterfall . We need to add a functionality in the visualization/reporting module to summarize the size of all the components downloaded in a page to represent the total page weight.

Add more flow samples

We need some examples which involve multiple pages and actions on pages (e.g. clicking button, filling in form, etc.)

Add testing of core functionality

We need testing for the core functionality. One way to make this relatively painless would be to use phantomjs, though this needs to be investigated.

Re-Organize Page Metrics Table

What : We need to re-organize the contents of page metrics table based on page timing and non-page timing metrics

Why : Its convenient to have metrics based on timing under one table as it makes it easy to read the report and helps in automated comparison between mobster reports

How : I propose we have two tables under page metrics (1) Page Timing Metrics (2) Page Metrics

(1) Page Timing Metrics table :

DOMContent Load Time [ available]
OnLoad Time [ available]
Total CSS Time [ available]

(2) Page Metrics Table :

Number of Style Recalculates [ available ]
Number of Paints [ available ]
Total Page Weight [ TBD ] - details in #11
Download Time [TBD ] - details in
Total number of Images [ TBD] - no tickets opened yet

onLoad times are incorrect sometimes

mobster-waterfall-bug

See the attachment. I think this is a bug with chromium, but if they are not able to solve it, we need a way to detect and resolve this in mobster. One potential approach is to look at the start time of the page requested and ignore stuff before it (in the har/waterfall)

Reduce timeout?

Right now mobster waits for 5 minutes (300 s) in utils.wait_until(). Its a loooong time. Lets make it something more reasonable.

Allow port number to be configurable

Right now the port number to communicate to chrome is hard-coded to be 9222. At some point, we might want this to be configurable through command line.

(low priority though)

Missing 'timing' information in some messages received from webkit

Some messages like these do not have 'timing' information, thus causing mobster to fail with an exception. Example callback and message (using print callback, message):

<bound method NetworkEventHandler.process_event of <linkedin.mobster.har.network.NetworkEventHandler object at 0xa82310>> {u'params': {u'timestamp': 1357698104.2517059, u'frameId': u'77.6', u'requestId': u'77.133', u'loaderId': u'77.12', u'type': u'Document', u'response': {u'status': 0, u'mimeType': u'text/html', u'url': u'data:text/html,chromewebdata', u'statusText': u'', u'connectionId': 0, u'connectionReused': False, u'headers': {}, u'fromDiskCache': False}}, u'method': u'Network.responseReceived'}

We could fix it by checking for this condition in har/network.py. Can you recheck if this is a valid fix? Are we missing any info by doing this:

git diff src/linkedin/mobster/har/network.py

diff --git a/src/linkedin/mobster/har/network.py b/src/linkedin/mobster/har/network.py
index 3f7dfd1..10c1e99 100644
--- a/src/linkedin/mobster/har/network.py
+++ b/src/linkedin/mobster/har/network.py
@@ -170,6 +170,9 @@ class NetworkEventHandler(object):
 
     # timings are not included for about: url's
     if not self._requests[request_id]['url'].startswith('about:'):
+      if not 'timing' in params['response']:
+        print "No timing"
+        return
       provided_timings = params['response']['timing']
 
       self._request_start_times[request_id] = provided_timings['requestTime']
@@ -230,4 +233,4 @@ class NetworkEventHandler(object):
     if start == -1 and end == -1:
       return -1
     else:
-      return int(end - start)
\ No newline at end of file
+      return int(end - start)

Mobster fails sometimes when running against a desktop chrome

I ran mobster against my desktop. My flow is to go to linkedin, login and go the home page again. This causes mobster to throw the following exceptions sometimes (unfortunately, not everytime):

Exception in thread WebSocketClient:
Traceback (most recent call last):
File "/usr/lib64/python2.6/threading.py", line 532, in __bootstrap_inner
self.run()
File "/usr/lib64/python2.6/threading.py", line 484, in run
self.__target(_self.__args, *_self.__kwargs)
File "/usr/local/linkedin/lib/python2.6/site-packages/ws4py/websocket.py", line 230, in run
if not process(bytes):
File "/usr/local/linkedin/lib/python2.6/site-packages/ws4py/websocket.py", line 283, in process
self.received_message(s.message)
File "/home/rmaheshw/git/mobster/src/linkedin/mobster/webkitcommunicator.py", line 61, in received_message
for callback in self._domain_callbacks[response['method'].split('.')[0]].itervalues():
RuntimeError: dictionary changed size during iteration

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.