I discovered we can use two methods to test performance – performance.now and Date.now. I was curious about the difference between them, so I made some experiments to document my findings.
The procedure for testing performance is simple. There are three steps:
Check the current timestamp
Run some operations
Check the timestamp again
The difference between the two timestamps will be the amount of time needed to run the operations.
Here’s what this process looks like in code:
const start = performance.now()
// Do stuff
const end = performance.now()
const elapsed = end - start
Performance.now vs Date.now
performance.now is said to generate a Dom high-res timestamp, which means it’s going to be more accurate than Date.now.
Unfortunately, browsers have to round off this timestamp because of security issues, so it doesn’t make much of a difference in the end (according to my findings).
To help with the tests, I created a perf function.
I often get requests from people who want me to look through their work and provide them with feedback. While asking for feedback is a praise-worthy thing – because you want to improve – I don’t have the time and resources to give feedback to everyone.
I suspect that’s the case for others too. We’re all busy.
When I ask others for feedback, sometimes I don’t get responses. Sometimes I get subpar responses. I found it hard to get specific, detailed, and actionable advice from people unless they have a skin in the game for helping me out.
For example: You’re paying for their services, so they have an incentive to help you. Another example: You’re in a project together with them; if you succeed they succeed.
If you get specific and helpful feedback, great! Use that feedback and improve. But the question remains: How can you improve if you don’t get feedback?
I was living a comfortable life back in 2014. I was living my dreams. I freelanced and I earned an equal amount to my friends who held full-time jobs. I was free.
Or so I thought.
The first three years of freelancing were exciting. I simply loved hopping around different agencies, creating websites for a living, making friends, and knowing more people. I felt I could do this forever. But I was wrong.