If you are using dataloader for your training loop, you can measure dataloading time simply like below.
loader_time, st = 0, time.time()
for i, data in enumerate(loader):
    loader_time += time.time() - st
    # sth for training
    # ...
    st = time.time()
    # end of the loop

Then you can measure the proportion of dataloading time from whole training.
Or the better way is to do the profiling like this.

  
      Sagivtech
  
  
    

Optimizing PyTorch training code 5

Ben Levy and Jacob Gildenblat, SagivTech    

PyTorch is an incredible Deep Learning Python framework. It makes prototyping and debugging deep learning algorithms easier, and has great support for multi gpu training.
However, as always with...