From cdfb944f3a763531bbf674a49dfed0afc8c7996c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Miko=C5=82ajczak?= Date: Mon, 22 Jan 2024 08:39:13 +0100 Subject: [PATCH] change devtools --- src/PERF.tsx | 52 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/src/PERF.tsx b/src/PERF.tsx index 5236c48d7f32..f4dc0c0d2593 100644 --- a/src/PERF.tsx +++ b/src/PERF.tsx @@ -1,26 +1,54 @@ -import React from 'react'; -import {Text} from 'react-native'; +import React, {useRef} from 'react'; +import {Text, View} from 'react-native'; import Performance from 'react-native-performance'; +import {startProfiling, stopProfiling} from 'react-native-release-profiler'; -const onPress = () => { - const metrics = Performance.getEntries(); - fetch('http://10.0.2.2:8080', { - method: 'POST', - body: JSON.stringify(metrics), - }); -}; +function SendDataButton() { + const onPress = () => { + const metrics = Performance.getEntries(); + fetch('http://10.0.2.2:8080', { + method: 'POST', + body: JSON.stringify(metrics), + }); + }; + return devtools; +} + +function ProfilingButton() { + const ref = useRef(null); + const active = useRef(false); + const onPress = () => { + if (active.current) { + stopProfiling(true); + active.current = false; + ref.current.setNativeProps({style: {backgroundColor: 'green'}}); + } else { + startProfiling(); + active.current = true; + ref.current.setNativeProps({style: {backgroundColor: 'red'}}); + } + }; -function PerfDevtools() { return ( - devtools + Profiling ); } +function PerfDevtools() { + return ( + + {/* */} + + + ); +} + const perf = { marks: { messageSent: '[SendMessage]Sent',