From f1bacb076139cf1157fb0988e6dc224123cb5723 Mon Sep 17 00:00:00 2001 From: Deyaaeldeen Almahallawi Date: Wed, 6 Apr 2022 17:30:13 -0700 Subject: [PATCH 1/2] [Schema Registry Avro] Add perf test for deserialize --- .../test/deserialize.spec.ts | 42 +++++++++++++++++++ .../schema-registry-avro/test/index.spec.ts | 3 +- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 sdk/schemaregistry/perf-tests/schema-registry-avro/test/deserialize.spec.ts diff --git a/sdk/schemaregistry/perf-tests/schema-registry-avro/test/deserialize.spec.ts b/sdk/schemaregistry/perf-tests/schema-registry-avro/test/deserialize.spec.ts new file mode 100644 index 000000000000..248f23487601 --- /dev/null +++ b/sdk/schemaregistry/perf-tests/schema-registry-avro/test/deserialize.spec.ts @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { AvroSerializerTest } from "./avroSerializerTest.spec"; +import { PerfOptionDictionary } from "@azure/test-utils-perf"; +import { MessageContent } from "@azure/schema-registry-avro"; + +interface SerializePerfTestOptions { + "items-count": number; +} + +export class DeserializeTest extends AvroSerializerTest { + options: PerfOptionDictionary = { + "items-count": { + required: false, + description: "Number of array items", + shortName: "n", + longName: "items-count", + defaultValue: 1000, + }, + }; + serialized: MessageContent | undefined; + + constructor() { + super(); + this.options = this.parsedOptions; + } + + async setup(): Promise { + this.serialized = await this.serializer.serialize( + { + name: "test", + favoriteNumbers: [...Array(this.options["items-count"].value).keys()], + }, + AvroSerializerTest.schema + ); + } + + async run(): Promise { + await this.serializer.deserialize(this.serialized!); + } +} diff --git a/sdk/schemaregistry/perf-tests/schema-registry-avro/test/index.spec.ts b/sdk/schemaregistry/perf-tests/schema-registry-avro/test/index.spec.ts index e0360ffee560..54c6f761d496 100644 --- a/sdk/schemaregistry/perf-tests/schema-registry-avro/test/index.spec.ts +++ b/sdk/schemaregistry/perf-tests/schema-registry-avro/test/index.spec.ts @@ -3,12 +3,13 @@ import { PerfProgram, selectPerfTest } from "@azure/test-utils-perf"; import { SerializeTest } from "./serialize.spec"; +import { DeserializeTest } from "./deserialize.spec"; import dotenv from "dotenv"; dotenv.config(); console.log("=== Starting the perf test ==="); -const perfProgram = new PerfProgram(selectPerfTest([SerializeTest])); +const perfProgram = new PerfProgram(selectPerfTest([SerializeTest, DeserializeTest])); perfProgram.run(); From dc90e8d2085bf775bb2dedd91d076dcc8bb66628 Mon Sep 17 00:00:00 2001 From: Deyaaeldeen Almahallawi Date: Wed, 6 Apr 2022 17:39:59 -0700 Subject: [PATCH 2/2] edits --- sdk/schemaregistry/perf-tests/schema-registry-avro/README.md | 5 ++++- .../perf-tests/schema-registry-avro/test/deserialize.spec.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sdk/schemaregistry/perf-tests/schema-registry-avro/README.md b/sdk/schemaregistry/perf-tests/schema-registry-avro/README.md index c56c13ecf5eb..6e9811ab1346 100644 --- a/sdk/schemaregistry/perf-tests/schema-registry-avro/README.md +++ b/sdk/schemaregistry/perf-tests/schema-registry-avro/README.md @@ -7,5 +7,8 @@ 3. Create an Event Hubs account and populate the `.env` file with the relevant credentials. 4. Run the tests as follows - - detect language + - serialize - `npm run perf-test:node -- SerializeTest --warmup 1 --iterations 10 --parallel 100 --duration 15 --items-count 1000` + + - deserialize + - `npm run perf-test:node -- DeserializeTest --warmup 1 --iterations 10 --parallel 100 --duration 15 --items-count 1000` diff --git a/sdk/schemaregistry/perf-tests/schema-registry-avro/test/deserialize.spec.ts b/sdk/schemaregistry/perf-tests/schema-registry-avro/test/deserialize.spec.ts index 248f23487601..33ce601931f7 100644 --- a/sdk/schemaregistry/perf-tests/schema-registry-avro/test/deserialize.spec.ts +++ b/sdk/schemaregistry/perf-tests/schema-registry-avro/test/deserialize.spec.ts @@ -19,7 +19,7 @@ export class DeserializeTest extends AvroSerializerTest