If you know how to benchmark, and you know that there's no translation of DST etc involved, why bother doing premature profiling? Unless you're doing this thousands of times per second, I see nothing wrong with this simple sub.
What exactly is the issue here?
| [reply] |
- What exactly is the issue here?
This is part of a web app where I call an external API and get back a few hundred results and have to do quite a few conversions. I can't speed up the API call so am looking to improve speed anywhere I can. Just thought this might be a likely candidate.
| [reply] |
This is part of a web app where I call an external API
Whoa, whoa, whoa... Stop right there!
Third rule of Optimization Club:
If your app is running faster than the underlying transport protocol, the optimization is over.
Networks are slow. CPUs are fast. Each API call is easily taking tens of thousands, if not millions, of times longer than your seconds-to-hh:mm:ss conversion routine. Even if you could optimize that conversion down so that a hundred calls take absolutely no time at all, it still wouldn't make a perceptible dent in the overall speed.
| [reply] |