summaryrefslogtreecommitdiff
path: root/core/ops_builtin.rs
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2023-04-30 10:50:24 +0200
committerGitHub <noreply@github.com>2023-04-30 08:50:24 +0000
commitbb1f5e4262940a966e6314f57a4267514911d262 (patch)
tree0b5b870e34fca10daf8e664eb4214e5e756daf53 /core/ops_builtin.rs
parent9c8ebce3dcc784f1a6ecd29d5fe0b3d35256ab82 (diff)
perf(core): async op pseudo-codegen and performance work (#18887)
Performance: ``` async_ops.js: 760k -> 1030k (!) async_ops_deferred.js: 730k -> 770k Deno.serve bench: 118k -> 124k WS test w/ third_party/prebuilt/mac/load_test 100 localhost 8000 0 0: unchanged Startup time: approx 0.5ms slower (13.7 -> 14.2ms) ```
Diffstat (limited to 'core/ops_builtin.rs')
-rw-r--r--core/ops_builtin.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/ops_builtin.rs b/core/ops_builtin.rs
index 0c071a918..70f478acd 100644
--- a/core/ops_builtin.rs
+++ b/core/ops_builtin.rs
@@ -27,9 +27,12 @@ crate::extension!(
op_wasm_streaming_feed,
op_wasm_streaming_set_url,
op_void_sync,
+ op_error_async,
+ op_error_async_deferred,
op_void_async,
op_void_async_deferred,
op_add,
+ op_add_async,
// TODO(@AaronO): track IO metrics for builtin streams
op_read,
op_read_all,
@@ -96,12 +99,27 @@ fn op_add(a: i32, b: i32) -> i32 {
a + b
}
+#[op]
+pub async fn op_add_async(a: i32, b: i32) -> i32 {
+ a + b
+}
+
#[op(fast)]
pub fn op_void_sync() {}
#[op]
pub async fn op_void_async() {}
+#[op]
+pub async fn op_error_async() -> Result<(), Error> {
+ Err(Error::msg("error"))
+}
+
+#[op(deferred)]
+pub async fn op_error_async_deferred() -> Result<(), Error> {
+ Err(Error::msg("error"))
+}
+
#[op(deferred)]
pub async fn op_void_async_deferred() {}