Hamsters.js
  • Home
  • About
  • Services
  • Example
  • Wiki
  • Contact

Hamsters.js Wiki

  • Installing Hamsters

    • HTML
    • React Native
    • Node.js
  • Using Hamsters

    • Initializing
    • The Basics
    • Restructuring Standard Functions
    • Promises
    • Sorting
    • Persistence
    • Transferable Objects
    • Debugging
    • Limitations

Transferable Objects

To obtain the best performance possible Hamsters.js introduced an optional dataType argument, assuming your problem array is any one of JavaScript's typed arrays you can see up to 10x the performance by telling the library to use transferable objects. If you do not know what Typed Arrays are please take a look at this guide Typed Arrays

You may write a function to make use of these like so

              
                function() {
                  var params = {
                    array: new Float64Array([0,1,2,3,4,5,6,7,8,9]),
                    threads: 2,
                    dataType: 'Float64',
                  };
                  hamsters.run(params, function() {
                    var arr = params.array;
                    arr.forEach(function(item, index) {
                      rtn.data[index] = ((item * 120) / 10);
                    });
                  }, function(output) {
                    invokeFunction(output);
                  });
                }
              
            

dataType can be one of the below options.

  • Int8 - 8-bit two's complement signed integer
  • Int16 - 16-bit two's complement signed integer
  • Int32 - 32-bit two's complement signed integer
  • Uint8 - 8-bit unsigned integer
  • Uint8Clamped - 8-bit unsigned integer (clamped)
  • Uint16 - 16-bit unsigned integer
  • Uint32 - 32-bit unsigned integer
  • Float32 - 32-bit IEEE floating point number ( 7 significant digits e.g. 1.1234567)
  • Float64 - 64-bit IEEE floating point number (16 significant digits e.g. 1.123...15)

Recent Updates

New React Native Hamsters Release v1.0.9!

New Hamsters.js Release v5.4.1!

New Hamsters.js Release v5.4.0!

New Hamsters.js Release v5.3.9!

Subscribe To Updates

Register your email address to receive updates from the news letter such as new version releases, and terms of service changes.

© 2015 - 2022 asmithdev | All rights reserved.
  • Home
  • About
  • Privacy
  • License