Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove always falsy condition on perf #6547

Merged
merged 1 commit into from
Sep 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 7 additions & 10 deletions benchmarks/dbmon/lib/memory-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,15 @@ var MemoryStats = function (){

var perf = window.performance || {};
// polyfill usedJSHeapSize
if (!perf && !perf.memory){
perf.memory = { usedJSHeapSize : 0 };
}
if (perf && !perf.memory){
if (!perf.memory){
perf.memory = { usedJSHeapSize : 0 };
}

// support of the API?
if( perf.memory.totalJSHeapSize === 0 ){
console.warn('totalJSHeapSize === 0... performance.memory is only available in Chrome .')
}

// TODO, add a sanity check to see if values are bucketed.
// If so, remind user to adopt the --enable-precise-memory-info flag.
// open -a "/Applications/Google Chrome.app" --args --enable-precise-memory-info
Expand All @@ -76,16 +73,16 @@ var MemoryStats = function (){
var delta = perf.memory.usedJSHeapSize - lastUsedHeap;
lastUsedHeap = perf.memory.usedJSHeapSize;
var color = delta < 0 ? '#830' : '#131';

var ms = perf.memory.usedJSHeapSize;
msMin = Math.min( msMin, ms );
msMax = Math.max( msMax, ms );
msText.textContent = "Mem: " + bytesToSize(ms, 2);

var normValue = ms / (30*1024*1024);
var height = Math.min( 30, 30 - normValue * 30 );
updateGraph( msGraph, height, color);

function bytesToSize( bytes, nFractDigit ){
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return 'n/a';
Expand All @@ -97,5 +94,5 @@ var MemoryStats = function (){
}

}
};

};