Coder Social home page Coder Social logo

adsoncostanzifilho / language-performance-benchmark Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nu12/language-performance-benchmark

0.0 1.0 0.0 9 KB

Language performance benchmark tests.

Dockerfile 29.63% Makefile 14.09% Ruby 4.02% R 3.06% Shell 3.88% C 4.83% COBOL 16.08% Crystal 2.54% Go 5.55% Java 6.63% JavaScript 4.11% PHP 2.96% Python 2.62%

language-performance-benchmark's Introduction

Language Performance Benchmark

This project is a simple performance benchmark between some popular programming languages:

  • Ruby
  • Crystal
  • Python
  • PHP
  • R
  • C
  • Java
  • Cobol
  • Go
  • Javascript (nodejs)

Objectives

The main objective is to find out if there is one language that is considerably "faster" than the other ones when performing the same programming logic.

Second, to find out if compiled languages are "faster" than interpreted languages.

Finally, if Docker affects languages' performance.

Methods

In the scope of this project the velocity measure will take into consideration the amount of time used by a program/script to be executed. Therefore a "faster" program/script is the one that takes less time to complete the task.

The letter appended in the end of each script name references the methods described below.

Method A

To reduce the amount of variables of the experiment, all programs/scripts are required to run the same "logic":

# This is pseudo-code

var current-value = 0
var highest = 0
var sum = 0
var count = 0
var input-file = File.open("data/input.cvs", read)
var output-file = File.open("outputs/language-method", write+)

for line = input-file.read-next-line():
    current-value = line.to_float()
    if current-value > highest:
        highest = current-value
    sum = sum + current-value
    count = count + 1
input-file.close()

output-file.write(highest , sum, count )
output-file.close()

The code encompasses opening two files (one for reading, one for writing), creating four more variables, looping through a dataset, performing one conditional statement and its block (when evaluated as true), performing one cumulative sum, adding 1 to the counter each record, writing the output and closing the files.

Method B

Not all programming languages are good at everything, and some may have different (more performant) approaches for the same task. A second program/script may be added and it is free to execute the task regardless the code, but external packages are not allowed. It should create an output with highest, sum, count, starting time and ending time.

Method C

It's time to go wild! Packages are allowed in this method. As before, it should create an output with highest, sum, count, starting time and ending time.

Executing

Prerequisites: install docker, docker-compose and make.

Docker (compose)

Warning: this will download a massive amount of data for several different images.

Run:

$ docker-compose up -d --build

Wait the service to be available and open localhost or the IP machine in the browser.

To run the test again, remove the created container and intermediate images:

$ docker-compose down
$ docker image prune --filter dangling=true

Local

Warning: this will download and install a massive amount of data for several different compilers and interpreters.

Install compilers and interpreters:

$ make setup -i -s

Run:

$ make -i -s

Open result/index.html.

Development

Prerequisites: install docker, docker-compose and make.

Install compilers and interpreters:

$ make setup -i -s

Execute scripts:

$ make -i -s

To add a new script, include it in the Makefile and Dockerfile to be executed.

language-performance-benchmark's People

Watchers

 avatar

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.