From 76182a2645ac81535179c926f3192b6762d514f0 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Mon, 11 Sep 2017 12:13:37 -0500 Subject: [PATCH] chore: remove always falsy condition on perf (#6547) --- benchmarks/dbmon/lib/memory-stats.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/benchmarks/dbmon/lib/memory-stats.js b/benchmarks/dbmon/lib/memory-stats.js index dd7fa5ef..03272d89 100644 --- a/benchmarks/dbmon/lib/memory-stats.js +++ b/benchmarks/dbmon/lib/memory-stats.js @@ -46,10 +46,7 @@ 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 }; } @@ -57,7 +54,7 @@ var MemoryStats = function (){ 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 @@ -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'; @@ -97,5 +94,5 @@ var MemoryStats = function (){ } } - -}; \ No newline at end of file + +};