8
|
1 using UnityEngine;
|
|
2 using System.Collections;
|
|
3 using JungleDB;
|
|
4
|
|
5 public class BenchMarkTest : MonoBehaviour {
|
|
6
|
|
7 public static string key = "KEY";
|
|
8 public static string indexKey = "INDEXKEY";
|
|
9 // Use this for initialization
|
|
10 void Start () {
|
|
11 System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
|
|
12 sw.Start ();
|
|
13 Jungle jungle = new DefaultJungle(new NullJournal(), "hoge", new DefaultTreeEditor(new DefaultTraverser()));
|
|
14 jungle.createNewTree("TestTree");
|
|
15 JungleTree tree = jungle.getTreeByName("TestTree");
|
|
16 JungleTreeEditor editor = tree.getTreeEditor();
|
|
17 editor = createTree(editor, 0, 3, new DefaultNodePath());
|
|
18 Either<Error, JungleTreeEditor> either = editor.commit();
|
|
19 DebugCommon.Assert (either.isA (), "[Error]" + either.a());
|
|
20 sw.Stop ();
|
|
21 print ("[Time]" + sw.Elapsed);
|
|
22 }
|
|
23
|
|
24 public JungleTreeEditor createTree(JungleTreeEditor editor, int _curY, int _maxHeight, NodePath path) {
|
|
25
|
|
26 if (_curY == _maxHeight) {
|
|
27 return editor;
|
|
28 }
|
|
29 for (int i = 0; i < 3; i++) {
|
|
30 Either<Error, JungleTreeEditor> either = editor.addNewChildAt (path, _curY);
|
|
31 DebugCommon.Assert (either.isA (), "Error");
|
|
32 editor = either.b ();
|
|
33 string value = path.add (_curY).ToString ();
|
|
34 either = editor.putAttribute (path.add (_curY), key, System.Text.Encoding.ASCII.GetBytes (value));
|
|
35 DebugCommon.Assert (either.isA (), "Error");
|
|
36 editor = either.b ();
|
|
37 string value2 = value + "+ index";
|
|
38 either = editor.putAttribute (path.add (_curY), indexKey, System.Text.Encoding.ASCII.GetBytes (value2));
|
|
39 DebugCommon.Assert (either.isA (), "Error");
|
|
40 editor = either.b ();
|
|
41 editor = createTree (editor, _curY + 1, _maxHeight, path);
|
|
42 }
|
|
43 return editor;
|
|
44 }
|
|
45 }
|