File tree Expand file tree Collapse file tree 4 files changed +9
-9
lines changed
Expand file tree Collapse file tree 4 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 1212
1313All results are relative to the Rust baseline (lower is better).
1414
15- ## 2024 (.NET 9)
15+ ## 2024 (.NET 9, Node.js 22 )
1616
1717| | Rust | Zig | .NET LLVM | Bootsharp | .NET AOT | Go |
1818| -------------| -------| -------| -----------| -----------| ----------| ---------|
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ crate-type = ["cdylib"]
99[dependencies ]
1010wasm-bindgen = " 0.2"
1111serde = { version = " 1.0" , features = [" derive" ] }
12- serde_json = " 1.0 "
12+ serde-wasm-bindgen = " 0.6 "
1313
1414[profile .release ]
1515codegen-units = 1
Original file line number Diff line number Diff line change @@ -4,10 +4,10 @@ import { getNumber, getStruct } from "../fixtures.mjs";
44/** @returns {Promise<import("../bench.mjs").Exports> } */
55export async function init ( ) {
66 global . getNumber = getNumber ;
7- global . getStruct = ( ) => JSON . stringify ( getStruct ( ) ) ;
7+ global . getStruct = getStruct ;
88 return {
99 echoNumber,
10- echoStruct : ( ) => JSON . parse ( echoStruct ( ) ) ,
10+ echoStruct,
1111 fi
1212 } ;
1313}
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ extern "C" {
1414 #[ wasm_bindgen( js_name = getNumber) ]
1515 fn get_number ( ) -> i32 ;
1616 #[ wasm_bindgen( js_name = getStruct) ]
17- fn get_struct ( ) -> String ;
17+ fn get_struct ( ) -> JsValue ;
1818}
1919
2020#[ wasm_bindgen( js_name = echoNumber) ]
@@ -23,10 +23,10 @@ pub fn echo_number() -> i32 {
2323}
2424
2525#[ wasm_bindgen( js_name = echoStruct) ]
26- pub fn echo_struct ( ) -> String {
27- let json = get_struct ( ) ;
28- let data: Data = serde_json :: from_str ( & json ) . unwrap ( ) ;
29- serde_json :: to_string ( & data) . unwrap ( )
26+ pub fn echo_struct ( ) -> Result < JsValue , JsValue > {
27+ let js_data = get_struct ( ) ;
28+ let data: Data = serde_wasm_bindgen :: from_value ( js_data ) ? ;
29+ Ok ( serde_wasm_bindgen :: to_value ( & data) ? )
3030}
3131
3232#[ wasm_bindgen]
You can’t perform that action at this time.
0 commit comments