Skip to content
New issue

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

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

Already on GitHub? # to your account

Updates to properly handle @profile decorators for CPU time attribution #637

Merged
merged 7 commits into from
Jul 14, 2023

Conversation

emeryberger
Copy link
Member

Fixes to restore the @profile decorator to its intended semantics (if any code has a @profile decorator, only profile that code).

@emeryberger
Copy link
Member Author

@sternj We could use a test for @profile to avoid future regressions.

@emeryberger emeryberger requested a review from sternj July 8, 2023 22:25
@emeryberger emeryberger changed the title Updates to properly handle @profile decorators. Updates to properly handle @profile decorators for CPU time attribution Jul 13, 2023
@sternj
Copy link
Collaborator

sternj commented Jul 13, 2023

This seems like it does the right thing to me, I'm going to put in a test that tests the statement "Given an @Profile decorator on a single function, there is precisely one function in the 'functions' field of the output and it has the name of that function"

@@ -0,0 +1,65 @@
#!/usr/bin/env python3
import numpy as np

Check notice

Code scanning / CodeQL

Unused import

Import of 'np' is not used.
y = 1
# w, v = LA.eig(np.diag(arr)) # (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)))
x = [i*i for i in range(0,100000)][99999]
y1 = [i*i for i in range(0,200000)][199999]

Check notice

Code scanning / CodeQL

Unused local variable

Variable y1 is not used.
# w, v = LA.eig(np.diag(arr)) # (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)))
x = [i*i for i in range(0,100000)][99999]
y1 = [i*i for i in range(0,200000)][199999]
z1 = [i for i in range(0,300000)][299999]

Check notice

Code scanning / CodeQL

Unused local variable

Variable z1 is not used.
@emeryberger
Copy link
Member Author

Smoketest is currently failing…

x = 1.01
return x

import sys

Check notice

Code scanning / CodeQL

Unused import

Import of 'sys' is not used.
# z = np.multiply(x,x)
# z = np.multiply(z,z)
# z = np.multiply(z,z)
z = z * z

Check warning

Code scanning / CodeQL

Variable defined multiple times

This assignment to 'z' is unnecessary as it is [redefined](1) before this value is used.
@profile
def doit3(x):
for i in range(1000000):
z = x + 1

Check warning

Code scanning / CodeQL

Variable defined multiple times

This assignment to 'z' is unnecessary as it is [redefined](1) before this value is used.
def doit3(x):
for i in range(1000000):
z = x + 1
z = x + 1

Check warning

Code scanning / CodeQL

Variable defined multiple times

This assignment to 'z' is unnecessary as it is [redefined](1) before this value is used.
for j in range(1,3):
x = doit1(x)
x = doit2(x)
x = doit3(x)

Check warning

Code scanning / CodeQL

Variable defined multiple times

This assignment to 'x' is unnecessary as it is [redefined](1) before this value is used.
@emeryberger emeryberger merged commit cadb8f4 into master Jul 14, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants