<commit_before>'use strict'

let Benchmark = require('benchmark')
let memoize1 = require('./1')
let underscore = require('underscore').memoize

//
// Fibonacci suite
//

let fibonacci = (n) => {
  return n < 2 ? n: fibonacci(n - 1) + fibonacci(n - 2)
}

let memoized1 = memoize1(fibonacci)
let memoizedUnderscore = underscore(fibonacci)

let suiteFibonnaci = new Benchmark.Suite()

suiteFibonnaci
  .add('vanilla', () => {
    fibonacci(15)
  })
  .add('algorithm1', () => {
    memoized1(15)
  })
  .add('underscore', () => {
    memoizedUnderscore(15)
  })
  .on('cycle', (event) => {
    console.log(String(event.target))
  })
  .on('complete', function() {
    console.log('Fastest is ' + this.filter('fastest').map('name'))
  })
  .run({'async': true})
<commit_msg>Add `lodash.memoize` to benchmark suite<commit_after>'use strict'

let Benchmark = require('benchmark')
let memoize1 = require('./1')
let underscore = require('underscore').memoize
let lodash = require('lodash').memoize

//
// Fibonacci suite
//

let fibonacci = (n) => {
  return n < 2 ? n: fibonacci(n - 1) + fibonacci(n - 2)
}

let memoized1 = memoize1(fibonacci)
let memoizedUnderscore = underscore(fibonacci)
let memoizedLodash = lodash(fibonacci)

let suiteFibonnaci = new Benchmark.Suite()

suiteFibonnaci
  .add('vanilla', () => {
    fibonacci(15)
  })
  .add('algorithm1', () => {
    memoized1(15)
  })
  .add('underscore', () => {
    memoizedUnderscore(15)
  })
  .add('lodash', () => {
    memoizedLodash(15)
  })
  .on('cycle', (event) => {
    console.log(String(event.target))
  })
  .on('complete', function() {
    console.log('Fastest is ' + this.filter('fastest').map('name'))
  })
  .run({'async': true})

{'fraction_non_alphanumeric': 0.19210371243370655, 'fraction_numerical': 0.01885680612846199, 'mean_word_length': 3.8238636363636362, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7614691', 'n_tokens_mistral': 678, 'n_tokens_neox': 650, 'n_words': 114}