Mercurial > hg > Members > tatsuki > jungle-bench
annotate src/main/java/example/WriteThread.java @ 8:442463aa27e5
miss Spell revision
author | one |
---|---|
date | Tue, 01 Apr 2014 18:28:34 +0900 |
parents | 24fca21a576e |
children |
rev | line source |
---|---|
3 | 1 package example; |
2 | |
3 import java.nio.ByteBuffer; | |
4 | |
5 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; | |
6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; | |
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; | |
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; | |
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; | |
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; | |
11 import junit.framework.Assert; | |
12 | |
13 public class WriteThread extends Thread { | |
14 public static final String key = "name"; | |
4 | 15 public String valueString = "tatsuki"; |
16 public ByteBuffer value = ByteBuffer.wrap(valueString.getBytes()); | |
3 | 17 Jungle j; |
18 NodePath childPath; | |
8 | 19 int loopCount; |
3 | 20 int num; |
4 | 21 |
8 | 22 WriteThread(Jungle j, NodePath childPath, int loopCount, int num) { |
3 | 23 this.num = num; |
24 this.valueString = this.valueString + Integer.toString(num); | |
25 this.value = ByteBuffer.wrap(valueString.getBytes()); | |
8 | 26 this.loopCount = loopCount; |
3 | 27 this.j = j; |
28 this.childPath = childPath; | |
29 } | |
4 | 30 |
31 public void run() { | |
32 JungleTree tree = j.getTreeByName("tree");// 名前を取得 | |
33 Either<Error, JungleTreeEditor> either; | |
8 | 34 System.out.println("loopCount = " + loopCount); |
4 | 35 long t1 = System.currentTimeMillis();// 時間の測定開始 |
36 | |
8 | 37 for (int count = 0; count < loopCount; count++) { |
5
24fca21a576e
add Read thread source
Kanagawa TATSUKI <tatsuki@ie.u-ryukyu.ac.jp>
parents:
4
diff
changeset
|
38 do { |
4 | 39 JungleTreeEditor editor = tree.getTreeEditor();// Treeのeditorを作成 |
40 either = editor.putAttribute(childPath, key, value); | |
41 if (either.isA()) { | |
42 Assert.fail(); | |
43 } | |
44 editor = either.b(); | |
45 either = editor.success(); | |
5
24fca21a576e
add Read thread source
Kanagawa TATSUKI <tatsuki@ie.u-ryukyu.ac.jp>
parents:
4
diff
changeset
|
46 } while (either.isA()); |
3 | 47 } |
48 long t2 = System.currentTimeMillis(); | |
4 | 49 System.out.println(num + "番目終わり" + (t2 - t1) + "秒"); |
3 | 50 } |
51 } |