Mercurial > hg > Members > tatsuki > jungle-bench
view 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 |
line wrap: on
line source
package example; import java.nio.ByteBuffer; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; import junit.framework.Assert; public class WriteThread extends Thread { public static final String key = "name"; public String valueString = "tatsuki"; public ByteBuffer value = ByteBuffer.wrap(valueString.getBytes()); Jungle j; NodePath childPath; int loopCount; int num; WriteThread(Jungle j, NodePath childPath, int loopCount, int num) { this.num = num; this.valueString = this.valueString + Integer.toString(num); this.value = ByteBuffer.wrap(valueString.getBytes()); this.loopCount = loopCount; this.j = j; this.childPath = childPath; } public void run() { JungleTree tree = j.getTreeByName("tree");// 名前を取得 Either<Error, JungleTreeEditor> either; System.out.println("loopCount = " + loopCount); long t1 = System.currentTimeMillis();// 時間の測定開始 for (int count = 0; count < loopCount; count++) { do { JungleTreeEditor editor = tree.getTreeEditor();// Treeのeditorを作成 either = editor.putAttribute(childPath, key, value); if (either.isA()) { Assert.fail(); } editor = either.b(); either = editor.success(); } while (either.isA()); } long t2 = System.currentTimeMillis(); System.out.println(num + "番目終わり" + (t2 - t1) + "秒"); } }