Skip to content

Commit

Permalink
Fix scope
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Oct 1, 2017
1 parent c55b726 commit 2be6027
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@ const createTimestamp = () => {
return () => Date.now() - start
}

module.exports = (lru, num = 1000) => {
module.exports = (createLRU, num = 1000) => {
const lru = createLRU(num)

//set
let setTimestamp = createTimestamp()
for(const i = 0; i < num; i++) lru.set(i, Math.random())
for(let i = 0; i < num; i++) lru.set(i, Math.random())
setTimestamp = setTimestamp()

// get
let getTimestamp = createTimestamp()
for(const i = 0; i < num; i++) lru.get(i)
let getTimestamp = getTimestamp
for(let i = 0; i < num; i++) lru.get(i)
getTimestamp = getTimestamp()

//update
let updateTimestmap = createTimestamp()
for(const i = 0; i < num; i++) lru.set(i, Math.random())
updateTimestmap = createTimestamp()
for(let i = 0; i < num; i++) lru.set(i, Math.random())
updateTimestmap = updateTimestmap()

// get
let getTimestampTwo = createTimestamp()
for(const i = 0; i < num; i++) lru.get(i)
getTimestampTwo = createTimestamp()
for(let i = 0; i < num; i++) lru.get(i)
getTimestampTwo = getTimestampTwo()


//evict
let evictTimestamp = createTimestamp()
const evicts = num*2
for(const i = num; i < evicts; i++) lru.set(i, Math.random())
evictTimestamp = createTimestamp()
for(let i = num; i < evicts; i++) lru.set(i, Math.random())
evictTimestamp = evictTimestamp()

return [
setTimestamp,
Expand Down

0 comments on commit 2be6027

Please sign in to comment.