Giter VIP home page Giter VIP logo

php-node-bubblesort-test's People

Contributors

gitkearney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

php-node-bubblesort-test's Issues

I think there's a flaw in your methodology

I've set up a fork to demonstrate what I'm talking about. You can see it here:

https://github.com/ryantate13/php-node-bubblesort-test/

In my test runs PHP is consistently ~20x slower than Node. I set up a script to cycle through 100 test runs and take the min time of each set per platform.

If you clone my repo and run make test you can see it in action. PHP is v7.2.18, Node is v10.14.2.

time elapsed (nanoseconds) for php is 133,391,141
time elapsed (nanoseconds) for node is 7,014,987

Node can go 3x faster

It might sound a bit like sorcery but if you will traverse array backwards you can achieve up to 3 times better performance. The only difference is to use this construction:

for ( var i = array.length; i--; ) {
   (...)
}

There has been prolonged discussion about it on GitHub: https://stackoverflow.com/questions/5349425/whats-the-fastest-way-to-loop-through-an-array-in-javascript
and here you can find related test:
http://jsbench.github.io/#67b13d4e78cdd0d7a7346410d5becf12

I didn't check it in node though but in browser... :
https://jsbench.me/j0jw6pygqu/1

Also as you can see in tests you can gain performance on declaring the data type for array.

Wonder how much improvements can be gain in PHP and if running on node will make the difference.

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.