Code Monkey home page Code Monkey logo

map_sets's Introduction

map_sets

https://travis-ci.org/k32/map_sets.svg?branch=master

It’s a drop-in replacement of OTP sets module based on maps. It’s much faster and simpler, as it makes heavy use of maps BIFs.

sets interface and sematics are fully preserved, so it should be sufficient to just use replace sets with map_sets in your codebase via sed.

Benchmarks

A few unscientific crude benchmarks:

Operating System: Linux
CPU Information: Intel(R) Core(TM) i5-4460  CPU @ 3.20GHz
Number of Available Cores: 4
Available memory: 7.74 GB
Elixir 1.7.4
Erlang 20.3.8.9

Benchmark suite executing with the following configuration:
warmup: 2 s
time: 10 s
memory time: 2 s
parallel: 1
inputs: none specified
Estimated total run time: 28 s

Name                         ips        average  deviation         median         99th %
sets from_list            215.46        4.64 ms    ±17.34%        4.43 ms        7.94 ms
map_sets from_list        154.53        6.47 ms    ±14.01%        6.25 ms        9.25 ms

Comparison:
sets from_list            215.46
map_sets from_list        154.53 - 1.39x slower

Memory usage statistics:

Name                  Memory usage
sets from_list            13.09 MB
map_sets from_list         0.46 MB - 0.04x memory usage

Benchmarking map_sets empty intersection...
Benchmarking sets empty intersection...

Name                                  ips        average  deviation         median         99th %
map_sets empty intersection        1.10 K        0.91 ms    ±21.91%        0.84 ms        1.16 ms
sets empty intersection            0.62 K        1.62 ms     ±3.55%        1.62 ms        1.74 ms

Comparison:
map_sets empty intersection        1.10 K
sets empty intersection            0.62 K - 1.79x slower

Memory usage statistics:

Name                           Memory usage
map_sets empty intersection        0.109 KB
sets empty intersection           173.25 KB - 1584.00x memory usage

Name                            ips        average  deviation         median         99th %
sets intersection            573.98        1.74 ms     ±6.34%        1.72 ms        2.15 ms
map_sets intersection        464.68        2.15 ms    ±26.53%        2.15 ms        4.20 ms

Comparison:
sets intersection            573.98
map_sets intersection        464.68 - 1.24x slower

Memory usage statistics:

Name                     Memory usage
sets intersection             0.25 MB
map_sets intersection         1.18 MB - 4.80x memory usage

Name                     ips        average  deviation         median         99th %
map_sets union        2.93 K        0.34 ms    ±24.78%        0.29 ms        0.50 ms
sets union            0.23 K        4.26 ms    ±10.48%        4.14 ms        5.74 ms

Comparison:
map_sets union        2.93 K
sets union            0.23 K - 12.47x slower

Memory usage statistics:

Name              Memory usage
map_sets union        0.150 MB
sets union            15.00 MB - 100.30x memory usage

map_sets's People

Contributors

k32 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

map_sets's Issues

Make UNUSED a more compact representation

Would it make sense to make the unused value either an empty binary, empty list or the empty atom '' so to reduce it's overhead when serialized using term_to_binary/1?

Documentation

Add edocs. In theory they could be identical to the OTP, but simple copying will (?) violate OTP's APL license

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.