11// smithy-typescript generated code
2+ import { HttpResponse } from "@smithy/types" ;
23import { afterAll , expect , test as it } from "vitest" ;
34
45import { GetNumbersCommand } from "../../src/commands/GetNumbersCommand" ;
@@ -303,13 +304,18 @@ it("HttpLabelCommandExample:Response", async () => {
303304it ( "GetNumbersRequestExample:SerdeBenchmark:Request" , async ( ) => {
304305 const client = new XYZServiceClient ( {
305306 ...clientParams ,
306- requestHandler : new RequestSerializationTestHandler ( ) ,
307307 } ) ;
308308
309309 const command = new GetNumbersCommand (
310310 {
311311 } as any ,
312312 ) ;
313+ const protocol = client . config . protocol ;
314+ const [ , namespace , _name , traits , input , output ] = command . schema as any ;
315+ const $schema = { namespace, name : _name , traits, input, output} as any ;
316+ const $input = command . input as any ;
317+ const $context = client . config as any ;
318+
313319 const name = "GetNumbersRequestExample:SerdeBenchmark:Request" ;
314320 const timings = [ ] as number [ ] ;
315321 const testStart = performance . now ( ) ;
@@ -318,21 +324,11 @@ it("GetNumbersRequestExample:SerdeBenchmark:Request", async () => {
318324
319325 while ( ++ i ) {
320326 const preSerialize = performance . now ( ) ;
321- try {
322- await client . send ( command ) ;
323- fail ( "Expected an EXPECTED_REQUEST_SERIALIZATION_ERROR to be thrown" ) ;
324- return ;
325- } catch ( err ) {
326- if ( ! ( err instanceof EXPECTED_REQUEST_SERIALIZATION_ERROR ) ) {
327- fail ( err ) ;
328- return ;
329- }
330- const r = err . request ;
331- } ;
327+ await ( protocol . serializeRequest as any ) ( $schema , $input , $context ) ;
332328 const postSerialize = performance . now ( ) ;
333329 if ( i >= WARMUP_ITERATIONS ) {
334330 // allow warmup
335- timings . push ( postSerialize * 1_000_000 - preSerialize * 1_000_000 ) ;
331+ timings . push ( postSerialize * 1_000_000 - preSerialize * 1_000_000 ) ;
336332 }
337333
338334 if ( timings . length >= BENCHMARK_ITERATIONS ) {
@@ -379,54 +375,42 @@ it("EndpointResolvedHeadersApplied:Request", async () => {
379375} ) ;
380376
381377it ( "GetNumbersResponseExample:SerdeBenchmark:Response" , async ( ) => {
378+ const params : any = { } ;
379+ const command = new GetNumbersCommand ( params ) ;
380+
382381 const client = new XYZServiceClient ( {
383382 ...clientParams ,
384- requestHandler : new ResponseDeserializationTestHandler (
385- true ,
386- 200 ,
387- {
388- "smithy-protocol" : "rpc-v2-cbor" ,
389- }
390- ) ,
391383 } ) ;
392384
393- const params : any = { } ;
394- const command = new GetNumbersCommand ( params ) ;
385+ const [ , namespace , _name , traits , input , output ] = command . schema as any ;
386+ const $schema = { namespace, name : _name , traits, input, output} as any ;
387+ const $context = client . config as any ;
388+ const protocol = client . config . protocol as any ;
395389
396390 const name = "GetNumbersResponseExample:SerdeBenchmark:Response" ;
397391 const timings = [ ] as number [ ] ;
398392 const numeric = ( a : number , b : number ) => a - b ;
399393 let i = 0 ;
400394
401- client . middlewareStack . addRelativeTo (
402- ( next : any ) => async ( args : any ) => {
403- const preDeserialize = performance . now ( ) ;
404- const r = await next ( args ) ;
405- const postDeserialize = performance . now ( ) ;
406- if ( i >= WARMUP_ITERATIONS ) {
407- timings . push ( postDeserialize * 1_000_000 - preDeserialize * 1_000_000 ) ;
408- }
409- return r ;
410- } ,
411- {
412- name : "deserializerBenchmarkMiddleware" ,
413- toMiddleware : "deserializerMiddleware" ,
414- relation : "before" ,
415- override : true ,
416- }
417- ) ;
418-
419395 const benchmarkStart = performance . now ( ) ;
420396
421397 while ( ++ i ) {
422- let r : any ;
423- try {
424- r = await client . send ( command ) ;
425- } catch ( err ) {
426- fail ( "Expected a valid response to be returned, got " + err ) ;
427- return ;
398+ const $httpResponse = new HttpResponse ( {
399+ statusCode : 200 ,
400+ headers : {
401+ "smithy-protocol" : "rpc-v2-cbor" ,
402+ } ,
403+ body : undefined ,
404+ } ) ;
405+ const preDeserialize = performance . now ( ) ;
406+ await ( protocol . deserializeResponse as any ) ( $schema , $context , $httpResponse ) ;
407+ const postDeserialize = performance . now ( ) ;
408+ if ( i >= WARMUP_ITERATIONS ) {
409+ timings . push ( postDeserialize * 1_000_000 - preDeserialize * 1_000_000 ) ;
428410 }
429- if ( i >= WARMUP_ITERATIONS + BENCHMARK_ITERATIONS ) {
411+
412+ if ( timings . length >= BENCHMARK_ITERATIONS ) {
413+ timings . length = BENCHMARK_ITERATIONS ;
430414 break ;
431415 } else if ( benchmarkStart + 30_000 < performance . now ( ) ) {
432416 break ;
0 commit comments