package org.cache2k.benchmark.thirdparty;

/*
 * #%L
 * Benchmarks: third party products.
 * %%
 * Copyright (C) 2013 - 2019 headissue GmbH, Munich
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import org.cache2k.benchmark.EvictionBenchmarkRunnerRule;
import org.cache2k.benchmark.EvictionTestVariation;
import org.cache2k.benchmark.PrototypeCacheFactory;
import org.cache2k.benchmark.TraceCollections;
import org.cache2k.benchmark.cache.CaffeineSimulatorOptPolicyFactory;
import org.cache2k.benchmark.cache.CaffeineStarFactory;
import org.cache2k.benchmark.prototype.evictionPolicies.Cache2kV12Eviction;
import org.cache2k.benchmark.prototype.evictionPolicies.Cache2kV14Eviction;
import org.cache2k.benchmark.traces.Traces;
import org.cache2k.benchmarks.clockProPlus.CAR;
import org.cache2k.benchmarks.clockProPlus.ClockProP;
import org.cache2k.benchmarks.clockProPlus.SimpleCacheFactory;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

/**
 * Example how to use the eviction test variation builder and test runner
 * to run eviction benchmarks on a combination of caches, sizes and traces.
 *
 * @author Jens Wilke
 */
@RunWith(Parameterized.class)
public class SomeTracesWithSomeCachesBenchmark {

	public final static EvictionTestVariation.Builder CACHES = new EvictionTestVariation.Builder()
		.add(SimpleCacheFactory.of(ClockProP.class))
		.add(SimpleCacheFactory.of(CAR.class))
		.add(PrototypeCacheFactory.of(Cache2kV14Eviction.class))
		.add(new CaffeineStarFactory())
		.add(new CaffeineSimulatorOptPolicyFactory().setName("OPT"));

	public final static EvictionTestVariation.Builder TRACES =
		new EvictionTestVariation.Builder()
			.add(Traces.FINANCIAL1_1M)
			.add(Traces.OLTP, 128, 256, 512)
			.add(Traces.SCARAB_RECS);

	@ClassRule
	public static EvictionBenchmarkRunnerRule runner = new EvictionBenchmarkRunnerRule()
		.candidateAndPeers(CACHES)
		.setReadStoredResults(false);

	@Parameterized.Parameters(name="{0}")
	public static Iterable<? extends Object> data() {
		return new EvictionTestVariation.Builder().merge(CACHES).merge(TRACES).build();
	}

	private EvictionTestVariation variation;

	public SomeTracesWithSomeCachesBenchmark(final EvictionTestVariation variation) {
		this.variation = variation;
	}

	@Test
	public void test() {
		runner.runBenchmark(variation);
	}

}

@@ -1801,17 +1801,18 @@
 mark %7B%0A%0A
-%09
+  
 public f
@@ -1898,18 +1898,20 @@
 ilder()%0A
-%09%09
+    
 .add(Sim
@@ -1943,26 +1943,28 @@
 roP.class))%0A
-%09%09
+    
 .add(SimpleC
@@ -1986,26 +1986,28 @@
 CAR.class))%0A
-%09%09
+    
 .add(Prototy
@@ -2051,18 +2051,20 @@
 class))%0A
-%09%09
+    
 .add(new
@@ -2087,18 +2087,20 @@
 tory())%0A
-%09%09
+    
 .add(new
@@ -2154,17 +2154,18 @@
 PT%22));%0A%0A
-%09
+  
 public f
@@ -2215,18 +2215,20 @@
 RACES =%0A
-%09%09
+    
 new Evic
@@ -2255,19 +2255,22 @@
 ilder()%0A
-%09%09%09
+      
 .add(Tra
@@ -2288,19 +2288,22 @@
 AL1_1M)%0A
-%09%09%09
+      
 .add(Tra
@@ -2331,11 +2331,14 @@
 12)%0A
-%09%09%09
+      
 .add
@@ -2360,17 +2360,18 @@
 RECS);%0A%0A
-%09
+  
 @ClassRu
@@ -2373,17 +2373,18 @@
 assRule%0A
-%09
+  
 public s
@@ -2460,18 +2460,20 @@
 rRule()%0A
-%09%09
+    
 .candida
@@ -2491,18 +2491,20 @@
 CACHES)%0A
-%09%09
+    
 .setRead
@@ -2526,17 +2526,18 @@
 alse);%0A%0A
-%09
+  
 @Paramet
@@ -2566,17 +2566,18 @@
 =%22%7B0%7D%22)%0A
-%09
+  
 public s
@@ -2618,18 +2618,20 @@
 ata() %7B%0A
-%09%09
+    
 return n
@@ -2702,21 +2702,23 @@
 uild();%0A
-%09%7D%0A%0A%09
+  %7D%0A%0A  
 private 
@@ -2751,17 +2751,18 @@
 ation;%0A%0A
-%09
+  
 public S
@@ -2835,18 +2835,20 @@
 tion) %7B%0A
-%09%09
+    
 this.var
@@ -2871,20 +2871,23 @@
 on;%0A
-%09%7D%0A%0A%09
+  %7D%0A%0A  
 @Test%0A
-%09
+  
 publ
@@ -2907,10 +2907,12 @@
 ) %7B%0A
-%09%09
+    
 runn
@@ -2943,9 +2943,10 @@
 n);%0A
-%09
+  
 %7D%0A%0A%7D

fix indet