From 6edf4190504f19974de76ec77ae33413646fe8a5 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 22 Jun 2026 04:14:52 +0000 Subject: [PATCH] bench: add benchmark to `utils/async/series-waterfall` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a missing `benchmark/benchmark.js` (present in 32/33 sibling packages — 97% conformance) and the corresponding `directories.benchmark` entry in `package.json` (also 32/33). Modeled after the sibling pattern used in `function-sequence` and `parallel`, exercising the waterfall through a fixed-length sequence of async callbacks. --- .../series-waterfall/benchmark/benchmark.js | 82 +++++++++++++++++++ .../utils/async/series-waterfall/package.json | 1 + 2 files changed, 83 insertions(+) create mode 100644 lib/node_modules/@stdlib/utils/async/series-waterfall/benchmark/benchmark.js diff --git a/lib/node_modules/@stdlib/utils/async/series-waterfall/benchmark/benchmark.js b/lib/node_modules/@stdlib/utils/async/series-waterfall/benchmark/benchmark.js new file mode 100644 index 000000000000..35787b6f0a12 --- /dev/null +++ b/lib/node_modules/@stdlib/utils/async/series-waterfall/benchmark/benchmark.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pkg = require( './../package.json' ).name; +var waterfall = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var fcns; + var i; + + fcns = [ foo, bar, fun ]; + + i = 0; + b.tic(); + + return next(); + + function next( error ) { + i += 1; + if ( error ) { + b.fail( 'should not return an error' ); + } + if ( i <= b.iterations ) { + return waterfall( fcns, done ); + } + b.toc(); + b.pass( 'benchmark finished' ); + b.end(); + } + + function foo( clbk ) { + setTimeout( onTimeout, 0 ); + function onTimeout() { + clbk( null, 'beep' ); + } + } + + function bar( str, clbk ) { + setTimeout( onTimeout, 0 ); + function onTimeout() { + clbk( null, str + ' boop' ); + } + } + + function fun( str, clbk ) { + setTimeout( onTimeout, 0 ); + function onTimeout() { + clbk( null ); + } + } + + function done( error ) { + if ( error ) { + next( error ); + return; + } + next(); + } +}); diff --git a/lib/node_modules/@stdlib/utils/async/series-waterfall/package.json b/lib/node_modules/@stdlib/utils/async/series-waterfall/package.json index 089dedf7ce84..cf6ec4533f99 100644 --- a/lib/node_modules/@stdlib/utils/async/series-waterfall/package.json +++ b/lib/node_modules/@stdlib/utils/async/series-waterfall/package.json @@ -15,6 +15,7 @@ ], "main": "./lib", "directories": { + "benchmark": "./benchmark", "doc": "./docs", "example": "./examples", "lib": "./lib",