@buoy-gg/benchmark 2.1.1 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BenchmarkModal=BenchmarkModal,exports.default=void 0;var _react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_sharedUi=require("@buoy-gg/shared-ui"),_benchmarking=require("../benchmarking"),_BenchmarkSessionCard=require("./BenchmarkSessionCard"),_BenchmarkDetailView=require("./BenchmarkDetailView"),_BenchmarkCompareView=require("./BenchmarkCompareView"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var a=new WeakMap,r=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var s,o,i={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return i;if(s=t?r:a){if(s.has(e))return s.get(e);s.set(e,i)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((o=(s=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(o.get||o.set)?s(i,t,o):i[t]=e[t]);return i})(e,t)}const storageAdapter=(0,_benchmarking.createAsyncStorageAdapter)(),storage=storageAdapter?new _benchmarking.BenchmarkStorage(storageAdapter):null;function BenchmarkModal({visible:e,onClose:t,onBack:a,onMinimize:r,enableSharedModalDimensions:s=!1}){const[o,i]=(0,_react.useState)(!1),[n,c]=(0,_react.useState)([]),[l,m]=(0,_react.useState)(null),[d,u]=(0,_react.useState)("list"),[_,h]=(0,_react.useState)(!1),[p,x]=(0,_react.useState)(new Set),[y,g]=(0,_react.useState)(null),[j,R]=(0,_react.useState)(0);(0,_react.useRef)(!1),(0,_react.useEffect)(()=>{e&&storage&&(async()=>{const e=await storage.listReports();c(e)})()},[e,j]),(0,_react.useEffect)(()=>{const e=_benchmarking.benchmarkRecorder.subscribe(e=>{"start"===e?i(!0):"stop"===e&&(i(!1),R(e=>e+1))});return i(_benchmarking.benchmarkRecorder.isRecording()),e},[]);const S=(0,_react.useCallback)(async()=>{if(o){const e=_benchmarking.benchmarkRecorder.stopSession();e&&storage&&(await storage.saveReport(e),R(e=>e+1))}else{const e=(new Date).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});_benchmarking.benchmarkRecorder.startSession({name:`Benchmark ${e}`,captureMemory:!0,verbose:!1})}},[o]),C=(0,_react.useCallback)(async e=>{if(_)x(t=>{const a=new Set(t);return a.has(e.id)?a.delete(e.id):a.size<2&&a.add(e.id),a});else{if(!storage)return;const t=await storage.loadReport(e.id);t&&(m(t),u("detail"))}},[_]),b=(0,_react.useCallback)(e=>{h(!0),x(new Set([e.id]))},[]),T=(0,_react.useCallback)(async()=>{if(2!==p.size||!storage)return;const e=Array.from(p),[t,a]=await Promise.all([storage.loadReport(e[0]),storage.loadReport(e[1])]);if(t&&a){const[e,r]=t.createdAt<a.createdAt?[t,a]:[a,t];g({baseline:e,comparison:r}),u("compare"),h(!1),x(new Set)}},[p]),k=(0,_react.useCallback)(async()=>{storage&&(await storage.clearAll(),R(e=>e+1))},[]),f=(0,_react.useCallback)(async()=>{0!==p.size&&storage&&(await Promise.all(Array.from(p).map(e=>storage.deleteReport(e))),x(new Set),h(!1),R(e=>e+1))},[p]),v=(0,_react.useCallback)(()=>{"detail"===d||"compare"===d?(u("list"),m(null),g(null)):_?(h(!1),x(new Set)):a&&a()},[d,_,a]),B=(0,_react.useCallback)(()=>{l&&storage&&_reactNative.Alert.prompt("Rename Benchmark","Enter a new name for this benchmark:",[{text:"Cancel",style:"cancel"},{text:"Save",onPress:async e=>{e&&e.trim()&&(await storage.updateReport(l.id,{name:e.trim()}),m({...l,name:e.trim()}),R(e=>e+1))}}],"plain-text","")},[l]),O=(0,_react.useCallback)(async()=>{l&&storage&&(await storage.deleteReport(l.id),u("list"),m(null),R(e=>e+1))},[l]),U=(0,_react.useCallback)(async()=>{if(!y)return;const{baseline:e,comparison:t}=y,a=_benchmarking.BenchmarkComparator.compare(e,t),r=e=>e<1?`${(1e3*e).toFixed(0)}μs`:e<10?`${e.toFixed(2)}ms`:e<100?`${e.toFixed(1)}ms`:`${e.toFixed(0)}ms`,s=e=>`${e>=0?"+":""}${e.toFixed(1)}%`,o=["BENCHMARK COMPARISON RESULTS","============================","",`Overall: ${a.isImproved?"IMPROVED":"REGRESSED"} ${s(a.overallImprovement)}`,"","COMPARING","---------",`Baseline: ${e.name}`,` Date: ${new Date(e.createdAt).toLocaleString()}`,`Comparison: ${t.name}`,` Date: ${new Date(t.createdAt).toLocaleString()}`,"","TIMING COMPARISON","-----------------",`Measure Time: ${r(e.stats.avgMeasureTime)} → ${r(t.stats.avgMeasureTime)} (${s(a.measureTimeImprovement)})`,`Pipeline Time: ${r(e.stats.avgTotalTime)} → ${r(t.stats.avgTotalTime)} (${s(a.pipelineTimeImprovement)})`,`Filter Time: ${r(e.stats.avgFilterTime)} → ${r(t.stats.avgFilterTime)} (${s(a.filterTimeImprovement)})`,`Track Time: ${r(e.stats.avgTrackTime)} → ${r(t.stats.avgTrackTime)} (${s(a.trackTimeImprovement)})`,`Overlay Render: ${r(e.stats.avgOverlayRenderTime)} → ${r(t.stats.avgOverlayRenderTime)} (${s(a.overlayRenderImprovement)})`,"","PERCENTILES","-----------",`P50 (Median): ${r(e.stats.p50TotalTime)} → ${r(t.stats.p50TotalTime)}`,`P95: ${r(e.stats.p95TotalTime)} → ${r(t.stats.p95TotalTime)}`,`P99: ${r(e.stats.p99TotalTime)} → ${r(t.stats.p99TotalTime)}`,"","BATCH STATISTICS","----------------",`Total Batches: ${e.stats.batchCount} → ${t.stats.batchCount}`,`Nodes Processed: ${e.stats.totalNodesProcessed.toLocaleString()} → ${t.stats.totalNodesProcessed.toLocaleString()}`];null!=e.memoryDelta&&null!=t.memoryDelta&&o.push("","MEMORY","------",`Memory Delta: ${(e.memoryDelta/1024/1024).toFixed(2)}MB → ${(t.memoryDelta/1024/1024).toFixed(2)}MB`),o.push("",`Compared at: ${new Date(a.comparedAt).toLocaleString()}`),await(0,_sharedUi.copyToClipboard)(o.join("\n"))},[y]),w=(0,_react.useCallback)(({item:e})=>(0,_jsxRuntime.jsx)(_BenchmarkSessionCard.BenchmarkSessionCard,{metadata:e,isSelected:p.has(e.id),onPress:()=>C(e),onLongPress:()=>b(e),selectionMode:_}),[_,p,C,b]),$=(0,_react.useCallback)(e=>e.id,[]),M=s?_sharedUi.devToolsStorageKeys.modal.root():_sharedUi.devToolsStorageKeys.benchmark.modal(),P=(0,_react.useMemo)(()=>"detail"===d&&l?l.name:"compare"===d?"Compare":_?0===p.size?"Select 2 to compare":1===p.size?"Select 1 more":`${p.size} Selected`:"Benchmarks",[d,l,_,p]),N="list"!==d||_||a;return e?(0,_jsxRuntime.jsxs)(_sharedUi.JsModal,{visible:e,onClose:t,onBack:N?v:void 0,onMinimize:r,persistenceKey:M,header:{showToggleButton:!0,customContent:(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[N&&(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:v}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:P}),(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader.Actions,{children:["list"===d&&!_&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:S,style:[styles.iconButton,o&&styles.recordingButton],children:o?(0,_jsxRuntime.jsx)(_sharedUi.Pause,{size:14,color:_sharedUi.macOSColors.semantic.error}):(0,_jsxRuntime.jsx)(_sharedUi.Play,{size:14,color:_sharedUi.macOSColors.semantic.success})}),n.length>=2&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>h(!0),style:styles.iconButton,children:(0,_jsxRuntime.jsx)(_sharedUi.GitBranch,{size:14,color:_sharedUi.macOSColors.semantic.info})}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>R(e=>e+1),style:styles.iconButton,children:(0,_jsxRuntime.jsx)(_sharedUi.RefreshCw,{size:14,color:_sharedUi.macOSColors.text.secondary})}),n.length>0&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:k,style:styles.iconButton,children:(0,_jsxRuntime.jsx)(_sharedUi.Trash2,{size:14,color:_sharedUi.macOSColors.semantic.error})})]}),"detail"===d&&l&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:B,style:styles.iconButton,children:(0,_jsxRuntime.jsx)(_sharedUi.Edit3,{size:14,color:_sharedUi.macOSColors.text.secondary})}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:O,style:styles.iconButton,children:(0,_jsxRuntime.jsx)(_sharedUi.Trash2,{size:14,color:_sharedUi.macOSColors.semantic.error})})]}),"compare"===d&&y&&(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:U,style:styles.iconButton,children:(0,_jsxRuntime.jsx)(_sharedUi.Copy,{size:14,color:_sharedUi.macOSColors.text.secondary})})}),_&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[2===p.size&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:T,style:[styles.iconButton,styles.compareButton],children:(0,_jsxRuntime.jsx)(_sharedUi.GitBranch,{size:14,color:_sharedUi.macOSColors.semantic.info})}),p.size>0&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:f,style:styles.iconButton,children:(0,_jsxRuntime.jsx)(_sharedUi.Trash2,{size:14,color:_sharedUi.macOSColors.semantic.error})})]})]})]})},enablePersistence:!0,initialMode:"bottomSheet",enableGlitchEffects:!0,children:[o&&"list"===d&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.recordingBanner,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.recordingDot}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.recordingText,children:"Recording..."}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:S,style:styles.stopButton,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.stopButtonText,children:"Stop"})})]}),"detail"===d&&l?(0,_jsxRuntime.jsx)(_BenchmarkDetailView.BenchmarkDetailView,{report:l}):"compare"===d&&y?(0,_jsxRuntime.jsx)(_BenchmarkCompareView.BenchmarkCompareView,{baseline:y.baseline,comparison:y.comparison}):0===n.length?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.emptyState,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyIcon,children:"📊"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyTitle,children:"No Benchmarks Yet"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptySubtitle,children:"Press the record button to start capturing performance metrics"})]}):(0,_jsxRuntime.jsx)(_reactNative.FlatList,{data:n,renderItem:w,keyExtractor:$,contentContainerStyle:styles.listContent,ItemSeparatorComponent:()=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.separator}),scrollEnabled:!1})]}):null}const styles=_reactNative.StyleSheet.create({iconButton:{width:32,height:32,borderRadius:8,backgroundColor:_sharedUi.macOSColors.background.hover,borderWidth:1,borderColor:_sharedUi.macOSColors.border.default,alignItems:"center",justifyContent:"center"},recordingButton:{backgroundColor:_sharedUi.macOSColors.semantic.errorBackground,borderColor:_sharedUi.macOSColors.semantic.error},compareButton:{backgroundColor:_sharedUi.macOSColors.semantic.infoBackground,borderColor:_sharedUi.macOSColors.semantic.info},listContent:{paddingVertical:16},separator:{height:8},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyIcon:{fontSize:48,marginBottom:16},emptyTitle:{fontSize:16,fontWeight:"600",color:_sharedUi.macOSColors.text.primary,fontFamily:"monospace",marginBottom:8},emptySubtitle:{fontSize:13,color:_sharedUi.macOSColors.text.secondary,fontFamily:"monospace",textAlign:"center"},recordingBanner:{flexDirection:"row",alignItems:"center",backgroundColor:_sharedUi.macOSColors.semantic.errorBackground,paddingHorizontal:16,paddingVertical:12,borderBottomWidth:1,borderColor:_sharedUi.macOSColors.semantic.error},recordingDot:{width:8,height:8,borderRadius:4,backgroundColor:_sharedUi.macOSColors.semantic.error,marginRight:8},recordingText:{flex:1,fontSize:13,fontWeight:"600",color:_sharedUi.macOSColors.semantic.error,fontFamily:"monospace"},stopButton:{paddingHorizontal:12,paddingVertical:6,backgroundColor:_sharedUi.macOSColors.semantic.error,borderRadius:4},stopButtonText:{fontSize:12,fontWeight:"600",color:"#fff",fontFamily:"monospace"}});var _default=exports.default=BenchmarkModal;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BenchmarkModal=BenchmarkModal,exports.default=void 0;var _react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_sharedUi=require("@buoy-gg/shared-ui"),_benchmarking=require("../benchmarking"),_BenchmarkSessionCard=require("./BenchmarkSessionCard"),_BenchmarkDetailView=require("./BenchmarkDetailView"),_BenchmarkCompareView=require("./BenchmarkCompareView"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var a=new WeakMap,r=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var s,o,i={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return i;if(s=t?r:a){if(s.has(e))return s.get(e);s.set(e,i)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((o=(s=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(o.get||o.set)?s(i,t,o):i[t]=e[t]);return i})(e,t)}const storageAdapter=(0,_benchmarking.createAsyncStorageAdapter)(),storage=storageAdapter?new _benchmarking.BenchmarkStorage(storageAdapter):null;function BenchmarkModal({visible:e,onClose:t,onBack:a,onMinimize:r,enableSharedModalDimensions:s=!1}){const[o,i]=(0,_react.useState)(!1),[n,c]=(0,_react.useState)([]),[l,m]=(0,_react.useState)(null),[d,u]=(0,_react.useState)("list"),[_,h]=(0,_react.useState)(!1),[p,x]=(0,_react.useState)(new Set),[g,y]=(0,_react.useState)(null),[j,R]=(0,_react.useState)(0);(0,_react.useRef)(!1),(0,_react.useEffect)(()=>{e&&storage&&(async()=>{const e=await storage.listReports();c(e)})()},[e,j]),(0,_react.useEffect)(()=>{const e=_benchmarking.benchmarkRecorder.subscribe(e=>{"start"===e?i(!0):"stop"===e&&(i(!1),R(e=>e+1))});return i(_benchmarking.benchmarkRecorder.isRecording()),e},[]);const b=(0,_react.useCallback)(async()=>{if(o){const e=_benchmarking.benchmarkRecorder.stopSession();e&&storage&&(await storage.saveReport(e),R(e=>e+1))}else{const e=(new Date).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});_benchmarking.benchmarkRecorder.startSession({name:`Benchmark ${e}`,captureMemory:!0,verbose:!1})}},[o]),S=(0,_react.useCallback)(async e=>{if(_)x(t=>{const a=new Set(t);return a.has(e.id)?a.delete(e.id):a.size<2&&a.add(e.id),a});else{if(!storage)return;const t=await storage.loadReport(e.id);t&&(m(t),u("detail"))}},[_]),C=(0,_react.useCallback)(e=>{h(!0),x(new Set([e.id]))},[]),T=(0,_react.useCallback)(async()=>{if(2!==p.size||!storage)return;const e=Array.from(p),[t,a]=await Promise.all([storage.loadReport(e[0]),storage.loadReport(e[1])]);if(t&&a){const[e,r]=t.createdAt<a.createdAt?[t,a]:[a,t];y({baseline:e,comparison:r}),u("compare"),h(!1),x(new Set)}},[p]),k=(0,_react.useCallback)(async()=>{storage&&(await storage.clearAll(),R(e=>e+1))},[]),f=(0,_react.useCallback)(async()=>{0!==p.size&&storage&&(await Promise.all(Array.from(p).map(e=>storage.deleteReport(e))),x(new Set),h(!1),R(e=>e+1))},[p]),v=(0,_react.useCallback)(()=>{"detail"===d||"compare"===d?(u("list"),m(null),y(null)):_?(h(!1),x(new Set)):a&&a()},[d,_,a]),B=(0,_react.useCallback)(()=>{l&&storage&&_reactNative.Alert.prompt("Rename Benchmark","Enter a new name for this benchmark:",[{text:"Cancel",style:"cancel"},{text:"Save",onPress:async e=>{e&&e.trim()&&(await storage.updateReport(l.id,{name:e.trim()}),m({...l,name:e.trim()}),R(e=>e+1))}}],"plain-text","")},[l]),O=(0,_react.useCallback)(async()=>{l&&storage&&(await storage.deleteReport(l.id),u("list"),m(null),R(e=>e+1))},[l]),w=(0,_react.useCallback)(async()=>{if(!g)return;const{baseline:e,comparison:t}=g,a=_benchmarking.BenchmarkComparator.compare(e,t),r=e=>e<1?`${(1e3*e).toFixed(0)}μs`:e<10?`${e.toFixed(2)}ms`:e<100?`${e.toFixed(1)}ms`:`${e.toFixed(0)}ms`,s=e=>`${e>=0?"+":""}${e.toFixed(1)}%`,o=["BENCHMARK COMPARISON RESULTS","============================","",`Overall: ${a.isImproved?"IMPROVED":"REGRESSED"} ${s(a.overallImprovement)}`,"","COMPARING","---------",`Baseline: ${e.name}`,` Date: ${new Date(e.createdAt).toLocaleString()}`,`Comparison: ${t.name}`,` Date: ${new Date(t.createdAt).toLocaleString()}`,"","TIMING COMPARISON","-----------------",`Measure Time: ${r(e.stats.avgMeasureTime)} → ${r(t.stats.avgMeasureTime)} (${s(a.measureTimeImprovement)})`,`Pipeline Time: ${r(e.stats.avgTotalTime)} → ${r(t.stats.avgTotalTime)} (${s(a.pipelineTimeImprovement)})`,`Filter Time: ${r(e.stats.avgFilterTime)} → ${r(t.stats.avgFilterTime)} (${s(a.filterTimeImprovement)})`,`Track Time: ${r(e.stats.avgTrackTime)} → ${r(t.stats.avgTrackTime)} (${s(a.trackTimeImprovement)})`,`Overlay Render: ${r(e.stats.avgOverlayRenderTime)} → ${r(t.stats.avgOverlayRenderTime)} (${s(a.overlayRenderImprovement)})`,"","PERCENTILES","-----------",`P50 (Median): ${r(e.stats.p50TotalTime)} → ${r(t.stats.p50TotalTime)}`,`P95: ${r(e.stats.p95TotalTime)} → ${r(t.stats.p95TotalTime)}`,`P99: ${r(e.stats.p99TotalTime)} → ${r(t.stats.p99TotalTime)}`,"","BATCH STATISTICS","----------------",`Total Batches: ${e.stats.batchCount} → ${t.stats.batchCount}`,`Nodes Processed: ${e.stats.totalNodesProcessed.toLocaleString()} → ${t.stats.totalNodesProcessed.toLocaleString()}`];null!=e.memoryDelta&&null!=t.memoryDelta&&o.push("","MEMORY","------",`Memory Delta: ${(e.memoryDelta/1024/1024).toFixed(2)}MB → ${(t.memoryDelta/1024/1024).toFixed(2)}MB`),o.push("",`Compared at: ${new Date(a.comparedAt).toLocaleString()}`),await(0,_sharedUi.copyToClipboard)(o.join("\n"))},[g]),$=(0,_react.useCallback)(({item:e})=>(0,_jsxRuntime.jsx)(_BenchmarkSessionCard.BenchmarkSessionCard,{metadata:e,isSelected:p.has(e.id),onPress:()=>S(e),onLongPress:()=>C(e),selectionMode:_}),[_,p,S,C]),U=(0,_react.useCallback)(e=>e.id,[]),M=s?_sharedUi.devToolsStorageKeys.modal.root():_sharedUi.devToolsStorageKeys.benchmark.modal(),N=(0,_react.useMemo)(()=>"detail"===d&&l?l.name:"compare"===d?"Compare":_?0===p.size?"Select 2 to compare":1===p.size?"Select 1 more":`${p.size} Selected`:"Benchmarks",[d,l,_,p]),P="list"!==d||_||a;return e?(0,_jsxRuntime.jsxs)(_sharedUi.JsModal,{visible:e,onClose:t,onBack:P?v:void 0,onMinimize:r,persistenceKey:M,header:{showToggleButton:!0,customContent:(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[P&&(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:v}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:N}),(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader.Actions,{children:["list"===d&&!_&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_sharedUi.PowerToggleButton,{isEnabled:o,onToggle:b,accessibilityLabel:"Toggle benchmark recording"}),n.length>=2&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>h(!0),style:styles.iconButton,children:(0,_jsxRuntime.jsx)(_sharedUi.GitBranch,{size:14,color:_sharedUi.macOSColors.semantic.info})}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>R(e=>e+1),style:styles.iconButton,children:(0,_jsxRuntime.jsx)(_sharedUi.RefreshCw,{size:14,color:_sharedUi.macOSColors.text.secondary})}),n.length>0&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:k,style:styles.iconButton,children:(0,_jsxRuntime.jsx)(_sharedUi.Trash2,{size:14,color:_sharedUi.macOSColors.semantic.error})})]}),"detail"===d&&l&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:B,style:styles.iconButton,children:(0,_jsxRuntime.jsx)(_sharedUi.Edit3,{size:14,color:_sharedUi.macOSColors.text.secondary})}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:O,style:styles.iconButton,children:(0,_jsxRuntime.jsx)(_sharedUi.Trash2,{size:14,color:_sharedUi.macOSColors.semantic.error})})]}),"compare"===d&&g&&(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:w,style:styles.iconButton,children:(0,_jsxRuntime.jsx)(_sharedUi.Copy,{size:14,color:_sharedUi.macOSColors.text.secondary})})}),_&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[2===p.size&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:T,style:[styles.iconButton,styles.compareButton],children:(0,_jsxRuntime.jsx)(_sharedUi.GitBranch,{size:14,color:_sharedUi.macOSColors.semantic.info})}),p.size>0&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:f,style:styles.iconButton,children:(0,_jsxRuntime.jsx)(_sharedUi.Trash2,{size:14,color:_sharedUi.macOSColors.semantic.error})})]})]})]})},enablePersistence:!0,initialMode:"bottomSheet",enableGlitchEffects:!0,children:[o&&"list"===d&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.recordingBanner,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.recordingDot}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.recordingText,children:"Recording..."}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:b,style:styles.stopButton,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.stopButtonText,children:"Stop"})})]}),"detail"===d&&l?(0,_jsxRuntime.jsx)(_BenchmarkDetailView.BenchmarkDetailView,{report:l}):"compare"===d&&g?(0,_jsxRuntime.jsx)(_BenchmarkCompareView.BenchmarkCompareView,{baseline:g.baseline,comparison:g.comparison}):0===n.length?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.emptyState,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyIcon,children:"📊"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyTitle,children:"No Benchmarks Yet"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptySubtitle,children:"Press the record button to start capturing performance metrics"})]}):(0,_jsxRuntime.jsx)(_reactNative.FlatList,{data:n,renderItem:$,keyExtractor:U,contentContainerStyle:styles.listContent,ItemSeparatorComponent:()=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.separator}),scrollEnabled:!1})]}):null}const styles=_reactNative.StyleSheet.create({iconButton:{width:32,height:32,borderRadius:8,backgroundColor:_sharedUi.macOSColors.background.hover,borderWidth:1,borderColor:_sharedUi.macOSColors.border.default,alignItems:"center",justifyContent:"center"},compareButton:{backgroundColor:_sharedUi.macOSColors.semantic.infoBackground,borderColor:_sharedUi.macOSColors.semantic.info},listContent:{paddingVertical:16},separator:{height:8},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyIcon:{fontSize:48,marginBottom:16},emptyTitle:{fontSize:16,fontWeight:"600",color:_sharedUi.macOSColors.text.primary,fontFamily:"monospace",marginBottom:8},emptySubtitle:{fontSize:13,color:_sharedUi.macOSColors.text.secondary,fontFamily:"monospace",textAlign:"center"},recordingBanner:{flexDirection:"row",alignItems:"center",backgroundColor:_sharedUi.macOSColors.semantic.errorBackground,paddingHorizontal:16,paddingVertical:12,borderBottomWidth:1,borderColor:_sharedUi.macOSColors.semantic.error},recordingDot:{width:8,height:8,borderRadius:4,backgroundColor:_sharedUi.macOSColors.semantic.error,marginRight:8},recordingText:{flex:1,fontSize:13,fontWeight:"600",color:_sharedUi.macOSColors.semantic.error,fontFamily:"monospace"},stopButton:{paddingHorizontal:12,paddingVertical:6,backgroundColor:_sharedUi.macOSColors.semantic.error,borderRadius:4},stopButtonText:{fontSize:12,fontWeight:"600",color:"#fff",fontFamily:"monospace"}});var _default=exports.default=BenchmarkModal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import React,{useState,useEffect,useCallback,useRef,useMemo}from"react";import{View,Text,TouchableOpacity,StyleSheet,FlatList,Alert}from"react-native";import{JsModal,ModalHeader,macOSColors,devToolsStorageKeys,
|
|
1
|
+
"use strict";import React,{useState,useEffect,useCallback,useRef,useMemo}from"react";import{View,Text,TouchableOpacity,StyleSheet,FlatList,Alert}from"react-native";import{JsModal,ModalHeader,macOSColors,devToolsStorageKeys,Trash2,RefreshCw,GitBranch,Edit3,Copy,copyToClipboard,PowerToggleButton}from"@buoy-gg/shared-ui";import{benchmarkRecorder,BenchmarkStorage,BenchmarkComparator,createAsyncStorageAdapter}from"../benchmarking";import{BenchmarkSessionCard}from"./BenchmarkSessionCard";import{BenchmarkDetailView}from"./BenchmarkDetailView";import{BenchmarkCompareView}from"./BenchmarkCompareView";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const storageAdapter=createAsyncStorageAdapter(),storage=storageAdapter?new BenchmarkStorage(storageAdapter):null;export function BenchmarkModal({visible:e,onClose:t,onBack:o,onMinimize:a,enableSharedModalDimensions:s=!1}){const[r,n]=useState(!1),[i,l]=useState([]),[c,m]=useState(null),[d,p]=useState("list"),[u,g]=useState(!1),[h,y]=useState(new Set),[S,T]=useState(null),[C,x]=useState(0);useRef(!1),useEffect(()=>{e&&storage&&(async()=>{const e=await storage.listReports();l(e)})()},[e,C]),useEffect(()=>{const e=benchmarkRecorder.subscribe(e=>{"start"===e?n(!0):"stop"===e&&(n(!1),x(e=>e+1))});return n(benchmarkRecorder.isRecording()),e},[]);const b=useCallback(async()=>{if(r){const e=benchmarkRecorder.stopSession();e&&storage&&(await storage.saveReport(e),x(e=>e+1))}else{const e=(new Date).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});benchmarkRecorder.startSession({name:`Benchmark ${e}`,captureMemory:!0,verbose:!1})}},[r]),f=useCallback(async e=>{if(u)y(t=>{const o=new Set(t);return o.has(e.id)?o.delete(e.id):o.size<2&&o.add(e.id),o});else{if(!storage)return;const t=await storage.loadReport(e.id);t&&(m(t),p("detail"))}},[u]),k=useCallback(e=>{g(!0),y(new Set([e.id]))},[]),B=useCallback(async()=>{if(2!==h.size||!storage)return;const e=Array.from(h),[t,o]=await Promise.all([storage.loadReport(e[0]),storage.loadReport(e[1])]);if(t&&o){const[e,a]=t.createdAt<o.createdAt?[t,o]:[o,t];T({baseline:e,comparison:a}),p("compare"),g(!1),y(new Set)}},[h]),j=useCallback(async()=>{storage&&(await storage.clearAll(),x(e=>e+1))},[]),_=useCallback(async()=>{0!==h.size&&storage&&(await Promise.all(Array.from(h).map(e=>storage.deleteReport(e))),y(new Set),g(!1),x(e=>e+1))},[h]),$=useCallback(()=>{"detail"===d||"compare"===d?(p("list"),m(null),T(null)):u?(g(!1),y(new Set)):o&&o()},[d,u,o]),O=useCallback(()=>{c&&storage&&Alert.prompt("Rename Benchmark","Enter a new name for this benchmark:",[{text:"Cancel",style:"cancel"},{text:"Save",onPress:async e=>{e&&e.trim()&&(await storage.updateReport(c.id,{name:e.trim()}),m({...c,name:e.trim()}),x(e=>e+1))}}],"plain-text","")},[c]),w=useCallback(async()=>{c&&storage&&(await storage.deleteReport(c.id),p("list"),m(null),x(e=>e+1))},[c]),R=useCallback(async()=>{if(!S)return;const{baseline:e,comparison:t}=S,o=BenchmarkComparator.compare(e,t),a=e=>e<1?`${(1e3*e).toFixed(0)}μs`:e<10?`${e.toFixed(2)}ms`:e<100?`${e.toFixed(1)}ms`:`${e.toFixed(0)}ms`,s=e=>`${e>=0?"+":""}${e.toFixed(1)}%`,r=["BENCHMARK COMPARISON RESULTS","============================","",`Overall: ${o.isImproved?"IMPROVED":"REGRESSED"} ${s(o.overallImprovement)}`,"","COMPARING","---------",`Baseline: ${e.name}`,` Date: ${new Date(e.createdAt).toLocaleString()}`,`Comparison: ${t.name}`,` Date: ${new Date(t.createdAt).toLocaleString()}`,"","TIMING COMPARISON","-----------------",`Measure Time: ${a(e.stats.avgMeasureTime)} → ${a(t.stats.avgMeasureTime)} (${s(o.measureTimeImprovement)})`,`Pipeline Time: ${a(e.stats.avgTotalTime)} → ${a(t.stats.avgTotalTime)} (${s(o.pipelineTimeImprovement)})`,`Filter Time: ${a(e.stats.avgFilterTime)} → ${a(t.stats.avgFilterTime)} (${s(o.filterTimeImprovement)})`,`Track Time: ${a(e.stats.avgTrackTime)} → ${a(t.stats.avgTrackTime)} (${s(o.trackTimeImprovement)})`,`Overlay Render: ${a(e.stats.avgOverlayRenderTime)} → ${a(t.stats.avgOverlayRenderTime)} (${s(o.overlayRenderImprovement)})`,"","PERCENTILES","-----------",`P50 (Median): ${a(e.stats.p50TotalTime)} → ${a(t.stats.p50TotalTime)}`,`P95: ${a(e.stats.p95TotalTime)} → ${a(t.stats.p95TotalTime)}`,`P99: ${a(e.stats.p99TotalTime)} → ${a(t.stats.p99TotalTime)}`,"","BATCH STATISTICS","----------------",`Total Batches: ${e.stats.batchCount} → ${t.stats.batchCount}`,`Nodes Processed: ${e.stats.totalNodesProcessed.toLocaleString()} → ${t.stats.totalNodesProcessed.toLocaleString()}`];null!=e.memoryDelta&&null!=t.memoryDelta&&r.push("","MEMORY","------",`Memory Delta: ${(e.memoryDelta/1024/1024).toFixed(2)}MB → ${(t.memoryDelta/1024/1024).toFixed(2)}MB`),r.push("",`Compared at: ${new Date(o.comparedAt).toLocaleString()}`),await copyToClipboard(r.join("\n"))},[S]),v=useCallback(({item:e})=>_jsx(BenchmarkSessionCard,{metadata:e,isSelected:h.has(e.id),onPress:()=>f(e),onLongPress:()=>k(e),selectionMode:u}),[u,h,f,k]),M=useCallback(e=>e.id,[]),P=s?devToolsStorageKeys.modal.root():devToolsStorageKeys.benchmark.modal(),z=useMemo(()=>"detail"===d&&c?c.name:"compare"===d?"Compare":u?0===h.size?"Select 2 to compare":1===h.size?"Select 1 more":`${h.size} Selected`:"Benchmarks",[d,c,u,h]),A="list"!==d||u||o;return e?_jsxs(JsModal,{visible:e,onClose:t,onBack:A?$:void 0,onMinimize:a,persistenceKey:P,header:{showToggleButton:!0,customContent:_jsxs(ModalHeader,{children:[A&&_jsx(ModalHeader.Navigation,{onBack:$}),_jsx(ModalHeader.Content,{title:z}),_jsxs(ModalHeader.Actions,{children:["list"===d&&!u&&_jsxs(_Fragment,{children:[_jsx(PowerToggleButton,{isEnabled:r,onToggle:b,accessibilityLabel:"Toggle benchmark recording"}),i.length>=2&&_jsx(TouchableOpacity,{onPress:()=>g(!0),style:styles.iconButton,children:_jsx(GitBranch,{size:14,color:macOSColors.semantic.info})}),_jsx(TouchableOpacity,{onPress:()=>x(e=>e+1),style:styles.iconButton,children:_jsx(RefreshCw,{size:14,color:macOSColors.text.secondary})}),i.length>0&&_jsx(TouchableOpacity,{onPress:j,style:styles.iconButton,children:_jsx(Trash2,{size:14,color:macOSColors.semantic.error})})]}),"detail"===d&&c&&_jsxs(_Fragment,{children:[_jsx(TouchableOpacity,{onPress:O,style:styles.iconButton,children:_jsx(Edit3,{size:14,color:macOSColors.text.secondary})}),_jsx(TouchableOpacity,{onPress:w,style:styles.iconButton,children:_jsx(Trash2,{size:14,color:macOSColors.semantic.error})})]}),"compare"===d&&S&&_jsx(_Fragment,{children:_jsx(TouchableOpacity,{onPress:R,style:styles.iconButton,children:_jsx(Copy,{size:14,color:macOSColors.text.secondary})})}),u&&_jsxs(_Fragment,{children:[2===h.size&&_jsx(TouchableOpacity,{onPress:B,style:[styles.iconButton,styles.compareButton],children:_jsx(GitBranch,{size:14,color:macOSColors.semantic.info})}),h.size>0&&_jsx(TouchableOpacity,{onPress:_,style:styles.iconButton,children:_jsx(Trash2,{size:14,color:macOSColors.semantic.error})})]})]})]})},enablePersistence:!0,initialMode:"bottomSheet",enableGlitchEffects:!0,children:[r&&"list"===d&&_jsxs(View,{style:styles.recordingBanner,children:[_jsx(View,{style:styles.recordingDot}),_jsx(Text,{style:styles.recordingText,children:"Recording..."}),_jsx(TouchableOpacity,{onPress:b,style:styles.stopButton,children:_jsx(Text,{style:styles.stopButtonText,children:"Stop"})})]}),"detail"===d&&c?_jsx(BenchmarkDetailView,{report:c}):"compare"===d&&S?_jsx(BenchmarkCompareView,{baseline:S.baseline,comparison:S.comparison}):0===i.length?_jsxs(View,{style:styles.emptyState,children:[_jsx(Text,{style:styles.emptyIcon,children:"📊"}),_jsx(Text,{style:styles.emptyTitle,children:"No Benchmarks Yet"}),_jsx(Text,{style:styles.emptySubtitle,children:"Press the record button to start capturing performance metrics"})]}):_jsx(FlatList,{data:i,renderItem:v,keyExtractor:M,contentContainerStyle:styles.listContent,ItemSeparatorComponent:()=>_jsx(View,{style:styles.separator}),scrollEnabled:!1})]}):null}const styles=StyleSheet.create({iconButton:{width:32,height:32,borderRadius:8,backgroundColor:macOSColors.background.hover,borderWidth:1,borderColor:macOSColors.border.default,alignItems:"center",justifyContent:"center"},compareButton:{backgroundColor:macOSColors.semantic.infoBackground,borderColor:macOSColors.semantic.info},listContent:{paddingVertical:16},separator:{height:8},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyIcon:{fontSize:48,marginBottom:16},emptyTitle:{fontSize:16,fontWeight:"600",color:macOSColors.text.primary,fontFamily:"monospace",marginBottom:8},emptySubtitle:{fontSize:13,color:macOSColors.text.secondary,fontFamily:"monospace",textAlign:"center"},recordingBanner:{flexDirection:"row",alignItems:"center",backgroundColor:macOSColors.semantic.errorBackground,paddingHorizontal:16,paddingVertical:12,borderBottomWidth:1,borderColor:macOSColors.semantic.error},recordingDot:{width:8,height:8,borderRadius:4,backgroundColor:macOSColors.semantic.error,marginRight:8},recordingText:{flex:1,fontSize:13,fontWeight:"600",color:macOSColors.semantic.error,fontFamily:"monospace"},stopButton:{paddingHorizontal:12,paddingVertical:6,backgroundColor:macOSColors.semantic.error,borderRadius:4},stopButtonText:{fontSize:12,fontWeight:"600",color:"#fff",fontFamily:"monospace"}});export default BenchmarkModal;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/benchmark",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Performance benchmarking system for React Native dev tools",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"sideEffects": false,
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@buoy-gg/shared-ui": "2.1.
|
|
29
|
+
"@buoy-gg/shared-ui": "2.1.3"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@react-native-async-storage/async-storage": "*",
|