Git Product home page Git Product logo

hpc-algorithms's Introduction

If you like hpc-algorithms, then help us keep more good stuff like this coming.
Let us know what other algorithms could use acceleration or improvement.

paypal

High Performance Computing Algorithms in JavaScript

Faster and Better Algorithms, starting with high performance sorting:

  • LSD Radix Sort for unsigned 32-bit integer arrays. 20-30X faster than JavaScript's built-in array sort for arrays less than 35 Million. 5-10X faster for arrays greater than 35 Million. This sort algorithm is not in-place, returning a new sorted array. Discussion, benchmarks and usage in https://duvanenko.tech.blog/2017/06/15/faster-sorting-in-javascript/
  • LSD Radix Sort for arrays of objects by an unsigned integer key. 15X faster than JavaScript's built-in .sort(). This is a stable sort, while JavaScript built-in is not stable. This sort algorithm is not in-place, returning a new sorted array. Discussion, benchmarks and usage in https://duvanenko.tech.blog/2017/07/10/sorting-arrays-of-objects-in-javascript-with-radix-sort/
  • Counting Sort for Uint8 and Uint16 typed arrays. 40X faster for Uint8 arrays and 15X faster for Uint16 arrays. This sort algorithm is in-place.

When you benchmark these algorithms keep in mind that for the first few runs the basic JavaScript JIT compiler is used, providing fast start up time and giving time for the optimizing compiler to run. After these few runs the optimized code starts being used, revealing the full performance of LSD Radix Sort and Counting Sort algorithms. See https://blog.sessionstack.com/how-javascript-works-inside-the-v8-engine-5-tips-on-how-to-write-optimized-code-ac089e62b12e for more details about the JIT engine in Chrome.

Examples

function simpleUsageExampleOfRadixSortLSD() {
    var arrayToBeSorted = [ 99, 1999999999, 51, 23, 102];
    var sortedArray = HpcAlgorithms.Sorting.RadixSortLsdUInt32(arrayToBeSorted);
    for ( var _current = 0; _current < sortedArray.length; _current++ ) {
        console.log(sortedArray[_current]);
    }
}

If you have other specific needs for higher performance algorithms, let us know.

hpc-algorithms's People

Contributors

dragonspit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

lfdoherty

hpc-algorithms's Issues

Order arrays of pairs of uint32?

Thanks for providing this package!

If one wants to order arrays of pairs of uint32 for the first element of the pair. Is there a faster than this?

Make an array A of pairs Uint32Array(2) and define function getKey(e) { return e[0]; } and then run RadixSortLsdUdtUInt32(A, getKey);

(Ideally, there would be just one Uint32array and one would sort the even indices together with their odd neighbors.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.