Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e7e8649
Create beep.js
SuYaSh-PaThAk04 Sep 25, 2025
ea32fcb
Create beep.js
SuYaSh-PaThAk04 Sep 25, 2025
38fa07e
Delete tools/make/lib/lint/javascript/beep.js
SuYaSh-PaThAk04 Sep 25, 2025
1cb0826
Merge branch 'stdlib-js:develop' into develop
SuYaSh-PaThAk04 Sep 26, 2025
23a2b4f
Update eslint.mk
SuYaSh-PaThAk04 Sep 26, 2025
2bd08ee
Delete beep.js
SuYaSh-PaThAk04 Sep 26, 2025
6d15877
Merge branch 'stdlib-js:develop' into develop
SuYaSh-PaThAk04 Sep 29, 2025
0185527
Merge branch 'stdlib-js:develop' into develop
SuYaSh-PaThAk04 Oct 23, 2025
9f8fca9
Add self-import to index.js for linting compliance
SuYaSh-PaThAk04 Oct 23, 2025
0878f6b
Update main.js
SuYaSh-PaThAk04 Oct 23, 2025
3ee6f99
Fix argument handling in async while function
SuYaSh-PaThAk04 Oct 23, 2025
662db12
Simplify linting logic in eslint.mk
SuYaSh-PaThAk04 Oct 23, 2025
c3839bf
Correct echo command in eslint.mk
SuYaSh-PaThAk04 Oct 23, 2025
a794162
Merge branch 'stdlib-js:develop' into develop
SuYaSh-PaThAk04 Nov 7, 2025
b3b438a
Fix JavaScript lint errors #8294
SuYaSh-PaThAk04 Nov 7, 2025
0e03a3e
chore: fix JavaScript lint errors (issue #8294)
SuYaSh-PaThAk04 Jan 16, 2026
9df00a4
chore: fix JavaScript lint errors (issue #8294)
SuYaSh-PaThAk04 Jan 16, 2026
cae5094
Update main.js
SuYaSh-PaThAk04 Jan 16, 2026
2ed16df
Update benchmark.fast_elements_array_length_heuristic.js
SuYaSh-PaThAk04 Jan 16, 2026
50e57b6
Update benchmark.fast_elements_array_length_heuristic.js
SuYaSh-PaThAk04 Jan 16, 2026
f19b558
Update benchmark.nested_dimensions.js
SuYaSh-PaThAk04 Jan 17, 2026
6173a15
Update main.js
SuYaSh-PaThAk04 Jan 17, 2026
0cf8073
Update benchmark.nested_dimensions.js
SuYaSh-PaThAk04 Jan 17, 2026
0451542
Update index.js
SuYaSh-PaThAk04 Jan 17, 2026
ce38ffd
Update index.js
SuYaSh-PaThAk04 Jan 17, 2026
d7743d6
Update main.js
SuYaSh-PaThAk04 Jan 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var debug = logger( 'to-reference:sync' );
*
* @example
* var ref = toReference( '@press1992' );
* // returns '...'
* // e.g., returns '...'
*/
function toReference( id, options ) {
var outFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ var rule;
* @param {Object} context - ESLint context
* @returns {Object} validators
*/
function main( context ) {
function main(context) {
var source = context.getSourceCode();
var filename = context.getFilename();

return {
'Program': validate
};
Expand Down Expand Up @@ -106,8 +106,10 @@ function main( context ) {
if ( year !== expected ) {
report( 'Expected year to be '+expected+' and not '+year, comment, expected );
}
} catch ( err ) {
// Do nothing if unable to determine the year the file was created (e.g., if the file is not tracked yet by `git`).
} catch( err ) {
// eslint-disable-line no-unused-vars
// Do nothing if unable to determine the year the file was created
// (e.g., if the file is not tracked yet by `git`).
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,174 +1,171 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2018 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';
* @license Apache-2.0
*
* Copyright (c) 2018 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 isArray = require( '@stdlib/assert/is-array' );
var floor = require( '@stdlib/math/base/special/floor' );
var randu = require( '@stdlib/random/base/randu' );
var pow = require( '@stdlib/math/base/special/pow' );

var bench = require("@stdlib/bench");
var isArray = require("@stdlib/assert/is-array");
var floor = require("@stdlib/math/base/special/floor");
var randu = require("@stdlib/random/base/randu");
var pow = require("@stdlib/math/base/special/pow");

// VARIABLES //

var NAME = 'js-array-length-fast-elements-heuristic';
var NAME = "js-array-length-fast-elements-heuristic";

/*
* In some engines, heuristics have been used to ensure "fast elements" (i.e., contiguous memory) for generic arrays. For historical background, see
*
* - https://www.html5rocks.com/en/tutorials/speed/v8/#toc-topic-numbers
* - https://github.com/thlorenz/v8-perf/blob/ee76ddf1e414f3299bd03943ef212072dd16200f/data-types.md#fast-elements
*
* Apparently, in more recent V8 versions, the limit at which dictionary mode is triggered when preallocating arrays has increased to ~32 million.
*
* - https://github.com/v8/v8/blob/2feb99dc8ac75f20d2e5c9c1b343e923476851ea/src/objects/js-array.h#L87-L88
*/
var MAX_FAST_ELEMENTS_HEURISTIC = 64000|0; // eslint-disable-line id-length

* In some engines, heuristics have been used to ensure "fast elements" (i.e., contiguous memory) for generic arrays. For historical background, see
*
* - https://www.html5rocks.com/en/tutorials/speed/v8/#toc-topic-numbers
* - https://github.com/thlorenz/v8-perf/blob/ee76ddf1e414f3299bd03943ef212072dd16200f/data-types.md#fast-elements
*
* Apparently, in more recent V8 versions, the limit at which dictionary mode is triggered when preallocating arrays has increased to ~32 million.
*
* - https://github.com/v8/v8/blob/2feb99dc8ac75f20d2e5c9c1b343e923476851ea/src/objects/js-array.h#L87-L88
*/
var MAX_FAST_ELEMENTS_HEURISTIC = 64000 | 0; // eslint-disable-line id-length

// FUNCTIONS //

/**
* Copies an array using a heuristic for ensuring "fast" elements.
*
* @private
* @param {Array} arr - array to copy
* @returns {Array} array copy
*/
function copy1( arr ) {
* Copies an array using a heuristic for ensuring "fast" elements.
*
* @private
* @param {Array} arr - array to copy
* @returns {Array} array copy
*/
function copy1(arr) {
var out;
var len;
var i;

len = arr.length;
if ( len > MAX_FAST_ELEMENTS_HEURISTIC ) {
out = new Array( MAX_FAST_ELEMENTS_HEURISTIC );
for ( i = 0; i < MAX_FAST_ELEMENTS_HEURISTIC; i++ ) {
out[ i ] = arr[ i ];
if (len > MAX_FAST_ELEMENTS_HEURISTIC) {
out = new Array(MAX_FAST_ELEMENTS_HEURISTIC); // eslint-disable-line stdlib/no-new-array
for (i = 0; i < MAX_FAST_ELEMENTS_HEURISTIC; i++) {
out[i] = arr[i];
}
for ( i = MAX_FAST_ELEMENTS_HEURISTIC; i < len; i++ ) {
out.push( arr[ i ] );
for (i = MAX_FAST_ELEMENTS_HEURISTIC; i < len; i++) {
out.push(arr[i]);
}
} else {
out = new Array( len );
for ( i = 0; i < len; i++ ) {
out[ i ] = arr[ i ];
out = new Array(len); // eslint-disable-line stdlib/no-new-array
for (i = 0; i < len; i++) {
out[i] = arr[i];
}
}
return out;
}

/**
* Copies an array by preallocating output array memory.
*
* @private
* @param {Array} arr - array to copy
* @returns {Array} array copy
*/
function copy2( arr ) {
* Copies an array by preallocating output array memory.
*
* @private
* @param {Array} arr - array to copy
* @returns {Array} array copy
*/
function copy2(arr) {
var out;
var len;
var i;

len = arr.length;
out = new Array( len );
for ( i = 0; i < len; i++ ) {
out[ i ] = arr[ i ];
out = new Array(len); // eslint-disable-line stdlib/no-new-array
for (i = 0; i < len; i++) {
out[i] = arr[i];
}
return out;
}

/**
* Copies an array using dynamic memory allocation.
*
* @private
* @param {Array} arr - array to copy
* @returns {Array} array copy
*/
function copy3( arr ) {
* Copies an array using dynamic memory allocation.
*
* @private
* @param {Array} arr - array to copy
* @returns {Array} array copy
*/
function copy3(arr) {
var out;
var len;
var i;

len = arr.length;
out = [];
for ( i = 0; i < len; i++ ) {
out.push( arr[ i ] );
for (i = 0; i < len; i++) {
out.push(arr[i]);
}
return out;
}

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

arr = [];
for ( i = 0; i < len; i++ ) {
arr.push( 0 );
for (i = 0; i < len; i++) {
arr.push(0);
}
return benchmark;

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

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr[ 0 ] = floor( randu()*100.0 )|0; // cast to int32
out = fcn( arr );
if ( out.length !== len ) {
b.fail( 'unexpected length' );
for (i = 0; i < b.iterations; i++) {
arr[0] = floor(randu() * 100.0) | 0; // cast to int32
out = fcn(arr);
if (out.length !== len) {
b.fail("unexpected length");
}
}
b.toc();
if ( !isArray( out ) ) {
b.fail( 'should return an array' );
if (!isArray(out)) {
b.fail("should return an array");
}
b.pass( 'benchmark finished' );
b.pass("benchmark finished");
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
* Main execution sequence.
*
* @private
*/
function main() {
var len;
var min;
Expand All @@ -179,17 +176,17 @@ function main() {
min = 1; // 10^min
max = 6; // 10^max

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

f = createBenchmark( copy1, len );
bench( NAME+'::heuristic:len='+len, f );
f = createBenchmark(copy1, len);
bench(NAME + "::heuristic:len=" + len, f);

f = createBenchmark( copy2, len );
bench( NAME+'::preallocate:len='+len, f );
f = createBenchmark(copy2, len);
bench(NAME + "::preallocate:len=" + len, f);

f = createBenchmark( copy3, len );
bench( NAME+'::dynamic:len='+len, f );
f = createBenchmark(copy3, len);
bench(NAME + "::dynamic:len=" + len, f);
}
}

Expand Down
Loading