Last active
December 7, 2016 09:59
-
-
Save Sinitca-Aleksandr/8c11f169adb5ba4f4e4c3ffd6d7e76d2 to your computer and use it in GitHub Desktop.
Для автоматизации можно использовать менеджер контекста и с помощью модуля timer.py http://san-tit.blogspot.ru/2016/12/python.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from timer import Timer | |
import numpy as np | |
#Генерация случайных массивов по 1000000 элементов | |
A = np.random.sample((1000, 1000)) | |
B = np.random.sample((1000, 1000)) | |
with Timer() as t: | |
C = A*B | |
print ("Время выполнения: %s s" % t.secs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
class Timer(object): | |
def __init__(self, verbose=False): | |
self.verbose = verbose | |
def __enter__(self): | |
self.start = time.time() | |
return self | |
def __exit__(self, *args): | |
self.end = time.time() | |
self.secs = self.end - self.start | |
self.msecs = self.secs * 1000 | |
if self.verbose: | |
print ('Время выполения: %f ms' % self.msecs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment