Skip to content

Commit

Permalink
Merge eb23503 into 9d84998
Browse files Browse the repository at this point in the history
  • Loading branch information
NickPancakes committed Jul 17, 2018
2 parents 9d84998 + eb23503 commit 35d6dcd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ matrix:
allow_failures:
- python: "nightly"
- python: "3.2"
- python: "2.6"
python:
- "2.6"
- "2.7"
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ easily produced using the public methods of ``HarParser`` and ``HarPage``::
load_time = har_page.get_load_time(content_type='image.*', status_code='2.*')

# Get the TOTAL load time for all images in the 2XX status code range #
load_time = har_page.get_load_time(content_type='image.*', status_code='2.*', async=False)
load_time = har_page.get_load_time(content_type='image.*', status_code='2.*', asynchronous=False)

This could potentially be out of date, so please check out the sphinx docs.

Expand Down
14 changes: 8 additions & 6 deletions haralyzer/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def _get_asset_load(self, asset_type):
# TODO - should we return a slightly fake total load time to
# accomodate HAR data that cannot understand things like JS
# rendering or just throw a warning?
#return self.get_load_time(request_type='.*',content_type='.*', status_code='.*', async=False)
#return self.get_load_time(request_type='.*',content_type='.*', status_code='.*', asynchronous=False)
else:
return self.get_load_time(
content_type=self.asset_types[asset_type])
Expand Down Expand Up @@ -341,12 +341,12 @@ def filter_entries(self, request_type=None, content_type=None,
return results

def get_load_time(self, request_type=None, content_type=None,
status_code=None, async=True):
status_code=None, asynchronous=True, **kwargs):
"""
This method can return the TOTAL load time for the assets or the ACTUAL
load time, the difference being that the actual load time takes
asyncronys transactions into account. So, if you want the total load
time, set async=False.
asynchronous transactions into account. So, if you want the total load
time, set asynchronous=False.
EXAMPLE:
Expand All @@ -355,13 +355,15 @@ def get_load_time(self, request_type=None, content_type=None,
them at the same time.
self.get_load_time(content_types=['image']) (returns 2)
self.get_load_time(content_types=['image'], async=False) (returns 4)
self.get_load_time(content_types=['image'], asynchronous=False) (returns 4)
"""
entries = self.filter_entries(request_type=request_type,
content_type=content_type,
status_code=status_code)
if "async" in kwargs:
asynchronous = kwargs['async']

if not async:
if not asynchronous:
time = 0
for entry in entries:
time += entry['time']
Expand Down
2 changes: 1 addition & 1 deletion tests/test_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_get_load_time(har_data):
page = HarPage(PAGE_ID, har_data=init_data)

assert page.get_load_time(request_type='GET') == 463
assert page.get_load_time(request_type='GET', async=False) == 843
assert page.get_load_time(request_type='GET', asynchronous=False) == 843
assert page.get_load_time(content_type='image.*') == 304
assert page.get_load_time(status_code='2.*') == 463

Expand Down

0 comments on commit 35d6dcd

Please sign in to comment.