Skip to content

Commit 8e5cc65

Browse files
committed
Auto-generated commit
1 parent 5518b90 commit 8e5cc65

7 files changed

Lines changed: 184 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ This release closes the following issue:
8888

8989
<details>
9090

91+
- [`e805b48`](https://github.com/stdlib-js/stdlib/commit/e805b48af03299edd06969a72e9bf03ccb344aa5) - **bench:** fix assignment operation _(by Athan Reines)_
92+
- [`3fdf0b9`](https://github.com/stdlib-js/stdlib/commit/3fdf0b943c342271e5ee4b80d7bf30cb2b5de1e1) - **bench:** reassign variable _(by Athan Reines)_
93+
- [`075283f`](https://github.com/stdlib-js/stdlib/commit/075283f8cdb22dd49286c6fa7ddc874b584af48d) - **bench:** reassign variable _(by Athan Reines)_
94+
- [`d47c19d`](https://github.com/stdlib-js/stdlib/commit/d47c19dbaa8eaae1e440307c9b4b6727f227fa07) - **bench:** add `copyWithin` benchmarks _(by Athan Reines)_
95+
- [`35f9d71`](https://github.com/stdlib-js/stdlib/commit/35f9d71411350aefc5992d63febbf0ad71bbff12) - **bench:** fix benchmarks _(by Athan Reines)_
9196
- [`0078b7e`](https://github.com/stdlib-js/stdlib/commit/0078b7ed60fc8040a9d11a6d1c4d94bc34e4df5a) - **feat:** add float16 dtype support to `array/ones-like` [(#14124)](https://github.com/stdlib-js/stdlib/pull/14124) _(by Gururaj Gurram)_
9297
- [`2e31902`](https://github.com/stdlib-js/stdlib/commit/2e31902b44dfa195f9caa5ece57b1649a000e47a) - **feat:** add float16 dtype support to `array/ones` [(#14123)](https://github.com/stdlib-js/stdlib/pull/14123) _(by Gururaj Gurram)_
9398
- [`4d0ce60`](https://github.com/stdlib-js/stdlib/commit/4d0ce60011997633aac407dbba435da1763a2550) - **feat:** add float16 dtype support to `array/convert-same` [(#14126)](https://github.com/stdlib-js/stdlib/pull/14126) _(by Gururaj Gurram)_

bool/benchmark/benchmark.copy_within.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
var bench = require( '@stdlib/bench' );
2424
var format = require( '@stdlib/string/format' );
25+
var reinterpret = require( '@stdlib/strided/base/reinterpret-boolean' );
2526
var pkg = require( './../package.json' ).name;
2627
var BooleanArray = require( './../lib' );
2728

@@ -38,13 +39,13 @@ bench( format( '%s:copyWithin', pkg ), function benchmark( b ) {
3839
arr.push( i%2 );
3940
}
4041
arr = new BooleanArray( arr );
41-
buf = arr.buffer;
42+
buf = reinterpret( arr, 0 );
4243

4344
b.tic();
4445
for ( i = 0; i < b.iterations; i++ ) {
4546
buf[ 0 ] = i%2;
4647
arr = arr.copyWithin( 1, 0 );
47-
if ( buf[ 0 ] !== i%2 ) {
48+
if ( typeof arr !== 'object' ) {
4849
b.fail( 'unexpected result' );
4950
}
5051
}

bool/benchmark/benchmark.copy_within.length.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
var bench = require( '@stdlib/bench' );
2424
var pow = require( '@stdlib/math/base/special/pow' );
25+
var reinterpret = require( '@stdlib/strided/base/reinterpret-boolean' );
2526
var format = require( '@stdlib/string/format' );
2627
var pkg = require( './../package.json' ).name;
2728
var BooleanArray = require( './../lib' );
@@ -46,7 +47,7 @@ function createBenchmark( len ) {
4647
arr.push( i%2 );
4748
}
4849
arr = new BooleanArray( arr );
49-
buf = arr.buffer;
50+
buf = reinterpret( arr, 0 );
5051

5152
return benchmark;
5253

@@ -62,8 +63,8 @@ function createBenchmark( len ) {
6263
b.tic();
6364
for ( i = 0; i < b.iterations; i++ ) {
6465
buf[ 0 ] = i%2;
65-
arr.copyWithin( 1, 0 );
66-
if ( buf[ 0 ] !== i%2 ) {
66+
arr = arr.copyWithin( 1, 0 );
67+
if ( typeof arr !== 'object' ) {
6768
b.fail( 'unexpected result' );
6869
}
6970
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var Complex128 = require( '@stdlib/complex/float64/ctor' );
25+
var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' );
26+
var format = require( '@stdlib/string/format' );
27+
var pkg = require( './../package.json' ).name;
28+
var Complex128Array = require( './../lib' );
29+
30+
31+
// MAIN //
32+
33+
bench( format( '%s:copyWithin:len=5', pkg ), function benchmark( b ) {
34+
var arr;
35+
var buf;
36+
var i;
37+
38+
arr = [];
39+
for ( i = 0; i < 5; i++ ) {
40+
arr.push( new Complex128( i, i ) );
41+
}
42+
arr = new Complex128Array( arr );
43+
buf = reinterpret( arr, 0 );
44+
45+
b.tic();
46+
for ( i = 0; i < b.iterations; i++ ) {
47+
buf[ 0 ] = i;
48+
arr = arr.copyWithin( 1, 0 );
49+
if ( typeof arr !== 'object' ) {
50+
b.fail( 'unexpected result' );
51+
}
52+
}
53+
b.toc();
54+
if ( buf[ 0 ] !== buf[ 0 ] ) {
55+
b.fail( 'should not be NaN' );
56+
}
57+
b.pass( 'benchmark finished' );
58+
b.end();
59+
});
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var pow = require( '@stdlib/math/base/special/pow' );
25+
var Complex128 = require( '@stdlib/complex/float64/ctor' );
26+
var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' );
27+
var format = require( '@stdlib/string/format' );
28+
var pkg = require( './../package.json' ).name;
29+
var Complex128Array = require( './../lib' );
30+
31+
32+
// FUNCTIONS //
33+
34+
/**
35+
* Creates a benchmark function.
36+
*
37+
* @private
38+
* @param {PositiveInteger} len - array length
39+
* @returns {Function} benchmark function
40+
*/
41+
function createBenchmark( len ) {
42+
var arr;
43+
var buf;
44+
var i;
45+
46+
arr = [];
47+
for ( i = 0; i < len+1; i++ ) {
48+
arr.push( new Complex128( i, i ) );
49+
}
50+
arr = new Complex128Array( arr );
51+
buf = reinterpret( arr, 0 );
52+
53+
return benchmark;
54+
55+
/**
56+
* Benchmark function.
57+
*
58+
* @private
59+
* @param {Benchmark} b - benchmark instance
60+
*/
61+
function benchmark( b ) {
62+
var i;
63+
64+
b.tic();
65+
for ( i = 0; i < b.iterations; i++ ) {
66+
buf[ 0 ] = i;
67+
arr = arr.copyWithin( 1, 0 );
68+
if ( typeof arr !== 'object' ) {
69+
b.fail( 'unexpected result' );
70+
}
71+
}
72+
b.toc();
73+
if ( buf[ 0 ] !== buf[ 0 ] ) {
74+
b.fail( 'should not be NaN' );
75+
}
76+
b.pass( 'benchmark finished' );
77+
b.end();
78+
}
79+
}
80+
81+
82+
// MAIN //
83+
84+
/**
85+
* Main execution sequence.
86+
*
87+
* @private
88+
*/
89+
function main() {
90+
var len;
91+
var min;
92+
var max;
93+
var f;
94+
var i;
95+
96+
min = 1; // 10^min
97+
max = 6; // 10^max
98+
99+
for ( i = min; i <= max; i++ ) {
100+
len = pow( 10, i );
101+
f = createBenchmark( len );
102+
bench( format( '%s:copyWithin:len=%d', pkg, len ), f );
103+
}
104+
}
105+
106+
main();

complex64/benchmark/benchmark.copy_within.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
var bench = require( '@stdlib/bench' );
2424
var Complex64 = require( '@stdlib/complex/float32/ctor' );
25+
var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' );
2526
var format = require( '@stdlib/string/format' );
2627
var pkg = require( './../package.json' ).name;
2728
var Complex64Array = require( './../lib' );
@@ -39,13 +40,13 @@ bench( format( '%s:copyWithin:len=5', pkg ), function benchmark( b ) {
3940
arr.push( new Complex64( i, i ) );
4041
}
4142
arr = new Complex64Array( arr );
42-
buf = arr.buffer;
43+
buf = reinterpret( arr, 0 );
4344

4445
b.tic();
4546
for ( i = 0; i < b.iterations; i++ ) {
4647
buf[ 0 ] = i;
4748
arr = arr.copyWithin( 1, 0 );
48-
if ( buf[ 0 ] !== i ) {
49+
if ( typeof arr !== 'object' ) {
4950
b.fail( 'unexpected result' );
5051
}
5152
}

complex64/benchmark/benchmark.copy_within.length.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var bench = require( '@stdlib/bench' );
2424
var pow = require( '@stdlib/math/base/special/pow' );
2525
var Complex64 = require( '@stdlib/complex/float32/ctor' );
26+
var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' );
2627
var format = require( '@stdlib/string/format' );
2728
var pkg = require( './../package.json' ).name;
2829
var Complex64Array = require( './../lib' );
@@ -47,7 +48,7 @@ function createBenchmark( len ) {
4748
arr.push( new Complex64( i, i ) );
4849
}
4950
arr = new Complex64Array( arr );
50-
buf = arr.buffer;
51+
buf = reinterpret( arr, 0 );
5152

5253
return benchmark;
5354

@@ -63,8 +64,8 @@ function createBenchmark( len ) {
6364
b.tic();
6465
for ( i = 0; i < b.iterations; i++ ) {
6566
buf[ 0 ] = i;
66-
arr.copyWithin( 1, 0 );
67-
if ( buf[ 0 ] !== i ) {
67+
arr = arr.copyWithin( 1, 0 );
68+
if ( typeof arr !== 'object' ) {
6869
b.fail( 'unexpected result' );
6970
}
7071
}

0 commit comments

Comments
 (0)