Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jamescook/fb64
Fast Base64 C extension
https://github.com/jamescook/fb64
base64 ruby
Last synced: about 22 hours ago
JSON representation
Fast Base64 C extension
- Host: GitHub
- URL: https://github.com/jamescook/fb64
- Owner: jamescook
- License: mit
- Created: 2017-10-20T00:18:31.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-20T01:01:59.000Z (almost 7 years ago)
- Last Synced: 2024-04-25T19:20:28.271Z (5 months ago)
- Topics: base64, ruby
- Language: Ruby
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### FB64 - Fast Base64
FB64 is a C extension that can encode and decode base64. It leverages the [Base64](https://github.com/aklomp/base64) library.
#### Installation
1) Download and compile [Base64](https://github.com/aklomp/base64)
2) Copy the library and headers to the appropriate directories,
such as /usr/local/lib and /usr/local/include on OSX.
3) `gem install fb64`#### Sample Usage
```ruby
require "fb64"
encoded = FB64.encode64("Sample String")
puts encoded
=> "U2FtcGxlIFN0cmluZw=="FB64.decode64(encoded)
=> "Sample String"
```#### Benchmarks
Run from 2.2Ghz Intel Core i7:```
Calculating -------------------------------------
FB64 encode large string
279.814 (± 7.5%) i/s - 8.372k in 30.097192s
Base64 encode large string
146.939 (± 3.4%) i/s - 4.410k in 30.043984sComparison:
FB64 encode large string: 279.8 i/s
Base64 encode large string: 146.9 i/s - 1.90x slowerCalculating -------------------------------------
FB64 decode large string
213.429 (± 4.7%) i/s - 6.400k in 30.052835s
Base64 decode large string
110.270 (± 2.7%) i/s - 3.311k in 30.051945sComparison:
FB64 decode large string: 213.4 i/s
Base64 decode large string: 110.3 i/s - 1.94x slowerCalculating -------------------------------------
FB64 encode small string
2.195M (± 3.3%) i/s - 65.770M in 29.999757s
Base64 encode small string
1.249M (± 6.1%) i/s - 37.348M in 30.025452sComparison:
FB64 encode small string: 2194957.8 i/s
Base64 encode small string: 1249343.9 i/s - 1.76x slowerCalculating -------------------------------------
FB64 decode small string
1.957M (± 8.3%) i/s - 58.318M in 30.049957s
Base64 decode small string
1.165M (± 4.8%) i/s - 34.910M in 30.036906sComparison:
FB64 decode small string: 1956556.9 i/s
Base64 decode small string: 1165117.6 i/s - 1.68x slower
```
Run `rake benchmark` after compiling to benchmark your own setup.#### Local development
1) `bundle exec rake test -- --with-libbase64-dir=/path/to/libbase64`