const Benchmark = require('benchmark');
const FixedSizeCache = require("../index");
const suite = new Benchmark.Suite;

function buildObject(size) {
	const largeObject = {};

	for (let i = 0; i < size; i++) {
		largeObject["key" + i] = Math.random();
	}

	return largeObject;
}

// Test objects
const largeObject = buildObject(10000);
const twentyLargeObjects = [];
for (let i = 0; i < 20; i++) {
	twentyLargeObjects[i] = buildObject(10000);
}
const twoTousandSmallObjects = [];
for (let i = 0; i < 2000; i++) {
	twoTousandSmallObjects[i] = buildObject(10);
}

// Actual tests
suite
.add('add 5 large equal items V2', function() {
	let cache = new FixedSizeCache();

	for (let i = 0; i < 5; i++) {
		cache.set("bob" + i, largeObject);
	}
})
.add('add 5 large different items V2', function() {
	let cache = new FixedSizeCache();

	for (let i = 0; i < 5; i++) {
		cache.set("bob" + i, twentyLargeObjects[i]);
	}
})
.add('add 20 small different items V2', function() {
	let cache = new FixedSizeCache();

	for (let i = 0; i < 200; i++) {
		cache.set("bob" + i, twoTousandSmallObjects[i]);
	}
})

.on('cycle', function(event) {
  console.log(String(event.target));
})
.run({ 'async': true });

@@ -142,17 +142,20 @@
 size) %7B%0A
-%09
+    
 const la
@@ -171,17 +171,20 @@
  = %7B%7D;%0A%0A
-%09
+    
 for (let
@@ -208,18 +208,24 @@
  i++) %7B%0A
-%09%09
+        
 largeObj
@@ -260,13 +260,19 @@
 ();%0A
-%09%7D%0A%0A%09
+    %7D%0A%0A    
 retu
@@ -408,17 +408,20 @@
  i++) %7B%0A
-%09
+    
 twentyLa
@@ -526,17 +526,20 @@
  i++) %7B%0A
-%09
+    
 twoTousa
@@ -640,33 +640,36 @@
 ', function() %7B%0A
-%09
+    
 let cache = new 
@@ -679,33 +679,36 @@
 edSizeCache();%0A%0A
-%09
+    
 for (let i = 0; 
@@ -713,34 +713,40 @@
 ; i %3C 5; i++) %7B%0A
-%09%09
+        
 cache.set(%22bob%22 
@@ -764,17 +764,20 @@
 bject);%0A
-%09
+    
 %7D%0A%7D)%0A.ad
@@ -817,33 +817,36 @@
 ', function() %7B%0A
-%09
+    
 let cache = new 
@@ -856,33 +856,36 @@
 edSizeCache();%0A%0A
-%09
+    
 for (let i = 0; 
@@ -890,34 +890,40 @@
 ; i %3C 5; i++) %7B%0A
-%09%09
+        
 cache.set(%22bob%22 
@@ -947,25 +947,28 @@
 bjects%5Bi%5D);%0A
-%09
+    
 %7D%0A%7D)%0A.add('a
@@ -1013,17 +1013,20 @@
 ion() %7B%0A
-%09
+    
 let cach
@@ -1052,17 +1052,20 @@
 che();%0A%0A
-%09
+    
 for (let
@@ -1092,10 +1092,16 @@
 ) %7B%0A
-%09%09
+        
 cach
@@ -1149,9 +1149,12 @@
 %5D);%0A
-%09
+    
 %7D%0A%7D)

Converts to spaces