File: data_construction.py

package info (click to toggle)
pytorch-text 0.14.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 11,560 kB
  • sloc: python: 14,197; cpp: 2,404; sh: 214; makefile: 20
file content (25 lines) | stat: -rw-r--r-- 596 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import time

from torchtext.prototype import datasets


def benchmark_construction(name, Dataset):
    t0 = time.perf_counter()
    print(name, end="")
    (d,) = Dataset(data_select=("train",))
    print(" construction time {0:.2f}s".format(time.perf_counter() - t0))
    del d


def benchmark_raw_construction(name, Dataset):
    print(name, end="")
    if name in "WMTNewsCrawl":
        d = Dataset(data_select=("train",))
    else:
        d = Dataset()
    del d


if __name__ == "__main__":
    for name, Dataset in datasets.DATASETS.items():
        benchmark_construction(name, Dataset)