> lru-fast@0.2.0 benchmark /Users/rsms/src/js-lru
> node --expose-gc benchmark.js

N = 10000, Iterations = 1000

----------
  function (){
    // 1. put
    //    Simply append a new entry.
    //    There will be no reordering since we simply append to the tail.
    for (var i=N; --i;)
      c.put('key'+i, i);
  }
   rss:        +9,276 kB -- (19,744 kB -> 29,020 kB)
   heap total: +6,144 kB -- (11,260 kB -> 17,404 kB)
   heap used:  +2,218 kB -- (3,809 kB -> 6,027 kB)

  -- 1.228 ms avg per iteration --

----------
  function (){
    // 2. get recent -> old
    //    Get entries starting with newest, effectively reversing the list.
    //
    // a. For each get, a find is first executed implemented as a native object with
    //    keys mapping to entries, so this should be reasonably fast as most native
    //    objects are implemented as hash maps.
    //
    // b. For each get, the aquired item will be moved to tail which includes a
    //    maximum of 7 assignment operations (minimum 3).
    for (var i=1,L=N+1; i<L; ++i)
      c.get('key'+i, i);
  }
   rss:        +336 kB -- (29,064 kB -> 29,400 kB)
   heap total: +0 kB -- (18,428 kB -> 18,428 kB)
   heap used:  -254 kB -- (6,048 kB -> 5,794 kB)

  -- 1.206 ms avg per iteration --

----------
  function (){
    // 3. get old -> recent
    //    Get entries starting with oldest, effectively reversing the list.
    //
    //  - Same conditions apply as for test 2.
    for (var i=1,L=N+1; i<L; ++i)
      c.get('key'+i);
  }
   rss:        -32 kB -- (29,468 kB -> 29,436 kB)
   heap total: +0 kB -- (18,428 kB -> 18,428 kB)
   heap used:  +4 kB -- (5,782 kB -> 5,785 kB)

  -- 1.273 ms avg per iteration --

----------
  function (){
    // 4. get missing
    //    Get try to get entries not in the cache.
    //  - Same conditions apply as for test 2, section a.
    for (var i=1,L=N+1; i<L; ++i)
      c.get('xkey'+i);
  }
   rss:        +240 kB -- (29,436 kB -> 29,676 kB)
   heap total: +0 kB -- (18,428 kB -> 18,428 kB)
   heap used:  +5 kB -- (5,781 kB -> 5,786 kB)

  -- 2.457 ms avg per iteration --

----------
  function (){
    // 5. put overflow
    //    Overflow the cache with N more items than it can hold.
    // a. The complexity of put in this case should be:
    //    ( <get whith enough space> + <shift> )
    for (var i=N; --i;)
      c.put('key2_'+i, i);
  }
   rss:        +1,836 kB -- (29,676 kB -> 31,512 kB)
   heap total: +1,812 kB -- (18,428 kB -> 20,240 kB)
   heap used:  +536 kB -- (5,781 kB -> 6,318 kB)

  -- 1.274 ms avg per iteration --

----------
  function (){
    // 6. shift head -> tail
    //    Remove all entries going from head to tail
    for (var i=1,L=N+1; i<L; ++i)
      c.shift();
  }
   rss:        -240 kB -- (31,236 kB -> 30,996 kB)
   heap total: +1,260 kB -- (18,192 kB -> 19,452 kB)
   heap used:  -2,076 kB -- (6,313 kB -> 4,238 kB)

  -- 0.046 ms avg per iteration --

----------
  function (){
    // 7. put 
    //    Simply put N new items into an empty cache with exactly N space.
    for (var i=N; --i;)
      c.put('key'+i, i);
  }
   rss:        +9,316 kB -- (29,220 kB -> 38,536 kB)
   heap total: +8,192 kB -- (18,428 kB -> 26,620 kB)
   heap used:  +1,303 kB -- (4,234 kB -> 5,537 kB)

  -- 1.241 ms avg per iteration --

----------
  function (){
    // 8. remove random
    // a. Most operations (which are not entries at head or tail) will cause closes
    //    siblings to be relinked.
    for (var i=shuffledKeys.length, key; key = shuffledKeys[--i]; ) {
      c.remove('key'+i, i);
    }
  }
   rss:        +136 kB -- (38,696 kB -> 38,832 kB)
   heap total: +0 kB -- (26,620 kB -> 26,620 kB)
   heap used:  -1,225 kB -- (5,660 kB -> 4,435 kB)

  -- 2.366 ms avg per iteration --
