Coder Social home page Coder Social logo

hamadmarri / elixir-benchmark-vs-other-languages Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 46 KB

Elixir Benchmark vs other languages

Elixir 34.36% Go 9.43% Java 13.95% C 28.16% C++ 14.09%
benchmark benchmarking depth-first-search dfs elixir elixir-lang performance test

elixir-benchmark-vs-other-languages's Introduction

Elixir Benchmark vs other languages

The test is a Depth First Search DFS on order of integer numbers from 1 to 10. Simply push to the stack the next generation of numbers and pull. This method tests the performance of a language on the following: -

  • Loop speed
  • Pushing and pulling from a list / stack
  • Check equality of two lists / arrays

The entropy is 10 numbers, and the maximum digits is 10. The current code is after some optimization. First Elixir was faster than Go about 3x, until I changed the default slice capacity in Go. After that Go become faster by 2x. So, it seems that the Go's slice initial capacity has much effects in performance.

Anyways, with the final optimizations on Elixir, Go, and Java, Elixir in this test is faster than Java by about 2x, and slower than Go by 1.2x

It is quite surprizing how Elixir is comparable with a complied language such as Go. Next I am planning to test C++ or C to see how far we are from almost optimum speed.

Results

  • Go average: 17.28828s ~17.3s
  • Elixir average: 21049749us ~21s / 3.75s / 1.22x slower than Go
  • Java average: 41.5353454s ~41.5s - 2.4x slower than Go and 1.97x slower than Elixir

Summary

Even thought some benchmarks on the Internet shows that Elixir might be not fast on computation or calculation tasks, Elixir in the DFS test is almost as a compiled language. Notice that the test DFS in this example is simple. I like Elixir as a beautiful Functional Programming language and the fact that it is based on Erlang technology. I was wishing before implementing GO that Elixir at least be slower no more than 4x or at least a linear (not exponential) differences. I am surprized that Elixir / Erlang at least in this test shows that it is not a slow languages as usually shown in different benchmarks in the Internet.

You may clone this repo and test. Please see the full results, build / run commands in results.txt files. If you have any optimized modification on either language please do not hesitate to Pull Request. Moreover, if you like to share your benchmarks on your machine I will be happy to share it as well as a separate branch such as bench-yourname.

Thank you

Hamad

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.