Skip to content

Instantly share code, notes, and snippets.

@Uberi
Created March 24, 2016 16:43
Show Gist options
  • Save Uberi/c626e601b12709b77cad to your computer and use it in GitHub Desktop.
Save Uberi/c626e601b12709b77cad to your computer and use it in GitHub Desktop.
pref analysis
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 35,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Populating the interactive namespace from numpy and matplotlib\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING: pylab import has clobbered these variables: ['Figure', 'Annotation']\n",
"`%matplotlib` prevents importing * from pylab and numpy\n"
]
}
],
"source": [
"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",
"from plotly.graph_objs import *\n",
"\n",
"from moztelemetry import get_pings, get_pings_properties, get_one_ping_per_client, get_clients_history, get_records\n",
"\n",
"%pylab inline"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"96"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sc.defaultParallelism"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"pings = get_pings(sc, app=\"Firefox\", channel=\"nightly\", submission_date=(\"20160323\", \"20160323\"), fraction=1)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"subset = get_pings_properties(pings, [\"clientId\",\n",
" \"environment/settings/userPrefs/layers.offmainthreadcomposition.enabled\"])"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"subset = get_one_ping_per_client(subset)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"31354"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"subset.count()"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"counts = subset.map(lambda p: p[\"environment/settings/userPrefs/layers.offmainthreadcomposition.enabled\"]).countByValue()"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~mozilla/412.embed\" height=\"525\" width=\"100%\"></iframe>"
],
"text/plain": [
"<plotly.tools.PlotlyDisplay object>"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"py.iplot({\n",
" 'data': [{'labels': ['Off-main-thread composition enabled', 'Off-main-thread composition disabled', 'Other'],\n",
" 'values': [counts[None], counts[False], sum(counts.values()) - counts[None] - counts[False]],\n",
" 'type': 'pie'}],\n",
" 'layout': {'title': 'Off-main-thread composition setting'}\n",
"}, filename=\"pie-chart-plot\", validate=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The link might not show up on GitHub Gists, so here's a [direct link](https://plot.ly/412/~mozilla/)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.11"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
# coding: utf-8
# In[35]:
import ujson as json
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import plotly.plotly as py
from plotly.graph_objs import *
from moztelemetry import get_pings, get_pings_properties, get_one_ping_per_client, get_clients_history, get_records
get_ipython().magic(u'pylab inline')
# In[2]:
sc.defaultParallelism
# In[20]:
pings = get_pings(sc, app="Firefox", channel="nightly", submission_date=("20160323", "20160323"), fraction=1)
# In[21]:
subset = get_pings_properties(pings, ["clientId",
"environment/settings/userPrefs/layers.offmainthreadcomposition.enabled"])
# In[22]:
subset = get_one_ping_per_client(subset)
# In[23]:
subset.count()
# In[29]:
counts = subset.map(lambda p: p["environment/settings/userPrefs/layers.offmainthreadcomposition.enabled"]).countByValue()
# In[43]:
py.iplot({
'data': [{'labels': ['Off-main-thread composition enabled', 'Off-main-thread composition disabled', 'Other'],
'values': [counts[None], counts[False], sum(counts.values()) - counts[None] - counts[False]],
'type': 'pie'}],
'layout': {'title': 'Off-main-thread composition setting'}
}, filename="pie-chart-plot", validate=False)
# The link might not show up on GitHub Gists, so here's a [direct link](https://plot.ly/412/~mozilla/).
# In[ ]:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment