Hamsters.js
  • Home
  • About
  • Services
  • Examples
    • Atomic Operations
    • Collatz Conjecture
    • Fibonacci Sequence
    • Mandelbrot Set
    • Square Root
  • Wiki
  • Donate
  • Contact
Login
Register

Hamsters.js Wiki

  • Installing Hamsters

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

    • Initializing
    • The Basics
    • Restructuring Standard Functions
    • Promises
    • Sorting
    • Persistence
    • Transferable Objects
    • Atomic Operations
    • Memoization
    • 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)
  • Twitter:

  • Recent Updates

    Hamsters.js v5.6.1 Released!

    New React Native Hamsters Release v1.0.9!

    Subscribe To Updates

    Stay in the Loop! Subscribe for Updates on New Releases and Terms of Service Changes.

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