Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1139)

Side by Side Diff: pkg/analysis_server/test/index/page_node_manager_test.dart

Issue 321953002: FilePageManager - disk based PageManager. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Improved tests. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.index.page_node_manager; 5 library test.index.page_node_manager;
6 6
7 import 'dart:math'; 7 import 'dart:math';
8 import 'dart:typed_data'; 8 import 'dart:typed_data';
9 9
10 import 'package:analysis_server/src/index/b_plus_tree.dart'; 10 import 'package:analysis_server/src/index/b_plus_tree.dart';
(...skipping 26 matching lines...) Expand all
37 37
38 /** 38 /**
39 * A stress test for [BPlusTree] using [PageNodeManager]. 39 * A stress test for [BPlusTree] using [PageNodeManager].
40 */ 40 */
41 _treeWithPageNodeManager() { 41 _treeWithPageNodeManager() {
42 int pageSize = 256; 42 int pageSize = 256;
43 MemoryPageManager pageManager = new MemoryPageManager(pageSize); 43 MemoryPageManager pageManager = new MemoryPageManager(pageSize);
44 NodeManager<int, String, int> nodeManager = new PageNodeManager<int, String>( 44 NodeManager<int, String, int> nodeManager = new PageNodeManager<int, String>(
45 pageManager, Uint32Codec.INSTANCE, new FixedStringCodec(7)); 45 pageManager, Uint32Codec.INSTANCE, new FixedStringCodec(7));
46 // NodeManager<int, String, int> nodeManager = new MemoryNodeManager(); 46 // NodeManager<int, String, int> nodeManager = new MemoryNodeManager();
47 int maxIndexKeys = (pageSize - 64) ~/ (4 + 4); 47 print('maxIndexKeys: ${nodeManager.maxIndexKeys} '
48 int maxLeafKeys = (pageSize - 64) ~/ (4 + (2 + 2 * 7)); 48 'maxLeafKeys: ${nodeManager.maxLeafKeys}');
49 print('maxIndexKeys: $maxIndexKeys maxLeafKeys: $maxLeafKeys'); 49 BPlusTree<int, String, int> tree = new BPlusTree(_intComparator, nodeManager);
50 BPlusTree<int, String, int> tree = new BPlusTree(maxIndexKeys, maxLeafKeys,
51 _intComparator, nodeManager);
52 int maxKey = 1000000; 50 int maxKey = 1000000;
53 int tryCount = 1000; 51 int tryCount = 1000;
54 Set<int> keys = new Set<int>(); 52 Set<int> keys = new Set<int>();
55 { 53 {
56 Random random = new Random(); 54 Random random = new Random();
57 for (int i = 0; i < tryCount; i++) { 55 for (int i = 0; i < tryCount; i++) {
58 int key = random.nextInt(maxKey); 56 int key = random.nextInt(maxKey);
59 keys.add(key); 57 keys.add(key);
60 tree.insert(key, 'V$key'); 58 tree.insert(key, 'V$key');
61 } 59 }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 268 }
271 269
272 test_all() { 270 test_all() {
273 // encode 271 // encode
274 codec.encode(buffer, 42); 272 codec.encode(buffer, 42);
275 expect(bytes, [0, 0, 0, 42]); 273 expect(bytes, [0, 0, 0, 42]);
276 // decode 274 // decode
277 expect(codec.decode(buffer), 42); 275 expect(codec.decode(buffer), 42);
278 } 276 }
279 } 277 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/index/file_page_manager_test.dart ('k') | pkg/analysis_server/test/index/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698