EP / tokyotyrant-java (http://code.google.com/p/tokyotyrant-java)

Java client for Tokyo Tyrant.

Clone this repository (size: 503.6 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/EP/tokyotyrant-java/
commit 255: f27906734222
parent 254: 9ed14a4068bd
branch: default
Added a benchmark for the spy memcached client.
Eung-ju PARK
4 months ago

Changed (Δ560 bytes):

raw changeset »

pom.xml (15 lines added, 1 lines removed)

src/test/java/tokyotyrant/example/MRDBBenchmark.java (1 lines added, 1 lines removed)

src/test/java/tokyotyrant/example/MemcachedBenchmark.java (11 lines added, 5 lines removed)

src/test/java/tokyotyrant/example/RDBBenchmark.java (1 lines added, 1 lines removed)

Up to file-list pom.xml:

42
42
				<enabled>false</enabled>
43
43
			</snapshots>
44
44
		</repository>
45
		<repository>
46
			<id>spy</id>
47
			<name>Spy Repository</name>
48
			<layout>default</layout>
49
			<url>http://bleu.west.spy.net/~dustin/m2repo/</url>
50
			<snapshots>
51
				<enabled>false</enabled>
52
			</snapshots>
53
		</repository>
45
54
	</repositories>
46
55
47
56
	<pluginRepositories>
108
117
			<version>4.0.1</version>
109
118
			<scope>test</scope>
110
119
		</dependency>
111
120
		<dependency>
121
			<groupId>spy</groupId>
122
			<artifactId>memcached</artifactId>
123
			<version>2.4.2</version>
124
		</dependency>
125
  
112
126
	</dependencies>
113
127
114
128
	<build>

Up to file-list src/test/java/tokyotyrant/example/MRDBBenchmark.java:

@@ -27,7 +27,7 @@ public class MRDBBenchmark {
27
27
				}
28
28
			}
29
29
		};
30
		for (int c : new int[] {1, 10, 100}) {
30
		for (int c : new int[] {1, 10, 100, 200, 300}) {
31
31
			System.out.println(c + ":" + (new Benchmark(c, 10000).run(task)) + "ms");
32
32
		}
33
33
		db.close();

Up to file-list src/test/java/tokyotyrant/example/MemcachedBenchmark.java:

@@ -9,14 +9,20 @@ import net.spy.memcached.transcoders.Tra
9
9
public class MemcachedBenchmark {
10
10
	public static void main(String[] args) throws Exception {
11
11
		final MemcachedClient db = new MemcachedClient(AddrUtil.getAddresses(args[0]));
12
		db.setTranscoder(new Transcoder<Object>() {
12
		final Transcoder<Object> transcoder = new Transcoder<Object>() {
13
13
			public CachedData encode(Object data) {
14
				return new CachedData(0, (byte[]) data);
14
				return new CachedData(0, (byte[]) data, getMaxSize());
15
15
			}
16
16
			public Object decode(CachedData cachedData) {
17
17
				return cachedData.getData();
18
18
			}
19
		});
19
			public boolean asyncDecode(CachedData arg0) {
20
				return false;
21
			}
22
			public int getMaxSize() {
23
				return CachedData.MAX_SIZE;
24
			}
25
		};
20
26
		final String key = "key";
21
27
		final byte[] value = new byte[128];
22
28
		value[0] = 1;
@@ -26,13 +32,13 @@ public class MemcachedBenchmark {
26
32
		Runnable task = new Runnable() {
27
33
			public void run() {
28
34
				try {
29
					assertArrayEquals(value, (byte[]) db.asyncGet(key).get());
35
					assertArrayEquals(value, (byte[]) db.asyncGet(key, transcoder).get());
30
36
				} catch (Exception e) {
31
37
					e.printStackTrace();
32
38
				}
33
39
			}
34
40
		};
35
		for (int c : new int[] {1, 10, 100}) {
41
		for (int c : new int[] {1, 10, 100, 200, 300}) {
36
42
			System.out.println(c + ":" + (new Benchmark(c, 10000).run(task)) + "ms");
37
43
		}
38
44
		db.shutdown();

Up to file-list src/test/java/tokyotyrant/example/RDBBenchmark.java:

@@ -25,7 +25,7 @@ public class RDBBenchmark {
25
25
				}
26
26
			}
27
27
		};
28
		for (int c : new int[] {1, 10, 100}) {
28
		for (int c : new int[] {1, 10, 100, 200, 300}) {
29
29
			System.out.println(c + ":" + (new Benchmark(c, 10000).run(task)) + "ms");
30
30
		}
31
31
		db.close();