2016-06-15 3 views
0

내 응용 프로그램에서 CPU 사용량이 너무 많이 들고 왜 대기 시간이 길어져서 응용 프로그램에 몇 가지 로그를 남기기 시작했습니다. 이 결과Meteor server method run time

console.log('update benchmark took %d nanoseconds', updateTime[0] * 1e9 + updateTime[1]); 

:

update benchmark took 1084353904561267 nanoseconds 

나중에 방법에
var updateTime = process.hrtime(); 

Nightclubs.update({_id: nightclubId}, {$push: { guests: { 
    value: value, 
    currentGuestAmount: currentGuestAmount+value, 
    date: thisEntryDate.toDate(), 
    gender: gender, 
    age: age, 
    guard: guardId 
}}}) 

var updateDiff = process.hrtime(updateTime); 

나는이 같은 시간을 로그 : 내 응용 프로그램의 모든 부분을 기록 할 때 나는이에 달렸다 네 .. 1.8 주입니다 .... 총계가 916589992 나노초 또는 0.91 초 (여전히 약간 너무 깁니다)를 사용하기 때문에 이것은 정말 이상합니다

아무도 이것에 대해 어떤 단서가 있습니까?

PS, I 삽입 할 데이터에 대한 자세한 내용의 비트 :

guests: { type: Array, defaultValue: [] }, 
'guests.$': { type: Object }, 
'guests.$.value': { type: Number }, 
'guests.$.currentGuestAmount': { type: Number }, 
'guests.$.date': { type: Date }, 
'guests.$.age': { type: Number }, 
'guests.$.gender': { type: String }, 
'guests.$.guard': { type: String }, 
+2

process.hrtime()의 당신은'console.time'을 사용할 수 있습니다 및 'console.timeEnd' https://developer.mozilla.org/en-US/docs/Web/API/console#Timers – Ser

+0

@Ser 그래, 그 사람이 조금 더 나은 대답을 주었다 : 15ms! 나는 그걸로 계속할 것 같아! –

답변

1

는 결론 console.time를 사용하고 console.timeEnd 대신

console.time("Update nightclub"); 

Nightclubs.update({_id: nightclubId}, {$push: { guests: { 
    value: value, 
    currentGuestAmount: currentGuestAmount+value, 
    date: thisEntryDate.toDate(), 
    gender: gender, 
    age: age, 
    guard: guardId 
}}}) 

console.timeEnd("Update nightclub");