speedtrap v0.0.2
Tool for opening your adaptive project in a mobile web view and gathering it's metrics using browser-perf
Setup
1. Install Selenium
brew install selenium-server-standalone2. Install ChromeDriver
Download the binary here: https://sites.google.com/a/chromium.org/chromedriver/downloads
Move it to somewhere in your path so Selenium can find it (eg. /usr/bin)
3. Install the tool
git clone git@github.com:mobify/speedtrap.git
cd speedtrap
npm install
npm linkUsage
Browser Perf
Performs selenium tests on your project and logs out performance metrics.
- Run Selenium using
selenium-server-standalone. - Run
grunt previewand copy the preview path URL to the tool. - Run
speedtrap:
speedtrap browser-perf --url "<preview-url>"Perfjankie
This command can be used to log performance stats to a CouchDB dashboard. This can be useful to run on a per-commit basis to track performance over time. It is a wrapper for perfjankie (https://github.com/axemclion/perfjankie).
Run grunt preview and copy the preview path URL to the tool.
speedtrap perfjankie -u "<url>" -slug "<project-slug>" -n "<project-name>"Notes:
- The URL, project name and slug need to be surrounded by
""so that special characters aren't interpreted by bash - The "Site Url" needs to be complete (start with
http://orhttps://) - The
SPEEDTRAP_DB_SERVER,SPEEDTRAP_DB_USERNAMEandSPEEDTRAP_DB_PASSWORDenvironment variables need to be set in order for test data to be posted to the CloudDB site.
Troubleshooting:
- If your dashboard breaks, your
speedtrapmay be linked to a version ofperfjankiewithout the web files built. You will need to go into the linkedperfjankieproject and rungrunt distto generate the html/css/js for the dashboard. The site will then need to have the new files pushed to it (see perfjankieupdateSiteoption).
Project Integration
Perfjankie was designed to be integrated into project CI environments to track performance over time.
Steps:
- Add environment variables for
SPEEDTRAP_DB_SERVER,SPEEDTRAP_DB_USERNAMEandSPEEDTRAP_DB_PASSWORDon CircleCI. - Copy the
scripts/speedtrap-ci.shscript to your project. - Update the fields at the top of the script:
SPEEDTRAP_URL,SPEEDTRAP_SLUG, andSPEEDTRAP_NAME. - Call the
speedtrap-ci.shscript in your circle.yml (recommended spot is with in thedeploymentsection so tests can be run when merging to a specific branch vs. on every commit):
deployment:
send_statistics:
branch: [develop]
commands:
- <path_to_script>/speedtrap-ci.sh
# OR
# - <path_to_script>/speedtrap-ci.sh:
# pwd: <path_to_adaptive_project_root>
# If your adaptive project isn't at the root of your repoDevelopment
Tests
grunt testLinting
grunt lintCode Coverage
grunt coverageReport viewable through coverage/lcov-report/index.html