From 7b4c29d26afa66782e190f3b9cf18d110ee5ae86 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 18 Oct 2023 21:55:43 +0300 Subject: [PATCH] chore: remove unused code --- packages/protons-benchmark/package.json | 3 +- .../src/implementations/decode.ts | 50 ------------------ .../src/implementations/encode.ts | 48 ----------------- .../src/implementations/rpc.proto | 52 ------------------- .../src/implementations/rpc.ts | 49 ----------------- 5 files changed, 1 insertion(+), 201 deletions(-) delete mode 100644 packages/protons-benchmark/src/implementations/decode.ts delete mode 100644 packages/protons-benchmark/src/implementations/encode.ts delete mode 100644 packages/protons-benchmark/src/implementations/rpc.proto delete mode 100644 packages/protons-benchmark/src/implementations/rpc.ts diff --git a/packages/protons-benchmark/package.json b/packages/protons-benchmark/package.json index b536c1d..f8e1354 100644 --- a/packages/protons-benchmark/package.json +++ b/packages/protons-benchmark/package.json @@ -56,8 +56,7 @@ "protobufjs": "^7.0.0", "protons": "^7.0.0", "protons-runtime": "^5.0.0", - "uint8arraylist": "^2.4.3", - "uint8arrays": "^4.0.2" + "uint8arraylist": "^2.4.3" }, "private": true } diff --git a/packages/protons-benchmark/src/implementations/decode.ts b/packages/protons-benchmark/src/implementations/decode.ts deleted file mode 100644 index 1506b7b..0000000 --- a/packages/protons-benchmark/src/implementations/decode.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* eslint-disable no-console */ - -/* -$ node dist/src/index.js -$ npx playwright-test dist/src/index.js --runner benchmark -*/ - -import Benchmark from 'benchmark' -import { decodeTest as pbjsDecodeTest } from './pbjs/bench.js' -import { Test as ProtobufjsTest } from './protobufjs/bench.js' -import { Test as ProtonsTest } from './protons/bench.js' - -const message = { - meh: { - lol: 'sdkljfoee', - b: { - tmp: { - baz: 2309292 - } - } - }, - hello: 3493822, - foo: 'derp derp derp', - payload: Uint8Array.from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) -} - -const buf = ProtonsTest.encode(message).subarray() - -new Benchmark.Suite() - .add('pbjs', () => { - pbjsDecodeTest(buf) - }) - .add('protons', () => { - ProtonsTest.decode(buf) - }) - .add('protobufjs', () => { - ProtobufjsTest.decode(buf) - }) - .on('error', (err: Error) => { - console.error(err) - }) - .on('cycle', (event: any) => { - console.info(String(event.target)) - }) - .on('complete', function () { - // @ts-expect-error types are wrong - console.info(`Fastest is ${this.filter('fastest').map('name')}`) - }) - // run async - .run({ async: true }) diff --git a/packages/protons-benchmark/src/implementations/encode.ts b/packages/protons-benchmark/src/implementations/encode.ts deleted file mode 100644 index 6218836..0000000 --- a/packages/protons-benchmark/src/implementations/encode.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* eslint-disable no-console */ - -/* -$ node dist/src/index.js -$ npx playwright-test dist/src/index.js --runner benchmark -*/ - -import Benchmark from 'benchmark' -import { encodeTest as pbjsEncodeTest } from './pbjs/bench.js' -import { Test as ProtobufjsTest } from './protobufjs/bench.js' -import { Test as ProtonsTest } from './protons/bench.js' - -const message = { - meh: { - lol: 'sdkljfoee', - b: { - tmp: { - baz: 2309292 - } - } - }, - hello: 3493822, - foo: 'derp derp derp', - payload: Uint8Array.from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) -} - -new Benchmark.Suite() - .add('pbjs', () => { - pbjsEncodeTest(message) - }) - .add('protons', () => { - ProtonsTest.encode(message) - }) - .add('protobufjs', () => { - ProtobufjsTest.encode(message).finish() - }) - .on('error', (err: Error) => { - console.error(err) - }) - .on('cycle', (event: any) => { - console.info(String(event.target)) - }) - .on('complete', function () { - // @ts-expect-error types are wrong - console.info(`Fastest is ${this.filter('fastest').map('name')}`) - }) - // run async - .run({ async: true }) diff --git a/packages/protons-benchmark/src/implementations/rpc.proto b/packages/protons-benchmark/src/implementations/rpc.proto deleted file mode 100644 index eb1a81d..0000000 --- a/packages/protons-benchmark/src/implementations/rpc.proto +++ /dev/null @@ -1,52 +0,0 @@ -syntax = "proto3"; - -message RPC { - repeated SubOpts subscriptions = 1; - repeated Message messages = 2; - optional ControlMessage control = 3; - - message SubOpts { - optional bool subscribe = 1; // subscribe or unsubcribe - optional string topic = 2; - } - - message Message { - optional bytes from = 1; - optional bytes data = 2; - optional bytes seqno = 3; - string topic = 4; - optional bytes signature = 5; - optional bytes key = 6; - } - - message ControlMessage { - repeated ControlIHave ihave = 1; - repeated ControlIWant iwant = 2; - repeated ControlGraft graft = 3; - repeated ControlPrune prune = 4; - } - - message ControlIHave { - optional string topicID = 1; - repeated bytes messageIDs = 2; - } - - message ControlIWant { - repeated bytes messageIDs = 1; - } - - message ControlGraft { - optional string topicID = 1; - } - - message ControlPrune { - optional string topicID = 1; - repeated PeerInfo peers = 2; - optional uint64 backoff = 3; - } - - message PeerInfo { - optional bytes peerID = 1; - optional bytes signedPeerRecord = 2; - } -} diff --git a/packages/protons-benchmark/src/implementations/rpc.ts b/packages/protons-benchmark/src/implementations/rpc.ts deleted file mode 100644 index c5af0f3..0000000 --- a/packages/protons-benchmark/src/implementations/rpc.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* eslint-disable no-console */ - -/* -$ node dist/src/index.js -$ npx playwright-test dist/src/index.js --runner benchmark -*/ - -import Benchmark from 'benchmark' -import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' -import { RPC as ProtobufjsRPC } from './protobufjs/rpc.js' -import { RPC as ProtonsRPC } from './protons/rpc.js' - -const rpc = { - subscriptions: [], - messages: [ - { - topic: 'topic1', - // typical Attestation - data: uint8ArrayFromString( - 'e40000000a000000000000000a00000000000000a45c8daa336e17a150300afd4c717313c84f291754c51a378f20958083c5fa070a00000000000000a45c8daa336e17a150300afd4c717313c84f291754c51a378f20958083c5fa070a00000000000000a45c8daa336e17a150300afd4c717313c84f291754c51a378f20958083c5fa0795d2ef8ae4e2b4d1e5b3d5ce47b518e3db2c8c4d082e4498805ac2a686c69f248761b78437db2927470c1e77ede9c18606110faacbcbe4f13052bde7f7eff6aab09edf7bc4929fda2230f943aba2c47b6f940d350cb20c76fad4a8d40e2f3f1f01', - 'hex' - ), - signature: Uint8Array.from(Array.from({ length: 96 }, () => 100)) - } - ], - control: undefined -} - -const bytes = ProtobufjsRPC.encode(rpc).finish() - -new Benchmark.Suite() - .add('protons', () => { - ProtonsRPC.decode(bytes) - }) - .add('protobufjs', () => { - ProtobufjsRPC.decode(bytes) - }) - .on('error', (err: Error) => { - console.error(err) - }) - .on('cycle', (event: any) => { - console.info(String(event.target)) - }) - .on('complete', function () { - // @ts-expect-error types are wrong - console.info(`Fastest is ${this.filter('fastest').map('name')}`) - }) - // run async - .run({ async: true })