Ver Mensaje Individual
  #4 (permalink)  
Antiguo 12/10/2012, 07:49
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: Medir tiempo que tarda en ejecutarse una funcion

Habría que ver tu ejemplo completo para ver por que querés medir el tiempo entre bucle y bucle, ni por que hacer la función infinita, puede que te cuelgue el navegador.
Más lógico me suena calcular el tiempo de ejecución de una función
De todas formas quizás esto te sirva u oriente

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <title>titulo</title>
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6. </head>
  7. <div id="ms"></div>
  8. <script type="text/javascript">
  9. //<![CDATA[
  10. function tiempo(){
  11. for (num=0;num<=10;num++) {
  12. var date1 = new Date();
  13. var milisegundos1 = date1.getTime();
  14. alert('obteniendo el tiempo entre alert y alert');
  15. var date2 = new Date();
  16. var milisegundos2 = date2.getTime();
  17. var diff_mseg = milisegundos2 - milisegundos1;
  18. document.getElementById('ms').innerHTML += 'bucle ' + num + ': ' + diff_mseg + ' milisegundos<br \/>';
  19. }
  20. }
  21. window.onload = tiempo;
  22. //]]>
  23.  
  24. </body>
  25. </html>

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.