我需要知道当整个程序执行时,这行特定代码加载了多少CPU:
cap.set(cv.CAP_PROP_POS_FRAMES,random_frame)
这行代码是某个程序的一部分,但我只关心这个特定的行如何加载CPU。我不知道如何准确地测量它。
更精确地说,这是我的完整代码:
import cv2 as cv
import random
cap = cv.VideoCapture('file_name.avi')
random_frame = random.randint(1,99999)
cap.set(cv.CAP_PROP_POS_FRAMES,random_frame)
ret, frame = cap.read()
cv.imshow("random_frame",frame)
while cap.isOpened():
if cv.waitKey(1) == ord('q'):
break
cap.release()
cv.destroyAllWindows()
Windows 7 操作系统
rdtsc
)放入 Python 解释器本身中,这也不容易。因此,你的计时代码也必须在 Python 中。 - Peter Cordes