Your approach could work to profile the loading of a single sample.
However, if you want to profile the data loading via a DataLoader (and thus potentially multiple workers), I would recommend to use this code snippet 30 from the ImageNet example.