Home

Awesome

Turbo Base64:Fastest Base64 SSE/AVX2/AVX512/Neon/Altivec

Build ubuntu

Fastest Base64 SIMD Encoding library
<p>

Download Turbo-Base64 executable benchmark tb64app from releases, extract the files and type "tb64app"</br>

Benchmark incl. the best SIMD Base64 libs:

Benchmark AMD CPU: AMD Ryzen 9 7950X @ 4,50 GHz, DDR5 6000 CL30 - gcc-12.2

E Sizeratio%E MB/sD MB/s1,000,000 bytes - 2023.07
1333336133.33%77619767168:tb64v512vbmi
1333336133.33%41325487837:_tb64v256 avx2
1333336133.33%45292466655:tb64v256 avx2
1000000100.00%370473169410:memcpy
1333336133.33%25077285374:tb64v128a avx
1333336133.33%24375278803:tb64v128
1333336133.33%951369082:tb64x
1333336133.33%951359759:_tb64x
1333336133.33%491451821:tb64s
E Sizeratio%E MB/sD MB/s10,000 bytes - 2023.07
13336133.36%89079920068:tb64v512vbmi
10000100.00%844188570310:memcpy
13336133.36%34963462167:_tb64v256 avx2
13336133.36%40722445525:tb64v256 avx2
13336133.36%22601272984:tb64v128a avx
13336133.36%21113269303:tb64v128
13336133.36%964868092:tb64x
13336133.36%962655999:_tb64x
13336133.36%493751841:tb64s

Benchmark Intel CPU: i7-9700k 3.6GHz gcc 11.2

E Sizeratio%E MB/sD MB/sName50,000 bytes - 2022.02
66668133.33279437837tb64v256Turbo Base64 avx2
66668133.32778922264b64avx2aklomp Base64 avx2
66668133.32530521980fb64avx2lemire Fastbase64 avx2
66668133.31734820686tb64v128aTurbo Base64 avx
66668133.31603518865tb64v128Turbo Base64 sse
66668133.31582013078b64avxaklomp Base64 avx
66668133.31532211302b64sseaklomp Base64 sse41
50000100.04759347623memcpy
E Sizeratio%E MB/sD MB/sName1 MB - 2022.02
1333336133.32908629748tb64v256Turbo Base64 avx2
1333336133.32615322515b64avx2Base64 avx2
1333336133.32368621231fb64avx2Fastbase64 avx2
1333336133.31689720215tb64v128aTurbo Base64 avx
1333336133.31593218749tb64v128Turbo Base64 sse
1333336133.31553712959b64avxBase64 avx
1333336133.31513511304b64sseBase64 sse41
1333336133.365465473TB64xTurbo Base64 scalar
1333336133.364954454b64plainBase64 plain
1333336133.319082752TB64sTurbo Base64 scalar
1333336133.325414289chromeGoogle Chrome base64
1333336133.326702299fb64plainFastBase64 plain
1333334135.41754219linuxLinux base64
1000000100.02868828656memcpy

<a name="short"></a> TurboBase64 vs. Base64 for short strings (incl. checking)

String lengthE MB/sD MB/sName50,000 bytes - short strings 2022.02
4 - 1623302161TB64avx2Turbo Base64 avx2
891734b64avx2Base64 avx2
8 - 3239633570TB64avx2Turbo Base64 avx2
1348943b64avx2Base64 avx2
16 - 6468815937TB64avx2Turbo Base64 avx2
25091488b64avx2Base64 avx2
32 - 128109468880TB64avx2Turbo Base64 avx2
49022777b64avx2Base64 avx2
Benchmark ARM Neon: Apple M1 3,5GHz (clang 12.0)
E MB/ssizeratioD MB/s50,000 bytes (2023.08)
24012.4366668133.34%15352.09tb64v128 (turbo-base64)
19087.5566668133.34%12515.17b64neon64 (aklomp/base64)
5611.4866668133.34%5092.64tb64s
9782.4566668133.34%6798.98tb64x
6181.3766668133.34%3108.54b64plain
45566.1650000100.00%45484.13memcpy
Benchmark ARM Neon: ARMv8 A73-ODROID-N2 1.8GHz (clang 6.0)
E Sizeratio%E MB/sD MB/sName30MB binary 2019.12
40000000133.320261650TB64neonTurbo Base64 Neon
40000000133.317951285b64neon64Base64 Neon
40000000133.312701095TB64xTurbo Base64 scalar
40000000133.3695965TB64sTurbo Base64 scalar
40000000133.3512782fb64neonFastbase64 SIMD Neon
40000000133.3565460ChromeGoogle Chrome base64
40000000133.3642614b64plainBase64 plain
40000000133.3506548fb64plainFastbase64 plain
40500000135.431491LinuxLinux base64
30000000100.038203834memcpy
<p>

Compile: (Download or clone Turbo Base64 SIMD)

    git clone https://github.com/powturbo/Turbo-Base64.git
    make

Usage: (Benchmark App)

    ./tb64app file 
    or  
    ./tb64app

Function usage:

static inline unsigned turbob64len(unsigned n)<br /> Base64 output length after encoding

unsigned tb64enc(const unsigned char *in, unsigned inlen, unsigned char *out)<br /> Encode binary input 'in' buffer into base64 string 'out'<br /> with automatic cpu detection for simd and switch (sse/avx2/scalar<br /> in : Input buffer to encode<br /> inlen : Length in bytes of input buffer<br /> out : Output buffer<br /> return value: Length of output buffer<br /> Remark : byte 'zero' is not written to end of output stream<br /> Caller must add 0 (out[outlen] = 0) for a null terminated string<br />

unsigned tb64dec(const unsigned char *in, unsigned inlen, unsigned char *out)<br /> Decode base64 input 'in' buffer into binary buffer 'out' <br /> in : input buffer to decode<br /> inlen : length in bytes of input buffer <br /> out : output buffer<br /> return value: >0 output buffer length<br /> 0 Error (invalid base64 input or input length = 0)<br />

Environment:

OS/Compiler (32 + 64 bits):
References:
* SIMD Base64 publications:

Last update: 06 AUG 2023