Skip to content

Commit 76182a2

Browse files
clarkdoyyx990803
authored andcommitted
chore: remove always falsy condition on perf (#6547)
1 parent 949ec34 commit 76182a2

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

Diff for: benchmarks/dbmon/lib/memory-stats.js

+7-10
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,15 @@ var MemoryStats = function (){
4646

4747
var perf = window.performance || {};
4848
// polyfill usedJSHeapSize
49-
if (!perf && !perf.memory){
50-
perf.memory = { usedJSHeapSize : 0 };
51-
}
52-
if (perf && !perf.memory){
49+
if (!perf.memory){
5350
perf.memory = { usedJSHeapSize : 0 };
5451
}
5552

5653
// support of the API?
5754
if( perf.memory.totalJSHeapSize === 0 ){
5855
console.warn('totalJSHeapSize === 0... performance.memory is only available in Chrome .')
5956
}
60-
57+
6158
// TODO, add a sanity check to see if values are bucketed.
6259
// If so, remind user to adopt the --enable-precise-memory-info flag.
6360
// open -a "/Applications/Google Chrome.app" --args --enable-precise-memory-info
@@ -76,16 +73,16 @@ var MemoryStats = function (){
7673
var delta = perf.memory.usedJSHeapSize - lastUsedHeap;
7774
lastUsedHeap = perf.memory.usedJSHeapSize;
7875
var color = delta < 0 ? '#830' : '#131';
79-
76+
8077
var ms = perf.memory.usedJSHeapSize;
8178
msMin = Math.min( msMin, ms );
8279
msMax = Math.max( msMax, ms );
8380
msText.textContent = "Mem: " + bytesToSize(ms, 2);
84-
81+
8582
var normValue = ms / (30*1024*1024);
8683
var height = Math.min( 30, 30 - normValue * 30 );
8784
updateGraph( msGraph, height, color);
88-
85+
8986
function bytesToSize( bytes, nFractDigit ){
9087
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
9188
if (bytes == 0) return 'n/a';
@@ -97,5 +94,5 @@ var MemoryStats = function (){
9794
}
9895

9996
}
100-
101-
};
97+
98+
};

0 commit comments

Comments
 (0)