Commit 371db7d5f2c249db2b14ea4e58daf0a21f7a127b

Authored by Geoffrey Challen
1 parent 1cbbad00

Script.

figures/.gitignore
  1 +/.virtualenv
1 2 *.pyc
... ...
figures/scripts/survey.py deleted
1   -#!/usr/bin/env python
2   -
3   -import os
4   -import numpy as np
5   -import matplotlib.cm as cm
6   -import json
7   -import operator
8   -from datetime import *
9   -from pylab import *
10   -import matplotlib.pyplot as plt
11   -import csv
12   -from matplotlib import rc
13   -
14   -#rc('font',**{'family':'serif','serif':['Times'], 'size': 8})
15   -#rc('text', usetex=True)
16   -
17   -all_ = []
18   -eff = []
19   -usg = []
20   -filename = '/home/anudipa/logcat/data/FormResponses.csv'
21   -with open(filename, 'rb') as csvfile:
22   - for line in csv.reader(csvfile, dialect="excel"):
23   - uCount = 0
24   - eCount = 0
25   - if 'Timestamp' in line[0]:
26   - continue
27   - for i in range(2,8):
28   - if 'No' in line[i]:
29   - continue
30   - elif 'Maybe' in line[i]:
31   - if i < 5:
32   - uCount += 0.5
33   - else:
34   - eCount += 0.5
35   - else:
36   - if i < 5:
37   - uCount += 1
38   - else:
39   - eCount += 1
40   -# print line[i]
41   - eff.append(eCount)
42   - usg.append(uCount)
43   -# print line[2:8], eff[-1], usg[-1]
44   -print len(eff),eff
45   -print len(usg),usg
46   -fig, ax = plt.subplots()
47   -#ax = fig.add_subplot(111)
48   -#fig.set_canvas(plt.gcf().canvas)
49   -left = 0.0
50   -for i in range(len(eff)):
51   - ax.bar(left, eff[i], width=1, color = 'b', linewidth = 0.25)
52   - ax.bar(left+1, usg[i], width=1, color ='r', linewidth = 0.25)
53   - left += 2.5
54   -#ax.legend([r'{\textbf {Efficiency Metric}}', r'{\textbf {Usage Metric}}'], loc='upper center')
55   -legend = ax.legend(['Efficiency Metric','Usage Metric'], loc='upper center')
56   -# Set the fontsize
57   -for label in legend.get_texts():
58   - label.set_fontsize('small')
59   -ax.set_yticks(ax.get_yticks()[1:])
60   -ax.tick_params(axis='both', which='both', top = 'off', right = 'off', bottom = 'off', labelleft='off', labelbottom='off')
61   -ax.set_xlim([0,(len(eff))])
62   -#ax.set_xlabel(r'{\textbf {Users}}')
63   -#ax.set_ylabel(r'{\textbf {Value}}')
64   -ax.set_xlabel('Users')
65   -ax.set_ylabel('Value')
66   -fig.set_size_inches(6.5,2.5)
67   -fig.subplots_adjust(left=0.06, right=0.99, top=0.95, bottom=0.2)
68   -fig.savefig('survey.pdf', dpi=300)
figures/scripts/FormResponses.csv renamed to figures/survey.csv
figures/survey.pdf
No preview for this file type
figures/survey.py 0 → 100755
  1 +#!/usr/bin/env python
  2 +
  3 +import argparse,numpy,os,sys,csv,re
  4 +
  5 +from matplotlib import rc
  6 +
  7 +rc('font',**{'family':'serif','serif':['Times'], 'size': 9})
  8 +rc('text', usetex=True)
  9 +
  10 +import matplotlib.pyplot as plt
  11 +
  12 +parser = argparse.ArgumentParser()
  13 +parser.add_argument('output', type=str, help='Output file.')
  14 +args = parser.parse_args()
  15 +
  16 +class Score(object):
  17 + def __init__(self, usage_score, efficiency_score):
  18 + self.usage_score, self.efficiency_score = usage_score, efficiency_score
  19 +
  20 +scores = []
  21 +
  22 +for line in csv.DictReader(open('survey.csv', 'rb'), dialect='excel'):
  23 + usage_keys = [key for key in line.keys() if re.search(r"""U\d""", key) != None]
  24 + efficiency_keys = [key for key in line.keys() if re.search(r"""E\d""", key) != None]
  25 +
  26 + usage_score = 1. * len([1 for key in usage_keys if line[key] == 'Yes.']) + \
  27 + 0.5 * len([1 for key in usage_keys if line[key] == 'Maybe.'])
  28 +
  29 + efficiency_score = 1. * len([1 for key in efficiency_keys if line[key] == 'Yes.']) + \
  30 + 0.5 * len([1 for key in efficiency_keys if line[key] == 'Maybe.'])
  31 +
  32 + scores.append(Score(usage_score, efficiency_score))
  33 +
  34 +scores.sort(key=lambda s: s.efficiency_score - s.usage_score)
  35 +
  36 +efficiency_wins = len([1 for s in scores if s.efficiency_score > s.usage_score])
  37 +usage_wins = len([1 for s in scores if s.usage_score > s.efficiency_score])
  38 +
  39 +fig = plt.figure()
  40 +ax = fig.add_subplot(111)
  41 +ax.bar(numpy.arange(len(scores)) - 0.3,
  42 + [s.usage_score for s in scores],
  43 + width=0.3, color='b', linewidth=0.,
  44 + label='{\\small \\textbf{Usage-Based Measure}: %d Wins}' % (usage_wins,))
  45 +ax.bar(numpy.arange(len(scores)),
  46 + [s.efficiency_score for s in scores],
  47 + width=0.3, color='r', linewidth=0.,
  48 + label='{\small \\textbf{Efficiency-Based Measure}: %d Wins}' % (efficiency_wins,))
  49 +ax.legend(loc='upper center', fontsize=9)
  50 +
  51 +ax.set_yticks(ax.get_yticks()[1:])
  52 +ax.xaxis.set_ticks(numpy.arange(len(scores)))
  53 +ax.xaxis.set_tick_params(which='both', direction='out')
  54 +ax.tick_params(axis='both', which='both', top='off', right='off', labelbottom='off')
  55 +ax.axis(xmin=-0.7,xmax=len(scores) + 0.7,
  56 + ymin=0,ymax=max([max(s.efficiency_score,s.usage_score) for s in scores]) + 0.5)
  57 +
  58 +for tick_location in ax.yaxis.get_majorticklocs():
  59 + ax.axhline(tick_location, color='black', ls=':', linewidth=0.1, zorder=-1)
  60 +
  61 +ax.set_xlabel('\\textbf{%d Responses}' % (len(scores)))
  62 +ax.set_ylabel('\\textbf{Score}')
  63 +fig.subplots_adjust(right=0.99,top=0.98,left=0.08,bottom=0.10)
  64 +
  65 +fig.set_size_inches(6.5,2.5)
  66 +
  67 +fig.savefig('survey.pdf')
... ...
results.tex
... ... @@ -2,8 +2,37 @@
2 2 \label{sec-results}
3 3  
4 4 To examine the potential components of a value measure further, we utilize a
5   -large dataset of energy consumption measurements collected on the \PhoneLab{}
6   -testbed.
  5 +large dataset of energy consumption measurements collected by an IRB-approved
  6 +experiment run on the \PhoneLab{} testbed. \PhoneLab{} is a public smartphone
  7 +platform testbed located at the University at
  8 +Buffalo~\cite{phonelab-sensemine13}. 220~students, faculty, and staff carry
  9 +instrumented Android Nexus~5 smartphones and receiv subsidized service in
  10 +return for willingness to participate in experiments. \PhoneLab{} provides
  11 +access to a representative group of participants balanced between genders and
  12 +across a wide variety of age brackets, making our results more
  13 +representative.
  14 +
  15 +Understanding fine-grained energy consumption dynamics such as what apps ran
  16 +for how long and how much energy each interactive session consumed while
  17 +running in the background required more information than Android normally
  18 +exposes to apps. In addition, to explore our content deliver metric we also
  19 +wanted to capture information about app usage---including foreground and
  20 +background time and use of the display and audio interface---that was not
  21 +possible to measure on unmodified Android devices.
  22 +
  23 +So to collect our dataset we took advantage of \PhoneLab{}'s ability to
  24 +modify the Android platform itself. Our modification augmented the platform
  25 +to collect the fine-grained energy consumption and app behavior information
  26 +required to understand smartphone energy consumption. We instrumented the
  27 +\texttt{SurfaceFlinger} and \texttt{AudioFlinger} Android platform components
  28 +to record usage of the screen and audio, and altered the Activity Services
  29 +package to record energy consumption at each app transition, allowing energy
  30 +consumption by components such as the screen to be accurately attributed to
  31 +the foreground app, a feature that Android's internal battery monitoring
  32 +component (the Fuel Gauge) lacks. The dataset of 67~GB of compressed log
  33 +files represents \num{6806} user days during which \num{1328}~apps were
  34 +started \num{277785} times and used for a total of \num{15224} hours of
  35 +active use.
7 36  
8 37 At \PhoneLab{} based on the analysis of data collected about foreground and
9 38 background energy consumption by applications running on the participants'
... ... @@ -69,7 +98,7 @@ users spend actively interacting with them.
69 98 \input{./figures/tables/tableCONTENT.tex}
70 99  
71 100  
72   -\begin{figure}[t]
  101 +\begin{figure*}[t]
73 102 \centering
74 103 \includegraphics[width=\textwidth]{./figures/survey.pdf}
75 104  
... ... @@ -78,7 +107,7 @@ users spend actively interacting with them.
78 107  
79 108 \label{fig-survey}
80 109  
81   -\end{figure}
  110 +\end{figure*}
82 111  
83 112 To evaluate our efficiency metric against usage based metric, we sent out a
84 113 survey to our participants asking to answer if they would remove the 3 top
... ...