Skip to content

Commit

Permalink
optimized exetime.py
Browse files Browse the repository at this point in the history
  • Loading branch information
saikuno committed Sep 26, 2021
1 parent 3ec9f11 commit e348e16
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions exetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
"""

'''
Source Code:
----------------------------------------------------------
Credit: It was created by Saikat ()
Credit: It was created by Saikat (https://github.com/saikat0326)
----------------------------------------------------------
'''

Expand All @@ -27,23 +26,24 @@
import decimal

exeStart = 0.0
def __init__():
global exeStart
exeStart = decimal.Decimal(time.process_time_ns())

def exetime():
'''
returns total process-time for profiling as seconds:\n
sum of kernel and User-space CPU time
'''
global exeStart
return (decimal.Decimal(time.process_time_ns()) - decimal.Decimal(exeStart))/(decimal.Decimal(10**9))

return (time.process_time_ns() - exeStart)/(10**9)

def exetime_ms():
'''
exetime() -> decimal
Returns total process-time for profiling as milliseconds (ms):\n sum of kernel and User-space CPU time
'''
global exeStart
return (decimal.Decimal(time.process_time_ns()) - decimal.Decimal(exeStart))/(decimal.Decimal(10**6))

return exetime()*1000

if __name__ != '__main__':
exeStart = decimal.Decimal(time.process_time_ns())

0 comments on commit e348e16

Please sign in to comment.