Created
February 7, 2021 13:29
-
-
Save hopezh/013e5ff222615b1a44d5b0651eb3f3ee to your computer and use it in GitHub Desktop.
test python script for tqdm
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 tqdm import tqdm | |
import torch | |
import time | |
from datetime import timedelta | |
@torch.jit.script | |
def foo(): | |
x = torch.ones((1024 * 12, 1024 * 12), dtype=torch.float32) | |
y = torch.ones((1024 * 12, 1024 * 12), dtype=torch.float32) | |
z = x + y | |
return z | |
if __name__ == '__main__': | |
start = time.time() | |
z0 = None | |
for _ in tqdm(range(100)): | |
zz = foo() | |
if z0 is None: | |
z0 = zz | |
else: | |
z0 += zz | |
delta = (time.time() - start) | |
elapsed = str(timedelta(seconds=delta)) | |
print('elapsed time: {}'.format(elapsed)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment