Skip to content

Conversation

jangnathan
Copy link

Resolves #3159 .

Description

What is the purpose of this pull request?

This pull request:

  • Adds toReversed method to main.js
  • Adds tests for toReversed method in new file test.to_reversed.js
  • Adds two benchmark files for toReversed method, one measuring baseline performance and the other measuring performance as array length increases
  • Added documentation and updated README.md file for toReversed method

Related Issues

Does this pull request have any related issues?
No

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Reversing a typed array using:

	for ( i = 0; i < len; i++ ) {
		v = buf[ GETTER ]( ( ( len - 1 ) * BYTES_PER_ELEMENT ) - ( i * BYTES_PER_ELEMENT ), this._isLE );
		obuf[ SETTER ]( i * BYTES_PER_ELEMENT, v, this._isLE );
	}

seems to perform faster (around ≈7-10 ms) in benchmarking and test results than:

	for ( i = 0; i < len; i++ ) {
		obuf[ i ] = buf[ len - i - 1 ];
	}

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

Copy link
Contributor

@stdlib-bot stdlib-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 Hi there! 👋

And thank you for opening your first pull request! We will review it shortly. 🏃 💨

@stdlib-bot
Copy link
Contributor

Coverage Report

Package Statements Branches Functions Lines
array/fixed-endian-factory $\color{red}940/1197$
$\color{green}+78.53\%$
$\color{red}80/89$
$\color{green}+89.89\%$
$\color{red}16/27$
$\color{green}+59.26\%$
$\color{red}940/1197$
$\color{green}+78.53\%$

The above coverage report was generated for the changes in this PR.

@jangnathan jangnathan changed the title Feature/3159 added to reversed method to array/fixed endian factory feat: 3159 add toReversed method to array/fixed endian factory Nov 30, 2024
@jangnathan jangnathan changed the title feat: 3159 add toReversed method to array/fixed endian factory feat: add toReversed method to array/fixed endian factory Nov 30, 2024
@jangnathan jangnathan closed this Nov 30, 2024
@jangnathan jangnathan deleted the feature/3159-added-toReversed-method-to-array/fixed-endian-factory branch November 30, 2024 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC]: add toReversed method to array/fixed-endian-factory

2 participants