Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Jul 1, 2024
1 parent 27eaa47 commit b6f3a8d
Show file tree
Hide file tree
Showing 12 changed files with 526 additions and 51 deletions.
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<section class="release" id="unreleased">

## Unreleased (2024-06-29)
## Unreleased (2024-07-01)

<section class="packages">

Expand Down Expand Up @@ -1872,6 +1872,28 @@ This release closes the following issue:

<!-- /.package -->

<section class="package" id="array-pool-unreleased">

#### [@stdlib/array/pool](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/pool)

<details>

<section class="features">

##### Features

- [`88cece6`](https://github.com/stdlib-js/stdlib/commit/88cece679d728150847dc2b5c957b395bffe7d90) - add boolean dtype support to `array/pool` [(#2486)](https://github.com/stdlib-js/stdlib/pull/2486)

</section>

<!-- /.features -->

</details>

</section>

<!-- /.package -->

<section class="package" id="array-promotion-rules-unreleased">

#### [@stdlib/array/promotion-rules](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/promotion-rules)
Expand Down Expand Up @@ -2291,6 +2313,7 @@ A total of 13 people contributed to this release. Thank you to the following con

<details>

- [`88cece6`](https://github.com/stdlib-js/stdlib/commit/88cece679d728150847dc2b5c957b395bffe7d90) - **feat:** add boolean dtype support to `array/pool` [(#2486)](https://github.com/stdlib-js/stdlib/pull/2486) _(by Jaysukh Makvana, Athan Reines)_
- [`3368a35`](https://github.com/stdlib-js/stdlib/commit/3368a3503ee7df4d1c0803ada84863b4250c76fa) - **docs:** update namespace TypeScript declarations [(#2477)](https://github.com/stdlib-js/stdlib/pull/2477) _(by stdlib-bot, Athan Reines)_
- [`3a3116e`](https://github.com/stdlib-js/stdlib/commit/3a3116e3ff5bef42e4b4f39e5375b89a877ccff0) - **feat:** add boolean dtype support to `array/from-scalar` [(#2470)](https://github.com/stdlib-js/stdlib/pull/2470) _(by Jaysukh Makvana, Athan Reines)_
- [`8a55ea2`](https://github.com/stdlib-js/stdlib/commit/8a55ea29ae7cc04e9ebef428ee90900641bbabe1) - **feat:** add boolean dtype support to `array/filled` [(#2471)](https://github.com/stdlib-js/stdlib/pull/2471) _(by Jaysukh Makvana, Athan Reines)_
Expand Down
28 changes: 8 additions & 20 deletions pool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@license Apache-2.0
Copyright (c) 2018 The Stdlib Authors.
Copyright (c) 2024 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.
Expand All @@ -18,7 +18,7 @@ limitations under the License.
-->

# Typed Array Pool
# typedarraypool

> Allocate typed arrays from a typed array memory pool.
Expand All @@ -42,7 +42,7 @@ var typedarraypool = require( '@stdlib/array/pool' );

#### typedarraypool( \[dtype] )

Returns an **uninitialized** [typed array][mdn-typed-array] having a specified data type `dtype`.
Returns an **uninitialized** [typed array][mdn-typed-array] having a specified [data type][@stdlib/array/typed-dtypes] `dtype`.

```javascript
var arr = typedarraypool();
Expand All @@ -53,21 +53,7 @@ var arr = typedarraypool();
typedarraypool.free( arr );
```

The function recognizes the following data types:

- `float64`: double-precision floating-point numbers (IEEE 754)
- `float32`: single-precision floating-point numbers (IEEE 754)
- `complex128`: double-precision complex floating-point numbers
- `complex64`: single-precision complex floating-point numbers
- `int32`: 32-bit two's complement signed integers
- `uint32`: 32-bit unsigned integers
- `int16`: 16-bit two's complement signed integers
- `uint16`: 16-bit unsigned integers
- `int8`: 8-bit two's complement signed integers
- `uint8`: 8-bit unsigned integers
- `uint8c`: 8-bit unsigned integers clamped to `0-255`

By default, the output [typed array][mdn-typed-array] is `float64`. To specify an alternative data type, set the `dtype` parameter.
By default, the output [typed array][mdn-typed-array] is `float64`. To specify an alternative [data type][@stdlib/array/typed-dtypes], set the `dtype` parameter.

```javascript
var arr = typedarraypool( 'int32' );
Expand Down Expand Up @@ -135,7 +121,7 @@ typedarraypool.free( arr2 );

#### typedarraypool.malloc( \[dtype] )

Returns an **uninitialized** [typed array][mdn-typed-array] having a specified data type `dtype`.
Returns an **uninitialized** [typed array][mdn-typed-array] having a specified [data type][@stdlib/array/typed-dtypes] `dtype`.

```javascript
var arr1 = typedarraypool.malloc();
Expand Down Expand Up @@ -207,7 +193,7 @@ typedarraypool.free( arr2 );

#### typedarraypool.calloc( \[dtype] )

Returns a **zero-initialized** [typed array][mdn-typed-array] having a specified data type `dtype`.
Returns a **zero-initialized** [typed array][mdn-typed-array] having a specified [data type][@stdlib/array/typed-dtypes] `dtype`.

```javascript
var arr1 = typedarraypool.calloc();
Expand Down Expand Up @@ -461,6 +447,8 @@ console.log( 'nbytes: %d', typedarray.nbytes );

[mdn-arraybuffer]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer

[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array/tree/main/typed-dtypes

<!-- <related-links> -->

[@stdlib/array/typed]: https://github.com/stdlib-js/array/tree/main/typed
Expand Down
21 changes: 20 additions & 1 deletion pool/benchmark/benchmark.calloc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
* Copyright (c) 2024 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.
Expand All @@ -23,6 +23,7 @@
var bench = require( '@stdlib/bench' );
var isTypedArray = require( '@stdlib/assert/is-typed-array' );
var isComplexTypedArray = require( '@stdlib/assert/is-complex-typed-array' );
var isBooleanArray = require( '@stdlib/assert/is-booleanarray' );
var pkg = require( './../package.json' ).name;
var typedarray = require( './../lib' );

Expand Down Expand Up @@ -209,6 +210,24 @@ bench( pkg+':calloc:dtype=uint8c', function benchmark( b ) {
b.end();
});

bench( pkg+':calloc:dtype=bool', function benchmark( b ) {
var arr;
var i;
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr = typedarray.calloc( 0, 'bool' );
if ( arr.length !== 0 ) {
b.fail( 'should have length 0' );
}
}
b.toc();
if ( !isBooleanArray( arr ) ) {
b.fail( 'should return a boolean array' );
}
b.pass( 'benchmark finished' );
b.end();
});

bench( pkg+':calloc:dtype=complex64', function benchmark( b ) {
var arr;
var i;
Expand Down
21 changes: 20 additions & 1 deletion pool/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
* Copyright (c) 2024 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.
Expand All @@ -23,6 +23,7 @@
var bench = require( '@stdlib/bench' );
var isTypedArray = require( '@stdlib/assert/is-typed-array' );
var isComplexTypedArray = require( '@stdlib/assert/is-complex-typed-array' );
var isBooleanArray = require('@stdlib/assert/is-booleanarray');
var pkg = require( './../package.json' ).name;
var typedarray = require( './../lib' );

Expand Down Expand Up @@ -209,6 +210,24 @@ bench( pkg+':dtype=uint8c', function benchmark( b ) {
b.end();
});

bench( pkg+':dtype=bool', function benchmark( b ) {
var arr;
var i;
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr = typedarray( 0, 'bool' );
if ( arr.length !== 0 ) {
b.fail( 'should have length 0' );
}
}
b.toc();
if ( !isBooleanArray( arr ) ) {
b.fail( 'should return a boolean array' );
}
b.pass( 'benchmark finished' );
b.end();
});

bench( pkg+':dtype=complex64', function benchmark( b ) {
var arr;
var i;
Expand Down
102 changes: 102 additions & 0 deletions pool/benchmark/benchmark.length.bool.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 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 pow = require( '@stdlib/math/base/special/pow' );
var isBooleanArray = require( '@stdlib/assert/is-booleanarray' );
var pkg = require( './../package.json' ).name;
var typedarray = require( './../lib' );


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {Function} fcn - allocation function
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( fcn, len ) {
return benchmark;

/**
* Benchmark function.
*
* @private
* @param {Benchmark} b - benchmark instance
*/
function benchmark( b ) {
var arr;
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr = fcn( len, 'bool' );
if ( arr.length !== len ) {
b.fail( 'unexpected length' );
}
typedarray.free( arr );
}
b.toc();
if ( !isBooleanArray( arr ) ) {
b.fail( 'should return a boolean array' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var len;
var min;
var max;
var f;
var i;

min = 1; // 10^min
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = pow( 10, i );

f = createBenchmark( typedarray, len );
bench( pkg+':dtype=bool,len='+len, f );

f = createBenchmark( typedarray.malloc, len );
bench( pkg+':malloc:dtype=bool,len='+len, f );

f = createBenchmark( typedarray.calloc, len );
bench( pkg+':calloc:dtype=bool,len='+len, f );
}
}

main();
21 changes: 20 additions & 1 deletion pool/benchmark/benchmark.malloc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
* Copyright (c) 2024 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.
Expand All @@ -23,6 +23,7 @@
var bench = require( '@stdlib/bench' );
var isTypedArray = require( '@stdlib/assert/is-typed-array' );
var isComplexTypedArray = require( '@stdlib/assert/is-complex-typed-array' );
var isBooleanArray = require( '@stdlib/assert/is-booleanarray' );
var pkg = require( './../package.json' ).name;
var typedarray = require( './../lib' );

Expand Down Expand Up @@ -209,6 +210,24 @@ bench( pkg+':malloc:dtype=uint8c', function benchmark( b ) {
b.end();
});

bench( pkg+':malloc:dtype=bool', function benchmark( b ) {
var arr;
var i;
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr = typedarray.malloc( 0, 'bool' );
if ( arr.length !== 0 ) {
b.fail( 'should have length 0' );
}
}
b.toc();
if ( !isBooleanArray( arr ) ) {
b.fail( 'should return a boolean array' );
}
b.pass( 'benchmark finished' );
b.end();
});

bench( pkg+':malloc:dtype=complex64', function benchmark( b ) {
var arr;
var i;
Expand Down
Loading

0 comments on commit b6f3a8d

Please sign in to comment.