import numpy as np
import torch
import time
T1 = time.time()
for i in range(100*100):
f = np.random.uniform(0, 1) > 0.5
T2 = time.time()
print('程序运行时间:%s毫秒' % ((T2 - T1)*1000))
T1 = time.time()
for i in range(100*100):
f = torch.rand(0, 1) > 0.5
T2 = time.time()
print('程序运行时间:%s毫秒' % ((T2 - T1)*1000))
程序运行时间:7.704019546508789毫秒
程序运行时间:29.051780700683594毫秒