From fd9945ee46b1b4ee31db3ddd61a41ca1045612f0 Mon Sep 17 00:00:00 2001 From: MierenManz <63878374+MierenManz@users.noreply.github.com> Date: Wed, 6 Mar 2024 09:31:42 +0100 Subject: [PATCH] fix: Broken benchmarks (#33) --- benchmarks/popular_encodings.ts | 10 +++++----- benchmarks/string.ts | 2 +- src/string/prefixed_length.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/benchmarks/popular_encodings.ts b/benchmarks/popular_encodings.ts index e7de2c0..944135d 100644 --- a/benchmarks/popular_encodings.ts +++ b/benchmarks/popular_encodings.ts @@ -8,7 +8,7 @@ const descriptor = { handIndex: u8, fieldIndex: u8, card: new Struct({ - name: new Strings.FixedLength(11), + name: new Strings.FixedLengthString(11), hp: u8, damage: u8, shield: u32, @@ -68,7 +68,7 @@ Deno.bench({ name: "Struct (Write)", group: "write", fn: () => { - codec.writeUnaligned(data, DATA_VIEW); + codec.writePacked(data, DATA_VIEW); }, }); @@ -76,7 +76,7 @@ Deno.bench({ name: "Struct (Read)", group: "read", fn: () => { - codec.readUnaligned(DATA_VIEW); + codec.readPacked(DATA_VIEW); }, }); @@ -84,8 +84,8 @@ Deno.bench({ name: "Struct (Roundtrip)", group: "roundtrip", fn: () => { - codec.writeUnaligned(data, DATA_VIEW); - codec.readUnaligned(DATA_VIEW); + codec.writePacked(data, DATA_VIEW); + codec.readPacked(DATA_VIEW); }, }); diff --git a/benchmarks/string.ts b/benchmarks/string.ts index 9727317..191125c 100644 --- a/benchmarks/string.ts +++ b/benchmarks/string.ts @@ -1,6 +1,6 @@ import { Strings } from "../mod.ts"; -const stringThing = new Strings.FixedLength(12); +const stringThing = new Strings.FixedLengthString(12); const ab = new TextEncoder().encode("Hello World!").buffer; const dt = new DataView(ab); diff --git a/src/string/prefixed_length.ts b/src/string/prefixed_length.ts index 03448b4..d0ef221 100644 --- a/src/string/prefixed_length.ts +++ b/src/string/prefixed_length.ts @@ -1,5 +1,5 @@ import { u8, UnsizedType } from "../mod.ts"; -import { Options } from "../types/_common.ts"; +import type { Options } from "../types/mod.ts"; import { TEXT_DECODER, TEXT_ENCODER } from "./_common.ts"; export class PrefixedString extends UnsizedType {