Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests to triava cache v1.0.4 #7

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bash jmh-run.sh
bash processJmhResults.sh --dir /var/run/shm/jmh-result process
```

This requires Linux and gnuplot. Single benchmarks can alternatively be run
This requires Linux with gnuplot, pandoc and asciidoctor. Single benchmarks can alternatively be run
via: `java -jar jmh-suite/target/benchmarks.jar [ jmh-parameters ]`

## The maven modules
Expand Down
2 changes: 1 addition & 1 deletion jmh-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ test -d $TARGET || mkdir -p $TARGET;
if test -n "$backends"; then
COMPLETE="$backends";
elif test -z "$no3pty"; then
COMPLETE="$COMPLETE thirdparty.CaffeineCacheFactory thirdparty.GuavaCacheFactory thirdparty.EhCache2Factory";
COMPLETE="$COMPLETE thirdparty.CaffeineCacheFactory thirdparty.GuavaCacheFactory thirdparty.EhCache2Factory thirdparty.TCache1Factory";
# "thirdparty.EhCache3Factory";
fi

Expand Down
3 changes: 2 additions & 1 deletion processJmhResults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ sed "$script";
CACHE_FACTORY_LIST="org.cache2k.benchmark.Cache2kFactory \
org.cache2k.benchmark.thirdparty.CaffeineCacheFactory \
org.cache2k.benchmark.thirdparty.GuavaCacheFactory \
org.cache2k.benchmark.thirdparty.EhCache2Factory";
org.cache2k.benchmark.thirdparty.EhCache2Factory \
org.cache2k.benchmark.thirdparty.TCache1Factory";

# "org.cache2k.benchmark.thirdparty.EhCache3Factory";

Expand Down
2 changes: 1 addition & 1 deletion thirdparty/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<dependency>
<groupId>com.trivago</groupId>
<artifactId>triava</artifactId>
<version>0.9.5</version>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache.internal</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@

import com.trivago.triava.tcache.TCacheFactory;
import com.trivago.triava.tcache.core.Builder;
import com.trivago.triava.tcache.eviction.Cache;
import com.trivago.triava.tcache.Cache;
import org.cache2k.benchmark.BenchmarkCache;
import org.cache2k.benchmark.BenchmarkCacheFactory;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
Expand All @@ -45,7 +46,7 @@ public class TCache1Factory extends BenchmarkCacheFactory {
public BenchmarkCache<Integer, Integer> create(int _maxElements) {
TCacheFactory factory = TCacheFactory.standardFactory();
Builder<Integer, Integer> b = factory.builder();
b.setExpectedMapSize(_maxElements);
b.setMaxElements(_maxElements);

/**
* Set a cache name. For some reason, auto-assigning a name does not work properly in this JMH based test.
Expand All @@ -57,22 +58,20 @@ public BenchmarkCache<Integer, Integer> create(int _maxElements) {
b.setId(id);

if (withExpiry) {
b.setMaxCacheTime(5 * 60);
b.setMaxIdleTime(5 * 60);
b.setMaxCacheTime(5, TimeUnit.MINUTES);
b.setMaxIdleTime(5, TimeUnit.MINUTES);
}

return new MyBenchmarkCacheAdapter(b, _maxElements, factory);
return new MyBenchmarkCacheAdapter(b, _maxElements);
}

static class MyBenchmarkCacheAdapter extends BenchmarkCache<Integer, Integer> {
final int size;
final Cache<Integer, Integer> cache;
final public TCacheFactory factory;

public MyBenchmarkCacheAdapter(Builder<Integer, Integer> builder, int maxElements, TCacheFactory factory) {
public MyBenchmarkCacheAdapter(Builder<Integer, Integer> builder, int maxElements) {
super();
this.size = maxElements;
this.factory = factory;
this.cache = builder.build();
}

Expand All @@ -93,7 +92,7 @@ public void put(final Integer key, final Integer value) {

@Override
public void close() {
factory.destroyCache(cache.id());
cache.close();
}

@Override
Expand Down