Browse Source

add stress test for desktop

Evan Almloff 1 year ago
parent
commit
a4fbeeb932
2 changed files with 61 additions and 29 deletions
  1. 32 0
      packages/desktop/examples/stress.rs
  2. 29 29
      packages/desktop/src/minified.js

+ 32 - 0
packages/desktop/examples/stress.rs

@@ -0,0 +1,32 @@
+use dioxus::prelude::*;
+
+fn app(cx: Scope) -> Element {
+    let state = use_state(cx, || 0);
+    use_future(cx, (), |_| {
+        to_owned![state];
+        async move {
+            loop {
+                state += 1;
+                tokio::time::sleep(std::time::Duration::from_millis(1)).await;
+            }
+        }
+    });
+
+    cx.render(rsx! {
+        button {
+            onclick: move |_| {
+                state.set(0);
+            },
+            "reset"
+        }
+        for _ in 0..10000 {
+            div {
+                "hello desktop! {state}"
+            }
+        }
+    })
+}
+
+fn main() {
+    dioxus_desktop::launch(app);
+}

+ 29 - 29
packages/desktop/src/minified.js

@@ -853,7 +853,19 @@ function event_bubbles(event) {
 
   return true;
 }
-let u8buf,u8bufp;let s = "";let lsp,sp,sl; let c = new TextDecoder();let u32buf,u32bufp;const attr = [];
+let u32buf,u32bufp;let u8buf,u8bufp;let s = "";let lsp,sp,sl; let c = new TextDecoder();const ns_cache = [];
+                    let ns_cache_cache_hit, ns_cache_cache_idx;
+                    function get_ns_cache() {
+                        ns_cache_cache_idx = u8buf[u8bufp++];
+                        if(ns_cache_cache_idx & 128){
+                            ns_cache_cache_hit=s.substring(sp,sp+=u8buf[u8bufp++]);
+                            ns_cache[ns_cache_cache_idx&4294967167]=ns_cache_cache_hit;
+                            return ns_cache_cache_hit;
+                        }
+                        else{
+                            return ns_cache[ns_cache_cache_idx&4294967167];
+                        }
+                    }const attr = [];
                     let attr_cache_hit, attr_cache_idx;
                     function get_attr() {
                         attr_cache_idx = u8buf[u8bufp++];
@@ -877,17 +889,17 @@ let u8buf,u8bufp;let s = "";let lsp,sp,sl; let c = new TextDecoder();let u32buf,
                         else{
                             return evt[evt_cache_idx&4294967167];
                         }
-                    }const ns_cache = [];
-                    let ns_cache_cache_hit, ns_cache_cache_idx;
-                    function get_ns_cache() {
-                        ns_cache_cache_idx = u8buf[u8bufp++];
-                        if(ns_cache_cache_idx & 128){
-                            ns_cache_cache_hit=s.substring(sp,sp+=u8buf[u8bufp++]);
-                            ns_cache[ns_cache_cache_idx&4294967167]=ns_cache_cache_hit;
-                            return ns_cache_cache_hit;
+                    }const namespace = [];
+                    let namespace_cache_hit, namespace_cache_idx;
+                    function get_namespace() {
+                        namespace_cache_idx = u8buf[u8bufp++];
+                        if(namespace_cache_idx & 128){
+                            namespace_cache_hit=s.substring(sp,sp+=u8buf[u8bufp++]);
+                            namespace[namespace_cache_idx&4294967167]=namespace_cache_hit;
+                            return namespace_cache_hit;
                         }
                         else{
-                            return ns_cache[ns_cache_cache_idx&4294967167];
+                            return namespace[namespace_cache_idx&4294967167];
                         }
                     }const el = [];
                     let el_cache_hit, el_cache_idx;
@@ -901,20 +913,8 @@ let u8buf,u8bufp;let s = "";let lsp,sp,sl; let c = new TextDecoder();let u32buf,
                         else{
                             return el[el_cache_idx&4294967167];
                         }
-                    }const namespace = [];
-                    let namespace_cache_hit, namespace_cache_idx;
-                    function get_namespace() {
-                        namespace_cache_idx = u8buf[u8bufp++];
-                        if(namespace_cache_idx & 128){
-                            namespace_cache_hit=s.substring(sp,sp+=u8buf[u8bufp++]);
-                            namespace[namespace_cache_idx&4294967167]=namespace_cache_hit;
-                            return namespace_cache_hit;
-                        }
-                        else{
-                            return namespace[namespace_cache_idx&4294967167];
-                        }
                     }let u16buf,u16bufp;
-            let value,event_name,array,ns,many,bubbles,id,field;
+            let bubbles,field,value,array,event_name,many,id,ns;
              function create(r){
                 d=r;
             }
@@ -927,7 +927,11 @@ let u8buf,u8bufp;let s = "";let lsp,sp,sl; let c = new TextDecoder();let u32buf,
                     ls=m.getUint32(d+6*4,true);
                 }
                 p=ls;
-                if ((metaflags>>>5)&1){
+                if ((metaflags>>>3)&1){
+                t = m.getUint32(d+3*4,true);
+                u32buf=new Uint32Array(m.buffer,t,((m.buffer.byteLength-t)-(m.buffer.byteLength-t)%4)/4);
+            }
+            u32bufp=0;if ((metaflags>>>5)&1){
                 t = m.getUint32(d+5*4,true);
                 u8buf=new Uint8Array(m.buffer,t,((m.buffer.byteLength-t)-(m.buffer.byteLength-t)%1)/1);
             }
@@ -957,11 +961,7 @@ let u8buf,u8bufp;let s = "";let lsp,sp,sl; let c = new TextDecoder();let u32buf,
                     s = c.decode(new DataView(m.buffer, lsp, sl));
                 }
             }
-            sp=0;if ((metaflags>>>3)&1){
-                t = m.getUint32(d+3*4,true);
-                u32buf=new Uint32Array(m.buffer,t,((m.buffer.byteLength-t)-(m.buffer.byteLength-t)%4)/4);
-            }
-            u32bufp=0;if ((metaflags>>>4)&1){
+            sp=0;if ((metaflags>>>4)&1){
                 t = m.getUint32(d+4*4,true);
                 u16buf=new Uint16Array(m.buffer,t,((m.buffer.byteLength-t)-(m.buffer.byteLength-t)%2)/2);
             }