Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements on precision of Throughput #183

Merged
merged 2 commits into from
Aug 29, 2017
Merged

Conversation

ioef
Copy link
Contributor

@ioef ioef commented Aug 26, 2017

Improvements on precision of Throughput Measuring Mechanism.

  • Usage of timeit.default_timer() in tlstests.py instead of time.time().
  • Measuring of the size for travelling data with the sys.getsizeof().

This change is Reviewable

Improvements on precision of Throughput Measuring Mechanism. 
- Usage of timeit.default_timer() in tlstests.py instead of time.time(). 
- Measuring of the size for travelling data with the sys.getsizeof().
tests/tlstest.py Outdated
connection.write(b"hello"*10000)
h = connection.read(min=50000, max=50000)
stopTime = time.clock()
stopTime = timeit.default_timer()
sizeofdata = sys.getsizeof(h)*2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sys.getsizeof() returns the size of allocated memory for the object, not the length of the string (actually transferred data).

See:

>>> import sys
>>> sys.getsizeof(bytearray(0))
48
>>> sys.getsizeof(bytearray(12))
61

len() is entirely sufficient here

Copy link
Contributor Author

@ioef ioef Aug 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or differently defined and Interpreted:
sys.getsizeof() returns the size of an object in bytes. The object can be any type of object. All built-in objects will return correct results, but this does not have to hold true for third-party extensions as it is implementation specific.

Whether len() returns the length (the number of items) of an object.

Therefore it seemed more accurate to measure the total size of the actual bytes instead of the number of the elements. Hence I'm not quite sure if len() is equally sufficient, which may seems like a good choice at first sight.

>>> h = b'hello'*10000
>>> len(h)
50000
>>> sys.getsizeof(h)
50037

Unless we are sure that this 37 bytes 'overhead' is never transmitted, I can agree with you.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the "overhead" isn't transmitted - the socket transmits bytes, not objects

Usage of timeit.default_timer() in tlstests.py. Measuring of the size for travelling data with the len()
@tomato42 tomato42 merged commit f296aeb into tlsfuzzer:master Aug 29, 2017
@tomato42
Copy link
Member

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants