@@ -40,44 +40,18 @@ export const hasValuesInSeries = series => {
4040} ;
4141
4242export const mapPerformanceDataToSeries = performanceData => {
43- const playersOnline = [ ] ;
44- const tps = [ ] ;
45- const cpu = [ ] ;
46- const ram = [ ] ;
47- const entities = [ ] ;
48- const chunks = [ ] ;
49- const disk = [ ] ;
50- const msptAverage = [ ] ;
51- const mspt95thPercentile = [ ] ;
52-
53- return new Promise ( ( resolve => {
54- let i = 0 ;
55- const length = performanceData . length ;
56-
57- function processNextThousand ( ) {
58- const to = Math . min ( i + 1000 , length ) ;
59- for ( i ; i < to ; i ++ ) {
60- const entry = performanceData [ i ] ;
61- const date = entry [ 0 ] ;
62- playersOnline [ i ] = [ date , entry [ 1 ] ] ;
63- tps [ i ] = [ date , entry [ 2 ] ] ;
64- cpu [ i ] = [ date , entry [ 3 ] ] ;
65- ram [ i ] = [ date , entry [ 4 ] ] ;
66- entities [ i ] = [ date , entry [ 5 ] ] ;
67- chunks [ i ] = [ date , entry [ 6 ] ] ;
68- disk [ i ] = [ date , entry [ 7 ] ] ;
69- msptAverage [ i ] = [ date , entry [ 8 ] ] ;
70- mspt95thPercentile [ i ] = [ date , entry [ 9 ] ] ;
71- }
72- if ( i >= length ) {
73- resolve ( { playersOnline, tps, cpu, ram, entities, chunks, disk, msptAverage, mspt95thPercentile} ) ;
74- } else {
75- setTimeout ( processNextThousand , 10 ) ;
76- }
77- }
78-
79- processNextThousand ( ) ;
80- } ) )
43+ const worker = new Worker ( new URL ( './workers/performanceGraphWorker.js' , import . meta. url ) ) ;
44+ return new Promise ( ( resolve , error ) => {
45+ worker . onmessage = e => {
46+ resolve ( e . data )
47+ worker . terminate ( ) ;
48+ } ;
49+ worker . onerror = e => {
50+ error ( new Error ( e . message ) ) ;
51+ worker . terminate ( ) ;
52+ } ;
53+ worker . postMessage ( performanceData ) ;
54+ } ) ;
8155} ;
8256
8357export const yAxisConfigurations = {
0 commit comments