Skip to content

Commit

Permalink
Merge pull request #7 from mrname/numpy
Browse files Browse the repository at this point in the history
Numpy
  • Loading branch information
mrname committed Jul 9, 2015
2 parents fa500f8 + ebfc71b commit aab7fc6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 23 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ language: python
matrix:
fast_finish: true
allow_failures:
- python: "3.2"
- python: "nightly"
python:
- "2.6"
Expand Down
5 changes: 0 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,3 @@ already filtered the entries you want to know about::
With this, you can examine the timeline for any number of assets. Since the key is a ``datetime``
object, this is a heavy operation. We could always change this in the future, but for now,
limit the assets you give this method to only what you need to examine.

Known Issues
------------

The `haralyzer` module is currently not compatible with python 3.2. This is due to the fact that it leverages the `statistics` backport, which is not compatible with python 3.2. We will be working on a fix as soon as possible, feel free to submit a pull request in the meantime.
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
# built documents.
#
# The short X.Y version.
version = '1.2'
version = '1.3'
# The full version, including alpha/beta/rc tags.
release = '1.2.2'
release = '1.3.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
21 changes: 11 additions & 10 deletions haralyzer/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import dateutil
# I know this import is stupid, but I cannot use dateutil.parser without it
from dateutil import parser
import numpy
assert parser
import re
import statistics

from haralyzer.compat import iteritems

Expand Down Expand Up @@ -214,7 +214,8 @@ def get_stdev(self, asset_type):
else:
load_times = self.get_load_times(asset_type)

return round(statistics.stdev(load_times), self.decimal_precision)
return round(numpy.std(load_times, ddof=1),
self.decimal_precision)

@property
def pages(self):
Expand Down Expand Up @@ -247,15 +248,15 @@ def time_to_first_byte(self):
ttfb = []
for page in self.pages:
ttfb.append(page.time_to_first_byte)
return round(statistics.mean(ttfb), self.decimal_precision)
return round(numpy.mean(ttfb), self.decimal_precision)

@cached_property
def page_load_time(self):
"""
The average total load time for all runs (not weighted).
"""
load_times = self.get_load_times('page')
return round(statistics.mean(load_times), self.decimal_precision)
return round(numpy.mean(load_times), self.decimal_precision)

@cached_property
def js_load_time(self):
Expand All @@ -266,47 +267,47 @@ def js_load_time(self):
total load time or the browser load time
"""
load_times = self.get_load_times('js')
return round(statistics.mean(load_times), self.decimal_precision)
return round(numpy.mean(load_times), self.decimal_precision)

@cached_property
def css_load_time(self):
"""
Returns aggregate css load time for all pages.
"""
load_times = self.get_load_times('css')
return round(statistics.mean(load_times), self.decimal_precision)
return round(numpy.mean(load_times), self.decimal_precision)

@cached_property
def image_load_time(self):
"""
Returns aggregate image load time for all pages.
"""
load_times = self.get_load_times('image')
return round(statistics.mean(load_times), self.decimal_precision)
return round(numpy.mean(load_times), self.decimal_precision)

@cached_property
def html_load_time(self):
"""
Returns aggregate html load time for all pages.
"""
load_times = self.get_load_times('html')
return round(statistics.mean(load_times), self.decimal_precision)
return round(numpy.mean(load_times), self.decimal_precision)

@cached_property
def audio_load_time(self):
"""
Returns aggregate audio load time for all pages.
"""
load_times = self.get_load_times('audio')
return round(statistics.mean(load_times), self.decimal_precision)
return round(numpy.mean(load_times), self.decimal_precision)

@cached_property
def video_load_time(self):
"""
Returns aggregate video load time for all pages.
"""
load_times = self.get_load_times('video')
return round(statistics.mean(load_times), self.decimal_precision)
return round(numpy.mean(load_times), self.decimal_precision)


class HarPage(object):
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
statistics; python_version <= '2.7'
cached-property
numpy
python-dateutil
pytest-cov
python-coveralls
cached-property
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@


install_reqs = ['cached-property',
'python-dateutil',
'statistics', ]
'numpy',
'python-dateutil', ]

readme = open('README.rst').read()

setup(
name='haralyzer',
version='1.2.2',
version='1.3',
description='A python framework for getting useful stuff out of HAR files',
long_description=readme,
author='Justin Crown',
Expand Down

0 comments on commit aab7fc6

Please sign in to comment.