Giter Club home page Giter Club logo

base64encoding's Introduction

Base64Encoding

Introduction

I implemented Base 64 encoding and decoding in several different languages. Base 64 Encoding is a way to represent arbitrary data in strings whose characters fall within a 64-length (+1 for padding) subset of ASCII characters. These aren't meant to be as fast as the standard bitshifting by multiples of 6 algorithm, but rather to compare the relative performace of different languages using my encode/decode algorithm implemented in (mostly) the same way (the bitwise operations are identical for all languages).

How It Works

The encode and decode functions divide the input and output data into chunks and use bitwise operations to transform them appropriately. I performed a benchmark for each language in which a large 'Lorem Ipsum' paragraph is encoded then decoded one million times. The test was run five times and the fastest was selected. For slower languages, the time was extrapolated.

Benchmark Results

Language Time (s) Comments Encoding Struct Decoding Struct
C 1.078 Compiled with gcc -O3 char * char *
Java 3.173 Ran in Eclipse, Java 8 StringBuffer ByteBuffer
Go 3.374 Go version go1.12.9 strings.Builder bytes.Buffer
C# 4.585 Ran in VS 2015, .NET 4.6 StringBuilder byte[]
Nim 5.264 Compiled with nim c -d:release string string
Python 15.52 Ran with PyPy3 (JIT) List bytearray
Crystal 20.28 Compiled with crystal build --release String UInt8[]
Javascript 22.04 Ran with Node.js v10 String Buffer
Elixir 28.60 Used Task.async_stream bitstring bitstring
Python 355.3 Ran with Python3 (standard) List bytearray

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.