-
Notifications
You must be signed in to change notification settings - Fork 3
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
Optimization + Threaded #19
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I add small comments but it's great work overall Nigel, congrats! 🎉
pytracer/core/parser.py
Outdated
@@ -130,9 +135,9 @@ def merge_dict(self, args): | |||
def _merge(self, values, attr, do_not_check=False): | |||
attrs = None | |||
if isinstance(attr, str): | |||
attrs = [value[attr] for value in values] | |||
attrs = [*map(lambda value: value[attr], values)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rewriting is not faster. Here are my tests:
(10:41) ~:$ python3 -m timeit -n 1000000 -r 5 -v "values = [ {'a':i.upper()} for i in 'abcde' ]; attr = 'a'; attrs = [value[attr] for value in values]"
raw times: 866 msec, 881 msec, 863 msec, 934 msec, 881 msec
1000000 loops, best of 5: 863 nsec per loop
(10:41) ~:$ python3 -m timeit -n 1000000 -r 5 -v "values = [ {'a':i.upper()} for i in 'abcde' ]; attr = 'a'; attrs = [*map(lambda value : value[attr], values)]"
raw times: 1.09 sec, 1.1 sec, 1.09 sec, 1.09 sec, 1.08 sec
Where have you find this optimization?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just in general map is faster than for loops. You're right though, list comprehension are faster than map, if it requires a lambda. I will revert the map with lambda back to list comprehension!
pytracer/core/parser.py
Outdated
print("STARTING") | ||
start = time.time() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an global variable like enable_timer
to turn on/off the timer.
pytracer/core/parser.py
Outdated
# pr = cProfile.Profile() | ||
# pr.enable() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the comments.
pytracer/core/parser.py
Outdated
# pr.disable() | ||
# pr.print_stats(sort="cumtime") | ||
# pr.dump_stats("output.prof") | ||
# | ||
# stream = open('output.txt', 'w') | ||
# stats = pstats.Stats('output.prof', stream=stream) | ||
# stats.sort_stats('cumtime') | ||
# stats.print_stats() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the comments.
pytracer/core/parser.py
Outdated
end = time.time() | ||
print(f"DONE in time: {end - start}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an global variable like enable_timer to turn on/off the timer.
pytracer/gui/callbacks.py
Outdated
# e1 = time.perf_counter() | ||
# print("pgc.data.filter x,y", e1-b1) | ||
|
||
b2 = time.perf_counter() | ||
# b2 = time.perf_counter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comments.
pytracer/gui/callbacks.py
Outdated
# e2 = time.perf_counter() | ||
# print("extra_value", e2-b2) | ||
|
||
b3 = time.perf_counter() | ||
# b3 = time.perf_counter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comments
pytracer/gui/callbacks.py
Outdated
# e3 = time.perf_counter() | ||
# print("scattergl", b3-e3) | ||
|
||
e = time.perf_counter() | ||
print("get_scatter_timeline", e-b) | ||
# e = time.perf_counter() | ||
# print("get_scatter_timeline", e-b) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comments.
pytracer/gui/callbacks.py
Outdated
# e = time.perf_counter() | ||
# print("add_scatter", e-b) | ||
|
||
# @cache.memoize(timeout=TIMEOUT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comments
@yohanchatelain is it good to be merged now? |
Optimization Changes