diff --git a/lib/node_modules/@stdlib/dstructs/compact-adjacency-matrix/benchmark/benchmark.js b/lib/node_modules/@stdlib/dstructs/compact-adjacency-matrix/benchmark/benchmark.js new file mode 100644 index 000000000000..f884db4369f0 --- /dev/null +++ b/lib/node_modules/@stdlib/dstructs/compact-adjacency-matrix/benchmark/benchmark.js @@ -0,0 +1,71 @@ +/** +* @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 instanceOf = require( '@stdlib/assert/instance-of' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var CompactAdjacencyMatrix = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::instantiation,new', pkg ), function benchmark( b ) { + var adj; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + adj = new CompactAdjacencyMatrix( 10 ); + if ( typeof adj !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !instanceOf( adj, CompactAdjacencyMatrix ) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::instantiation,no_new', pkg ), function benchmark( b ) { + var compactAdjacencyMatrix; + var adj; + var i; + + compactAdjacencyMatrix = CompactAdjacencyMatrix; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + adj = compactAdjacencyMatrix( 10 ); + if ( typeof adj !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !instanceOf( adj, CompactAdjacencyMatrix ) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/dstructs/compact-adjacency-matrix/package.json b/lib/node_modules/@stdlib/dstructs/compact-adjacency-matrix/package.json index 79ea204cb5df..4e595d43a754 100644 --- a/lib/node_modules/@stdlib/dstructs/compact-adjacency-matrix/package.json +++ b/lib/node_modules/@stdlib/dstructs/compact-adjacency-matrix/package.json @@ -15,6 +15,7 @@ ], "main": "./lib", "directories": { + "benchmark": "./benchmark", "doc": "./docs", "example": "./examples", "lib": "./lib",