The operation itself should not be slow, but is synchronizing the code, if you are using the GPU.
I.e. since CUDA operations are executed asynchronously, the timing will be accumulated in the next synchronizing operation, which is tensor.item(), since it needs to wait for the GPU calculation to finish in order to grab the value and push it to the CPU.