I have a code that plays fast _it's order is log(n)_.I have to meter it's play's elapsed time.I used from time.time() and time.clock() but they returned 0.I need a timer witch meter nano second.
How can I do it?
C:\>python -m timeit "for i in xrange(100): pass"
1000000 loops, best of 3: 1.77 usec per loop
#Are tuple faster than list?
C:\>python -m timeit (1,2,3,4)
10000000 loops, best of 3: 0.0226 usec per loop
C:\>python -m timeit [1,2,3,4]
10000000 loops, best of 3: 0.194 usec per loop
#Yes tuple are faster than list
# using Python module timeit on a simple statement
# (timeit turns off garbage collection)
stmt = "x = (12345679 * 63)//7"
# use n=1000000 passes (this is also the default)
# this way the result will be time per pass in microseconds
elapsed = lambda stmt, n=1000000: timeit.Timer(stmt).timeit(n)
# run and show the timeit test
print( "%s took %0.3f micro-seconds" % (stmt, elapsed(stmt)) )
"""my result with Python 3.1.1 -->
x = (12345679 * 63)//7 took 0.085 micro-seconds
I am writing a java program that needs to execute shell commands, so I wrote a function that would take the command to execute as a string (ie: "mkdir ~/Folder1") and execute that command with the shell. Here is the function:
Runtime run = Runtime.getRuntime();
Process pr = ...
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"