Javascript te permite medir el tiempo de ejecución de los eventos // Javascript allows you to measure the execution time of events

avatar

Esto es algo que muy poco desarrolladores llegamos a utilizar, medir el tiempo de ejecución de un evento, desde su comienzo hasta su fin. En los comienzos de javascript estoy seguro que la manera de lograr esto era mediante la función “Date()” que nos permite obtener los datos de la fecha actual en la que se ejecutando el navegador por lo tanto esto era un gran problema porque muchos usuarios al no tener licencias oficiales de su sistema operativo siempre tenían problemas con la fecha.
Los desarrolladores siempre debemos prever posibles errores y advertencias al usuario para el correcto funcionamiento de la web.

Podría hacer un ejemplo a la vieja escuela de como calcular el tiempo de ejecución, pero javascript facilita esto con un simple método “performance”

This is something that very few developers use, measuring the execution time of an event, from its beginning to its end. In the beginnings of javascript I am sure that the way to achieve this was through the "Date()" function that allows us to obtain the data of the current date in which the browser is running, therefore this was a big problem because many users Not having official licenses for their operating system always had problems with the date. Developers must always anticipate possible errors and warnings to the user for the proper functioning of the web.

I could do an old school example of how to calculate execution time, but javascript makes it easy with a simple "performance" method.

timestap.jpg
Este método increíble de javascript retorna el tiempo de ejecución en milisegundos.
En este caso tomare como ejemplo el evento “click” que otorga una visión más amplia e ilustrativa de la manipulación del tiempo del evento.
Los scripts de la anterior imagen lo único que hacen es imprimir por consola el tiempo de ejecución del evento al ejecutar el click sobre el botón y al soltar el click del botón.

This awesome javascript method returns the execution time in milliseconds. In this case, I will take the “click” event as an example, which provides a broader and more illustrative vision of the manipulation of the time of the event. The scripts in the previous image all they do is print to the console the execution time of the event when executing the click on the button and when the button is released.

times1.jpg


times2.jpg
Espero que con este corto ejemplo hayas aprendido a calcular el tiempo de ejecución de los eventos sin recurrir a los eventos que acceden a las fechas.

I hope that with this short example you have learned how to calculate the execution time of events without resorting to events that access dates.


0
0
0.000
2 comments
avatar

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support. 
 

0
0
0.000
avatar

Congratulations @dobro2020! You received a personal badge!

Happy Hive Birthday! You are on the Hive blockchain for 3 years!

You can view your badges on your board and compare yourself to others in the Ranking

0
0
0.000