Are you saying the code prints this in the console?
"ping: 20.457208156585693 download: 79367128.02705236 upload: 8458681.882858781"
If yes, then the code worked. The download and upload speeds are returned in bits per second. You can convert it to Mbps by dividing them by 10**6.
If no, then please share which specific problem you are facing when running the code.