-
Notifications
You must be signed in to change notification settings - Fork 119
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
How to change the Timer unit to seconds instead of 1e-9 seconds #291
Comments
Merged
See the unit argument:
Example: echo "if 1:
from line_profiler import profile
@profile
def is_prime(n):
max_val = n ** 0.5
stop = int(max_val + 1)
for i in range(2, stop):
if n % i == 0:
return False
return True
@profile
def find_primes(size):
primes = []
for n in range(size):
flag = is_prime(n)
if flag:
primes.append(n)
return primes
@profile
def main():
print('start calculating')
primes = find_primes(10)
primes = find_primes(1000)
primes = find_primes(100000)
print(f'done calculating. Found {len(primes)} primes.')
if __name__ == '__main__':
main()
" > script.py
LINE_PROFILE=1 python script.py
# Use different values for the unit report
python -m line_profiler -rtmz --unit 1 profile_output.lprof
python -m line_profiler -rtmz --unit 1e-6 profile_output.lprof
python -m line_profiler -rtmz --unit 1e-9 profile_output.lprof I made a documentation update to make this more clear: #293 |
Thanks for the swift reply |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
Time
column is hard to understand whenTimer unit: 1e-09 s:
Is there a way to show seconds rounded to 1 or 2 decimals?
7.22
is more readable than721673000.0
. How to control this?The text was updated successfully, but these errors were encountered: