Giter Club home page Giter Club logo

bitarray's Introduction

bitarray

Bitarray is a NIF library to provide an alternative to hipe_bifs:bitarray* functions, which become unusable in certain circumstances (platform doesn't support HiPE, halfword emulator).

Build

./rebar compile

Test

./rebar get-deps compile && ./rebar ct skip_deps=true

Usage

The bitarrays are 0-indexed (based on HiPE's bitarrays), and run with three functions: new/2, update/3, and sub/2:

%% 20 bits array, initialized to false
Bits = bitarray:new(20, false),
%% flips the bits 0, 13 and 19 to true
bitarray:update(Bits, 0, true),  % lower boundary
bitarray:update(Bits, 13, true),
bitarray:update(Bits, 19, true), % max boundary for 20 bits
%% Reads the 6th and 13th bits:
false = bitarray:sub(Bits, 6),
true = bitarray:sub(Bits, 13).

Note that there is also a new/1 function that defaults to new(N, false).

Performance

The bitarray application is, depending on the test run, on par with HiPE bitarrays in the best cases, and nearly twice as slow in the worst case. Initial allocation for a bitarray is the worst part, being nearly 10x slower than their HiPE counterparts.

Note that they're generally much faster than any in-Erlang attempt at things, such as using binaries if you need to update rather frequently.

This application may therefore be seen as a backup plan for the HiPE bitarrays, not a performance improvement.

bitarray's People

Contributors

ferd avatar

Watchers

Zvi avatar James Cloos avatar  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.