2012-10-25 5 views
0

setTimeout/setInterval을 사용하여 모바일 브라우저를 계산하는 방법의 CPU 효율은 어느 정도입니까?setTimeout/setInterval 모바일 브라우저가 CPU 효율을 계산합니다

function someFunction(){ 
    console.timeEnd('someFunction timer'); 
    //this function's code goes here... 
    console.time('someFunction timer'); 
} 

이것은 당신에게 당신의 기능을 실행하는 데 걸린 시간을 줄 것이다 :

function fn() { 
    var start = new Date(); 
    setInterval(function() { 
     var _s = new Date(); 
     console.info(_s - start); 
     start = _s; 
    }, 1000/60) 
} 
fn() 
+0

'css3'과 어떤 관련이 있습니까? –

+0

중복 가능 (또는 적어도 관련) : [스레드 잠자기와 관련하여 모바일 장치 웹 브라우저에 대한 표준이 있습니까?] (http://stackoverflow.com/questions/10739835/are-there-any-standards-for- 모바일 장치 웹 브라우저 - 용어 - 스레드 - 잠자기) – Bergi

답변

1

당신은 console.time를 사용할 수 있습니다. 이게 니가 필요한거야?

아니면 이럴 수 있습니까?

var start = new Date().getTime(); 

//your code 
var end = new Date().getTime(); 
var time = end - start; 
alert('Execution time: ' + time); 
관련 문제