-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
407 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use strict'; | ||
|
||
// MODULES // | ||
|
||
var Matrix = require( './../lib' ); | ||
|
||
|
||
// VARIABLES // | ||
|
||
var start, | ||
stop, | ||
res, | ||
len, | ||
m, | ||
v, | ||
i; | ||
|
||
|
||
// -------------------------------------- | ||
// WARM-UP | ||
|
||
len = 1e6; | ||
for ( i = 0; i < len; i++ ) { | ||
i = i; | ||
} | ||
|
||
|
||
// -------------------------------------- | ||
// BENCHMARK | ||
|
||
len = 1e6; | ||
|
||
res = new Array( 2 ); | ||
|
||
m = new Matrix( [128,128] ); | ||
|
||
start = process.hrtime(); | ||
for ( i = 0; i < len; i++ ) { | ||
v = m.get( 64, 64 ); | ||
} | ||
stop = process.hrtime( start ); | ||
|
||
res[ 1 ] = stop[ 0 ] + stop[ 1 ]*1e-9; | ||
|
||
|
||
// -------------------------------------- | ||
// RESULTS | ||
|
||
console.log( 'Get:\t%d ops/sec', Math.floor( len/res[ 1 ] ) ); | ||
console.log( '\n' ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
'use strict'; | ||
|
||
// MODULES // | ||
|
||
var Matrix = require( './../lib' ); | ||
|
||
|
||
// VARIABLES // | ||
|
||
var start, | ||
stop, | ||
res, | ||
len, | ||
m, | ||
i; | ||
|
||
|
||
// -------------------------------------- | ||
// WARM-UP | ||
|
||
len = 1e6; | ||
for ( i = 0; i < len; i++ ) { | ||
i = i; | ||
} | ||
|
||
|
||
// -------------------------------------- | ||
// BENCHMARK | ||
|
||
len = 1e6; | ||
|
||
res = new Array( 2 ); | ||
|
||
m = new Matrix( [128,128] ); | ||
|
||
start = process.hrtime(); | ||
for ( i = 0; i < len; i++ ) { | ||
m.set( 64, 64, Math.random() ); | ||
} | ||
stop = process.hrtime( start ); | ||
|
||
res[ 1 ] = stop[ 0 ] + stop[ 1 ]*1e-9; | ||
|
||
|
||
// -------------------------------------- | ||
// RESULTS | ||
|
||
console.log( 'Set:\t%d ops/sec', Math.floor( len/res[ 1 ] ) ); | ||
console.log( '\n' ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
'use strict'; | ||
|
||
var foo = require( './../lib' ); | ||
var Matrix = require( './../lib' ); | ||
|
||
var m = new Matrix( [2,2] ); | ||
|
||
console.log( m ); | ||
|
||
console.log( m.set( 1, 1, 5 ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
// BASE TYPES // | ||
|
||
var BTYPES = { | ||
'int8': Int8Array, | ||
'uint8': Uint8Array, | ||
'uint8_clamped': Uint8ClampedArray, | ||
'int16': Int16Array, | ||
'uint16': Uint16Array, | ||
'int32': Int32Array, | ||
'uint32': Uint32Array, | ||
'float32': Float32Array, | ||
'float64': Float64Array | ||
}; | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = BTYPES; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
// DATA TYPES // | ||
|
||
var DTYPES = [ | ||
'int8', | ||
'uint8', | ||
'uint8_clamped', | ||
'int16', | ||
'uint16', | ||
'int32', | ||
'uint32', | ||
'float32', | ||
'float64' | ||
]; | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = DTYPES; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
|
||
// MODULES // | ||
|
||
var typeName = require( 'type-name' ); | ||
|
||
|
||
// VARIABLES // | ||
|
||
var ITYPES = require( './itypes.js' ); | ||
|
||
|
||
// GET TYPE // | ||
|
||
/** | ||
* FUNCTION: getType( x ) | ||
* Determines an input data type. | ||
* | ||
* @private | ||
* @param {*} x - input value | ||
* @returns {String|Null} data type | ||
*/ | ||
function getType( x ) { | ||
var type = ITYPES[ typeName( x ) ]; | ||
if ( type ) { | ||
return type; | ||
} | ||
return null; | ||
} // end FUNCTION getType() | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = getType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,5 @@ | ||
'use strict'; | ||
|
||
// MODULES // | ||
|
||
// var module_alias = require( 'module_name' ); | ||
|
||
|
||
// FUNCTIONS // | ||
|
||
// any private utility functions go here... | ||
|
||
|
||
// {{ FOO }} // | ||
|
||
/** | ||
* FUNCTION: foo() | ||
* {{ foo description }}. | ||
*/ | ||
function foo() { | ||
|
||
} // end FUNCTION foo() | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = foo; | ||
module.exports = require( './matrix.js' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
// INPUT TYPES // | ||
|
||
var ITYPES = { | ||
'Int8Array': 'int8', | ||
'Uint8Array': 'uint8', | ||
'Uint8ClampedArray': 'uint8_clamped', | ||
'Int16Array': 'int16', | ||
'Uint16Array': 'uint16', | ||
'Int32Array': 'int32', | ||
'Uint32Array': 'uint32', | ||
'Float32Array': 'float32', | ||
'Float64Array': 'float64' | ||
}; | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = ITYPES; |
Oops, something went wrong.