2022-06-20 07:06:04 -04:00
|
|
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
|
|
|
// deno-lint-ignore-file
|
|
|
|
|
|
|
|
const targetDir = Deno.execPath().replace(/[^\/\\]+$/, "");
|
|
|
|
const [libPrefix, libSuffix] = {
|
|
|
|
darwin: ["lib", "dylib"],
|
|
|
|
linux: ["lib", "so"],
|
|
|
|
windows: ["", "dll"],
|
|
|
|
}[Deno.build.os];
|
|
|
|
const libPath = `${targetDir}/${libPrefix}test_ffi.${libSuffix}`;
|
|
|
|
|
|
|
|
const dylib = Deno.dlopen(libPath, {
|
|
|
|
"nop": { parameters: [], result: "void" },
|
2022-07-08 13:49:09 -04:00
|
|
|
"add_u32": { parameters: ["u32", "u32"], result: "u32" },
|
2022-07-28 08:38:22 -04:00
|
|
|
"add_u64": { parameters: ["u64", "u64"], result: "u64" },
|
|
|
|
"ffi_string": { parameters: [], result: "pointer" },
|
2022-08-22 23:46:43 -04:00
|
|
|
"hash": { parameters: ["buffer", "u32"], result: "u32" },
|
2022-06-20 07:06:04 -04:00
|
|
|
"nop_u8": { parameters: ["u8"], result: "void" },
|
|
|
|
"nop_i8": { parameters: ["i8"], result: "void" },
|
|
|
|
"nop_u16": { parameters: ["u16"], result: "void" },
|
|
|
|
"nop_i16": { parameters: ["i16"], result: "void" },
|
|
|
|
"nop_u32": { parameters: ["u32"], result: "void" },
|
|
|
|
"nop_i32": { parameters: ["i32"], result: "void" },
|
|
|
|
"nop_u64": { parameters: ["u64"], result: "void" },
|
|
|
|
"nop_i64": { parameters: ["i64"], result: "void" },
|
|
|
|
"nop_usize": { parameters: ["usize"], result: "void" },
|
|
|
|
"nop_isize": { parameters: ["isize"], result: "void" },
|
|
|
|
"nop_f32": { parameters: ["f32"], result: "void" },
|
|
|
|
"nop_f64": { parameters: ["f64"], result: "void" },
|
2022-08-22 23:46:43 -04:00
|
|
|
"nop_buffer": { parameters: ["buffer"], result: "void" },
|
2022-06-20 07:06:04 -04:00
|
|
|
"return_u8": { parameters: [], result: "u8" },
|
|
|
|
"return_i8": { parameters: [], result: "i8" },
|
|
|
|
"return_u16": { parameters: [], result: "u16" },
|
|
|
|
"return_i16": { parameters: [], result: "i16" },
|
|
|
|
"return_u32": { parameters: [], result: "u32" },
|
|
|
|
"return_i32": { parameters: [], result: "i32" },
|
|
|
|
"return_u64": { parameters: [], result: "u64" },
|
|
|
|
"return_i64": { parameters: [], result: "i64" },
|
|
|
|
"return_usize": { parameters: [], result: "usize" },
|
|
|
|
"return_isize": { parameters: [], result: "isize" },
|
|
|
|
"return_f32": { parameters: [], result: "f32" },
|
|
|
|
"return_f64": { parameters: [], result: "f64" },
|
2022-08-22 23:46:43 -04:00
|
|
|
"return_buffer": { parameters: [], result: "buffer" },
|
2022-06-20 07:06:04 -04:00
|
|
|
// Nonblocking calls
|
|
|
|
"nop_nonblocking": { name: "nop", parameters: [], result: "void" },
|
|
|
|
"nop_u8_nonblocking": { name: "nop_u8", parameters: ["u8"], result: "void" },
|
|
|
|
"nop_i8_nonblocking": { name: "nop_i8", parameters: ["i8"], result: "void" },
|
|
|
|
"nop_u16_nonblocking": {
|
|
|
|
name: "nop_u16",
|
|
|
|
parameters: ["u16"],
|
|
|
|
result: "void",
|
|
|
|
},
|
|
|
|
"nop_i16_nonblocking": {
|
|
|
|
name: "nop_i16",
|
|
|
|
parameters: ["i16"],
|
|
|
|
result: "void",
|
|
|
|
},
|
|
|
|
"nop_u32_nonblocking": {
|
|
|
|
name: "nop_u32",
|
|
|
|
parameters: ["u32"],
|
|
|
|
result: "void",
|
|
|
|
},
|
|
|
|
"nop_i32_nonblocking": {
|
|
|
|
name: "nop_i32",
|
|
|
|
parameters: ["i32"],
|
|
|
|
result: "void",
|
|
|
|
},
|
|
|
|
"nop_u64_nonblocking": {
|
|
|
|
name: "nop_u64",
|
|
|
|
parameters: ["u64"],
|
|
|
|
result: "void",
|
|
|
|
},
|
|
|
|
"nop_i64_nonblocking": {
|
|
|
|
name: "nop_i64",
|
|
|
|
parameters: ["i64"],
|
|
|
|
result: "void",
|
|
|
|
},
|
|
|
|
"nop_usize_nonblocking": {
|
|
|
|
name: "nop_usize",
|
|
|
|
parameters: ["usize"],
|
|
|
|
result: "void",
|
|
|
|
},
|
|
|
|
"nop_isize_nonblocking": {
|
|
|
|
name: "nop_isize",
|
|
|
|
parameters: ["isize"],
|
|
|
|
result: "void",
|
|
|
|
},
|
|
|
|
"nop_f32_nonblocking": {
|
|
|
|
name: "nop_f32",
|
|
|
|
parameters: ["f32"],
|
|
|
|
result: "void",
|
|
|
|
},
|
|
|
|
"nop_f64_nonblocking": {
|
|
|
|
name: "nop_f64",
|
|
|
|
parameters: ["f64"],
|
|
|
|
result: "void",
|
|
|
|
},
|
|
|
|
"nop_buffer_nonblocking": {
|
|
|
|
name: "nop_buffer",
|
2022-08-22 23:46:43 -04:00
|
|
|
parameters: ["buffer"],
|
2022-06-20 07:06:04 -04:00
|
|
|
result: "void",
|
|
|
|
},
|
|
|
|
"return_u8_nonblocking": { name: "return_u8", parameters: [], result: "u8" },
|
|
|
|
"return_i8_nonblocking": { name: "return_i8", parameters: [], result: "i8" },
|
|
|
|
"return_u16_nonblocking": {
|
|
|
|
name: "return_u16",
|
|
|
|
parameters: [],
|
|
|
|
result: "u16",
|
|
|
|
},
|
|
|
|
"return_i16_nonblocking": {
|
|
|
|
name: "return_i16",
|
|
|
|
parameters: [],
|
|
|
|
result: "i16",
|
|
|
|
},
|
|
|
|
"return_u32_nonblocking": {
|
|
|
|
name: "return_u32",
|
|
|
|
parameters: [],
|
|
|
|
result: "u32",
|
|
|
|
},
|
|
|
|
"return_i32_nonblocking": {
|
|
|
|
name: "return_i32",
|
|
|
|
parameters: [],
|
|
|
|
result: "i32",
|
|
|
|
},
|
|
|
|
"return_u64_nonblocking": {
|
|
|
|
name: "return_u64",
|
|
|
|
parameters: [],
|
|
|
|
result: "u64",
|
|
|
|
},
|
|
|
|
"return_i64_nonblocking": {
|
|
|
|
name: "return_i64",
|
|
|
|
parameters: [],
|
|
|
|
result: "i64",
|
|
|
|
},
|
|
|
|
"return_usize_nonblocking": {
|
|
|
|
name: "return_usize",
|
|
|
|
parameters: [],
|
|
|
|
result: "usize",
|
|
|
|
},
|
|
|
|
"return_isize_nonblocking": {
|
|
|
|
name: "return_isize",
|
|
|
|
parameters: [],
|
|
|
|
result: "isize",
|
|
|
|
},
|
|
|
|
"return_f32_nonblocking": {
|
|
|
|
name: "return_f32",
|
|
|
|
parameters: [],
|
|
|
|
result: "f32",
|
|
|
|
},
|
|
|
|
"return_f64_nonblocking": {
|
|
|
|
name: "return_f64",
|
|
|
|
parameters: [],
|
|
|
|
result: "f64",
|
|
|
|
},
|
|
|
|
"return_buffer_nonblocking": {
|
|
|
|
name: "return_buffer",
|
|
|
|
parameters: [],
|
2022-08-22 23:46:43 -04:00
|
|
|
result: "buffer",
|
2022-06-20 07:06:04 -04:00
|
|
|
},
|
|
|
|
// Parameter checking
|
|
|
|
"nop_many_parameters": {
|
|
|
|
parameters: [
|
|
|
|
"u8",
|
|
|
|
"i8",
|
|
|
|
"u16",
|
|
|
|
"i16",
|
|
|
|
"u32",
|
|
|
|
"i32",
|
|
|
|
"u64",
|
|
|
|
"i64",
|
|
|
|
"usize",
|
|
|
|
"isize",
|
|
|
|
"f32",
|
|
|
|
"f64",
|
2022-08-22 23:46:43 -04:00
|
|
|
"buffer",
|
2022-06-20 07:06:04 -04:00
|
|
|
"u8",
|
|
|
|
"i8",
|
|
|
|
"u16",
|
|
|
|
"i16",
|
|
|
|
"u32",
|
|
|
|
"i32",
|
|
|
|
"u64",
|
|
|
|
"i64",
|
|
|
|
"usize",
|
|
|
|
"isize",
|
|
|
|
"f32",
|
|
|
|
"f64",
|
2022-08-22 23:46:43 -04:00
|
|
|
"buffer",
|
2022-06-20 07:06:04 -04:00
|
|
|
],
|
|
|
|
result: "void",
|
|
|
|
},
|
|
|
|
"nop_many_parameters_nonblocking": {
|
|
|
|
name: "nop_many_parameters",
|
|
|
|
parameters: [
|
|
|
|
"u8",
|
|
|
|
"i8",
|
|
|
|
"u16",
|
|
|
|
"i16",
|
|
|
|
"u32",
|
|
|
|
"i32",
|
|
|
|
"u64",
|
|
|
|
"i64",
|
|
|
|
"usize",
|
|
|
|
"isize",
|
|
|
|
"f32",
|
|
|
|
"f64",
|
|
|
|
"pointer",
|
|
|
|
"u8",
|
|
|
|
"i8",
|
|
|
|
"u16",
|
|
|
|
"i16",
|
|
|
|
"u32",
|
|
|
|
"i32",
|
|
|
|
"u64",
|
|
|
|
"i64",
|
|
|
|
"usize",
|
|
|
|
"isize",
|
|
|
|
"f32",
|
|
|
|
"f64",
|
|
|
|
"pointer",
|
|
|
|
],
|
|
|
|
result: "void",
|
|
|
|
nonblocking: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
nop();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-28 08:38:22 -04:00
|
|
|
const bytes = new Uint8Array(64);
|
|
|
|
|
|
|
|
const { hash } = dylib.symbols;
|
|
|
|
Deno.bench("hash()", () => {
|
|
|
|
hash(bytes, bytes.byteLength);
|
|
|
|
});
|
|
|
|
|
|
|
|
const { ffi_string } = dylib.symbols;
|
|
|
|
Deno.bench(
|
|
|
|
"c string",
|
|
|
|
() => new Deno.UnsafePointerView(ffi_string()).getCString(),
|
|
|
|
);
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { add_u32 } = dylib.symbols;
|
|
|
|
Deno.bench("add_u32()", () => {
|
|
|
|
add_u32(1, 2);
|
|
|
|
});
|
|
|
|
|
2022-07-28 08:38:22 -04:00
|
|
|
const { return_buffer } = dylib.symbols;
|
|
|
|
Deno.bench("return_buffer()", () => {
|
|
|
|
return_buffer();
|
|
|
|
});
|
2022-07-27 10:02:21 -04:00
|
|
|
|
2022-07-28 08:38:22 -04:00
|
|
|
const { add_u64 } = dylib.symbols;
|
|
|
|
Deno.bench("add_u64()", () => {
|
|
|
|
add_u64(1, 2);
|
|
|
|
});
|
|
|
|
|
|
|
|
const { return_u64 } = dylib.symbols;
|
|
|
|
Deno.bench("return_u64()", () => {
|
|
|
|
return_u64();
|
|
|
|
});
|
|
|
|
|
|
|
|
const { return_i64 } = dylib.symbols;
|
|
|
|
Deno.bench("return_i64()", () => {
|
|
|
|
return_i64();
|
2022-07-27 10:02:21 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_u8 } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_u8()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
nop_u8(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_i8 } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_i8()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
nop_i8(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_u16 } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_u16()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
nop_u16(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_i16 } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_i16()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
nop_i16(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_u32 } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_u32()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
nop_u32(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_i32 } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_i32()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
nop_i32(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_u64 } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_u64()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
nop_u64(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_i64 } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_i64()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
nop_i64(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_usize } = dylib.symbols;
|
2022-07-11 22:50:20 -04:00
|
|
|
Deno.bench("nop_usize() number", () => {
|
|
|
|
nop_usize(100);
|
|
|
|
});
|
|
|
|
|
|
|
|
Deno.bench("nop_usize() bigint", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
nop_usize(100n);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_isize } = dylib.symbols;
|
2022-07-11 22:50:20 -04:00
|
|
|
Deno.bench("nop_isize() number", () => {
|
|
|
|
nop_isize(100);
|
|
|
|
});
|
|
|
|
|
|
|
|
Deno.bench("nop_isize() bigint", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
nop_isize(100n);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_f32 } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_f32()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
nop_f32(100.1);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_f64 } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_f64()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
nop_f64(100.1);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_buffer } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
const buffer = new Uint8Array(8).fill(5);
|
2022-08-11 09:56:56 -04:00
|
|
|
// Make sure the buffer does not get collected
|
|
|
|
globalThis.buffer = buffer;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_buffer()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
nop_buffer(buffer);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_u8 } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_u8()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
return_u8();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_i8 } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_i8()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
return_i8();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_u16 } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_u16()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
return_u16();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_i16 } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_i16()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
return_i16();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_u32 } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_u32()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
return_u32();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_i32 } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_i32()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
return_i32();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_usize } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_usize()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
return_usize();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_isize } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_isize()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
return_isize();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_f32 } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_f32()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
return_f32();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_f64 } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_f64()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
return_f64();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
// Nonblocking calls
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await nop_nonblocking();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_u8_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_u8_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await nop_u8_nonblocking(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_i8_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_i8_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await nop_i8_nonblocking(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_u16_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_u16_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await nop_u16_nonblocking(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_i16_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_i16_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await nop_i16_nonblocking(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_u32_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_u32_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await nop_u32_nonblocking(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_i32_nonblocking } = dylib.symbols;
|
2022-08-22 23:46:43 -04:00
|
|
|
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_i32_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await nop_i32_nonblocking(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_u64_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_u64_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await nop_u64_nonblocking(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_i64_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_i64_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await nop_i64_nonblocking(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_usize_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_usize_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await nop_usize_nonblocking(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_isize_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_isize_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await nop_isize_nonblocking(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_f32_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_f32_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await nop_f32_nonblocking(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_f64_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_f64_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await nop_f64_nonblocking(100);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_buffer_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_buffer_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await nop_buffer_nonblocking(buffer);
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_u8_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_u8_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await return_u8_nonblocking();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_i8_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_i8_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await return_i8_nonblocking();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_u16_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_u16_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await return_u16_nonblocking();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_i16_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_i16_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await return_i16_nonblocking();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_u32_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_u32_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await return_u32_nonblocking();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_i32_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_i32_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await return_i32_nonblocking();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_u64_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_u64_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await return_u64_nonblocking();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_i64_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_i64_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await return_i64_nonblocking();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_usize_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_usize_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await return_usize_nonblocking();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_isize_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_isize_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await return_isize_nonblocking();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_f32_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_f32_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await return_f32_nonblocking();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_f64_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_f64_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await return_f64_nonblocking();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { return_buffer_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("return_buffer_nonblocking()", async () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
await return_buffer_nonblocking();
|
2022-06-20 07:06:04 -04:00
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_many_parameters } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
const buffer2 = new Uint8Array(8).fill(25);
|
2022-08-11 09:56:56 -04:00
|
|
|
// Make sure the buffer does not get collected
|
|
|
|
globalThis.buffer2 = buffer2;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_many_parameters()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
nop_many_parameters(
|
2022-06-20 07:06:04 -04:00
|
|
|
135,
|
|
|
|
47,
|
|
|
|
356,
|
|
|
|
-236,
|
|
|
|
7457,
|
|
|
|
-1356,
|
|
|
|
16471468n,
|
|
|
|
-1334748136n,
|
|
|
|
132658769535n,
|
|
|
|
-42745856824n,
|
|
|
|
13567.26437,
|
|
|
|
7.686234e-3,
|
|
|
|
buffer,
|
|
|
|
64,
|
|
|
|
-42,
|
|
|
|
83,
|
|
|
|
-136,
|
|
|
|
3657,
|
|
|
|
-2376,
|
|
|
|
3277918n,
|
|
|
|
-474628146n,
|
|
|
|
344657895n,
|
|
|
|
-2436732n,
|
|
|
|
135.26437e3,
|
|
|
|
264.3576468623546834,
|
|
|
|
buffer2,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2022-07-08 13:49:09 -04:00
|
|
|
const { nop_many_parameters_nonblocking } = dylib.symbols;
|
2022-06-20 07:06:04 -04:00
|
|
|
Deno.bench("nop_many_parameters_nonblocking()", () => {
|
2022-07-08 13:49:09 -04:00
|
|
|
nop_many_parameters_nonblocking(
|
2022-06-20 07:06:04 -04:00
|
|
|
135,
|
|
|
|
47,
|
|
|
|
356,
|
|
|
|
-236,
|
|
|
|
7457,
|
|
|
|
-1356,
|
|
|
|
16471468n,
|
|
|
|
-1334748136n,
|
|
|
|
132658769535n,
|
|
|
|
-42745856824n,
|
|
|
|
13567.26437,
|
|
|
|
7.686234e-3,
|
|
|
|
buffer,
|
|
|
|
64,
|
|
|
|
-42,
|
|
|
|
83,
|
|
|
|
-136,
|
|
|
|
3657,
|
|
|
|
-2376,
|
|
|
|
3277918n,
|
|
|
|
-474628146n,
|
|
|
|
344657895n,
|
|
|
|
-2436732n,
|
|
|
|
135.26437e3,
|
|
|
|
264.3576468623546834,
|
|
|
|
buffer2,
|
|
|
|
);
|
|
|
|
});
|
2022-07-22 07:07:35 -04:00
|
|
|
|
|
|
|
Deno.bench("Deno.UnsafePointer.of", () => {
|
|
|
|
Deno.UnsafePointer.of(buffer);
|
|
|
|
});
|
|
|
|
|
|
|
|
const cstringBuffer = new TextEncoder().encode("Best believe it!\0");
|
|
|
|
// Make sure the buffer does not get collected
|
|
|
|
globalThis.cstringBuffer = cstringBuffer;
|
|
|
|
const cstringPointerView = new Deno.UnsafePointerView(
|
|
|
|
Deno.UnsafePointer.of(cstringBuffer),
|
|
|
|
);
|
|
|
|
Deno.bench("Deno.UnsafePointerView#getCString", () => {
|
|
|
|
cstringPointerView.getCString();
|
|
|
|
});
|