Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(napi-derive): catch_unwind attribute
- Loading branch information
1 parent
bc69e15
commit 97659e4
Showing
12 changed files
with
55 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
use napi::bindgen_prelude::*; | ||
|
||
#[napi] | ||
fn throw_error() -> Result<()> { | ||
pub fn throw_error() -> Result<()> { | ||
Err(Error::new(Status::InvalidArg, "Manual Error".to_owned())) | ||
} | ||
|
||
#[napi(catch_unwind)] | ||
pub fn panic() { | ||
panic!("Don't panic"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97659e4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
noop#napi-rs
60426621
ops/sec (±0.36%
)59795184
ops/sec (±0.26%
)0.99
noop#JavaScript
595940093
ops/sec (±0.11%
)591426599
ops/sec (±0.85%
)0.99
Plus number#napi-rs
20560698
ops/sec (±0.69%
)20721781
ops/sec (±0.51%
)1.01
Plus number#JavaScript
594437491
ops/sec (±0.22%
)594960595
ops/sec (±0.08%
)1.00
Create buffer#napi-rs
427054
ops/sec (±7.03%
)436176
ops/sec (±7.38%
)1.02
Create buffer#JavaScript
1869852
ops/sec (±4.36%
)1582612
ops/sec (±49.38%
)0.85
createArray#createArrayJson
43096
ops/sec (±0.14%
)43174
ops/sec (±0.1%
)1.00
createArray#create array for loop
8067
ops/sec (±0.12%
)8070
ops/sec (±0.11%
)1.00
createArray#create array with serde trait
8016
ops/sec (±0.1%
)8018
ops/sec (±0.1%
)1.00
getArrayFromJs#get array from json string
17680
ops/sec (±0.15%
)17665
ops/sec (±0.14%
)1.00
getArrayFromJs#get array from serde
10767
ops/sec (±0.05%
)10792
ops/sec (±0.05%
)1.00
getArrayFromJs#get array with for loop
12611
ops/sec (±0.2%
)13157
ops/sec (±0.05%
)1.04
Get Set property#Get Set from native#u32
374182
ops/sec (±4.8%
)389557
ops/sec (±4.34%
)1.04
Get Set property#Get Set from JavaScript#u32
332581
ops/sec (±4.43%
)334551
ops/sec (±4.49%
)1.01
Get Set property#Get Set from native#string
351176
ops/sec (±4.7%
)361064
ops/sec (±4.31%
)1.03
Get Set property#Get Set from JavaScript#string
311788
ops/sec (±4.7%
)324569
ops/sec (±4.26%
)1.04
Async task#spawn task
36447
ops/sec (±0.82%
)36267
ops/sec (±0.98%
)1.00
Async task#ThreadSafeFunction
2445
ops/sec (±7.68%
)1992
ops/sec (±2.86%
)0.81
Async task#Tokio future to Promise
31065
ops/sec (±0.53%
)32020
ops/sec (±0.61%
)1.03
Query#query * 100
2194
ops/sec (±1.69%
)2196
ops/sec (±2.09%
)1.00
Query#query * 1
31988
ops/sec (±1.65%
)32783
ops/sec (±0.52%
)1.02
This comment was automatically generated by workflow using github-action-benchmark.