Skip to content

Commit

Permalink
Revert "add cache monitoring"
Browse files Browse the repository at this point in the history
This reverts commit b7571db.
  • Loading branch information
kacper-mikolajczak committed May 14, 2024
1 parent fec8b86 commit b53cf49
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions src/components/ProfilingToolMenu/BaseProfilingToolMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type {StatsObject} from 'moize';
import moize from 'moize';
import React, {useCallback, useEffect, useState} from 'react';
import DeviceInfo from 'react-native-device-info';
import RNFS from 'react-native-fs';
Expand Down Expand Up @@ -32,14 +30,6 @@ type BaseProfilingToolMenuProps = {
displayPath: string;
} & BaseProfilingToolMenuOnyxProps;

function completeCacheStatsMonitoring() {
const stats = moize.getStats();
moize.clearStats();
moize.collectStats(false);

return stats;
}

function formatBytes(bytes: number, decimals = 2) {
if (!+bytes) {
return '0 Bytes';
Expand All @@ -62,7 +52,6 @@ function BaseProfilingToolMenu({isProfilingInProgress = false, pathToBeUsed, dis
const [sharePath, setSharePath] = useState('');
const [totalMemory, setTotalMemory] = useState(0);
const [usedMemory, setUsedMemory] = useState(0);
const [cacheStats, setCacheStats] = useState<StatsObject>();
const {translate} = useLocalize();

// eslint-disable-next-line @lwc/lwc/no-async-await
Expand All @@ -72,18 +61,14 @@ function BaseProfilingToolMenu({isProfilingInProgress = false, pathToBeUsed, dis

const amountOfTotalMemory = await DeviceInfo.getTotalMemory();
const amountOfUsedMemory = await DeviceInfo.getUsedMemory();
const stats = completeCacheStatsMonitoring();

setTotalMemory(amountOfTotalMemory);
setUsedMemory(amountOfUsedMemory);
setCacheStats(stats);
}, []);

const onToggleProfiling = useCallback(() => {
const shouldProfiling = !isProfilingInProgress;
if (shouldProfiling) {
startProfiling();
moize.collectStats();
} else {
stop();
}
Expand All @@ -101,9 +86,8 @@ function BaseProfilingToolMenu({isProfilingInProgress = false, pathToBeUsed, dis
platform: getPlatform(),
totalMemory: formatBytes(totalMemory, 2),
usedMemory: formatBytes(usedMemory, 2),
cacheStats,
}),
[cacheStats, totalMemory, usedMemory],
[totalMemory, usedMemory],
);

useEffect(() => {
Expand Down

0 comments on commit b53cf49

Please sign in to comment.