Skip to content

Instantly share code, notes, and snippets.

@vitillo
Created March 30, 2015 10:55
Show Gist options
  • Save vitillo/ec7a4703b766b2e80aac to your computer and use it in GitHub Desktop.
Save vitillo/ec7a4703b766b2e80aac to your computer and use it in GitHub Desktop.
Bug 1148473
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "",
"signature": "sha256:b4c6706647a87fe218036df60de368ef553890f0cc1851abf1e57b7f35f38942"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"import ujson as json\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"import numpy as np\n",
"import plotly.plotly as py\n",
"\n",
"from moztelemetry.spark import get_pings, get_pings_properties\n",
"from moztelemetry.histogram import Histogram\n",
"\n",
"%pylab inline"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Populating the interactive namespace from numpy and matplotlib\n"
]
}
],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"sc.defaultParallelism"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 2,
"text": [
"16"
]
}
],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"pings = get_pings(sc, \"Firefox\", \"nightly\", \"*\", (\"20150317\", \"20150324\"), \"20150325\", 1)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 82
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"props = get_pings_properties(pings, [\"threadHangStats\"])\n",
"props.count()"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 83,
"text": [
"83535"
]
}
],
"prompt_number": 83
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def add_activity(ping):\n",
" threadHangs = ping[\"threadHangStats\"]\n",
" gecko = None\n",
"\n",
" for thread in threadHangs:\n",
" if thread[\"name\"] == \"Gecko\":\n",
" return pd.Series(thread[\"activity\"][\"values\"])\n",
"\n",
" return None"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 84
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"activity = props.map(add_activity).filter(lambda a: a is not None).reduce(lambda x, y: x.add(y, fill_value=0))"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 85
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"activity.index = activity.index.astype(int)\n",
"activity = activity.sort_index()"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 95
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"orig = activity[activity.index >= 511].sum()\n",
"new = (activity.ix[127] + activity.ix[255])"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 98
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"print new, orig, new/orig"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"299816266.0 13432683.0 22.3199092839\n"
]
}
],
"prompt_number": 101
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment