Coder Social home page Coder Social logo

splasky / basiccompare Goto Github PK

View Code? Open in Web Editor NEW

This project forked from coalnova/basiccompare

0.0 0.0 0.0 47 KB

A basic comparitive analysis of C, C++, Rust, and Zig.

License: The Unlicense

C++ 12.22% Python 10.13% C 18.56% Java 13.21% Rust 12.21% Makefile 3.61% Zig 30.06%

basiccompare's Introduction

BasicCompare

pretty command line text A basic comparitive analysis of C, C++, Rust, Zig, Python, and Java.

Overview

The goal of this project was to test operational time performance for each language using as like operations as possible. Though per-lang optimizations could be performed, the systems-level languages allow for inline assembly. That means this would get real nasty, real quick. The implementation is meant to be a naive, or at least a beginner's basic approach to the problem.

The operations are:

  • using a struct to contain a billable user account
  • propogated by a language provided random number generator
  • over a provided (100 default) number of iterations
  • propagate a resizeable heap-based account collection of provided operation size (100 default)
  • iterate over the list and perform a billing based on account balance (actual values don't matter)
  • perform the iteration loop operation number of times
  • clear list/free memory

Although variations obviously change between languages, those operations are performed in much the same manner across. The languages are compiled using optimizations where available. C/C++ uses -O2, Rust uses --release, and Zig uses ReleaseFast. Programs will print to command line the total time of execution. As well as the maximum, minimum, and average per-iteration times.


Useage

The provided Makefile should build on any machine that has Make/Clang, Rust/Cargo, Zig, and Java. Python .py file to be run via CLI $ python ./python/main.py. Each program allows for up to two numeric arguments, with the first assigning operations, and the second iterations.


Timings

Raw output on an admittedly cheap laptop running 100 operations over 1000 iterations are as follows:

Language Execution Time (s) Max (ns) Min (ns) Avg (ns) C Ratio
C 0.335615 455000 296000 335181 1.00
C++ 0.348636 477918 306957 348245 0.96
Rust 0.229681174 368683 201749 229564 1.46
Zig 0.10153 541197 75332 95047 3.30
Python 14.77727734 33754451 12984472 14775610 0.02
Java 0.263353044 7772037 130966 240370 1.27

*note: Python timed via interpreter, your times may vary. Please speak to your doctor or a licensed medical professional before attempting Java. Not to be confused with financial advice. Offer void in Utah.

basiccompare's People

Contributors

coalnova avatar splasky 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.