23 private static final String STORAGE_NAME = "rmsbenchmark"; |
23 private static final String STORAGE_NAME = "rmsbenchmark"; |
24 private static final int REPEAT = 100; |
24 private static final int REPEAT = 100; |
25 private int LENGTH; |
25 private int LENGTH; |
26 |
26 |
27 private RecordStore recordStore; |
27 private RecordStore recordStore; |
|
28 private String[] STORE_NAMES; |
|
29 |
28 |
30 |
29 public Storage(int aLength) |
31 public Storage(int aLength) |
30 { |
32 { |
31 LENGTH = aLength; |
33 LENGTH = aLength; |
32 try |
34 try |
33 { |
35 { |
34 recordStore = RecordStore.openRecordStore(STORAGE_NAME, true); |
36 recordStore = RecordStore.openRecordStore(STORAGE_NAME, true); |
|
37 createMultiStores(); |
35 } |
38 } |
36 catch (RecordStoreException _ex) |
39 catch (RecordStoreException _ex) |
37 { |
40 { |
38 System.out.println("RecordStoreException: " + _ex.toString()); |
41 System.out.println("RecordStoreException: " + _ex.toString()); |
39 } |
42 } |
40 Utils.initRandom(); |
43 Utils.initRandom(); |
|
44 } |
|
45 |
|
46 private void createMultiStores() throws RecordStoreException |
|
47 { |
|
48 STORE_NAMES = new String[REPEAT]; |
|
49 // create stores |
|
50 for(int i = 0; i < STORE_NAMES.length; i++) |
|
51 { |
|
52 STORE_NAMES[i] = "multistore" + i; |
|
53 RecordStore r = RecordStore.openRecordStore(STORE_NAMES[i], true); |
|
54 r.closeRecordStore(); |
|
55 } |
|
56 } |
|
57 |
|
58 private void deleteMultiStores() throws RecordStoreException |
|
59 { |
|
60 for(int i = 0; i < STORE_NAMES.length; i++) |
|
61 { |
|
62 RecordStore.deleteRecordStore(STORE_NAMES[i]); |
|
63 } |
41 } |
64 } |
42 |
65 |
43 public void clean() |
66 public void clean() |
44 { |
67 { |
45 try |
68 try |
46 { |
69 { |
47 recordStore.closeRecordStore(); |
70 recordStore.closeRecordStore(); |
48 RecordStore.deleteRecordStore(STORAGE_NAME); |
71 RecordStore.deleteRecordStore(STORAGE_NAME); |
|
72 deleteMultiStores(); |
49 } |
73 } |
50 catch (RecordStoreException _ex) |
74 catch (RecordStoreException _ex) |
51 { |
75 { |
52 System.out.println("RecordStoreException: " + _ex.toString()); |
76 System.out.println("RecordStoreException: " + _ex.toString()); |
53 } |
77 } |
328 System.out.println("RecordStoreException: " + _ex.toString()); |
352 System.out.println("RecordStoreException: " + _ex.toString()); |
329 } |
353 } |
330 return score; |
354 return score; |
331 } |
355 } |
332 |
356 |
|
357 public String openMultipleStores() |
|
358 { |
|
359 String score = ""; |
|
360 try |
|
361 { |
|
362 RecordStore[] stores = new RecordStore[STORE_NAMES.length]; |
|
363 // open stores |
|
364 Utils.startTiming(); |
|
365 for (int i = 0; i < STORE_NAMES.length; i++) |
|
366 { |
|
367 stores[i] = RecordStore.openRecordStore(STORE_NAMES[i], false); |
|
368 } |
|
369 Utils.stopTiming(); |
|
370 score = Utils.getTime(Utils.getDiff()); |
|
371 |
|
372 // close stores |
|
373 for (int i = 0; i < STORE_NAMES.length; i++) |
|
374 { |
|
375 stores[i].closeRecordStore(); |
|
376 } |
|
377 |
|
378 } |
|
379 catch (RecordStoreException _ex) |
|
380 { |
|
381 System.out.println("RecordStoreException: " + _ex.toString()); |
|
382 } |
|
383 return score; |
|
384 } |
|
385 |
|
386 public String closeMultipleStores() |
|
387 { |
|
388 String score = ""; |
|
389 try |
|
390 { |
|
391 RecordStore[] stores = new RecordStore[STORE_NAMES.length]; |
|
392 // open stores |
|
393 for (int i = 0; i < STORE_NAMES.length; i++) |
|
394 { |
|
395 stores[i] = RecordStore.openRecordStore(STORE_NAMES[i], false); |
|
396 } |
|
397 |
|
398 // close stores |
|
399 Utils.startTiming(); |
|
400 for (int i = 0; i < STORE_NAMES.length; i++) |
|
401 { |
|
402 stores[i].closeRecordStore(); |
|
403 } |
|
404 Utils.stopTiming(); |
|
405 score = Utils.getTime(Utils.getDiff()); |
|
406 |
|
407 } |
|
408 catch (RecordStoreException _ex) |
|
409 { |
|
410 System.out.println("RecordStoreException: " + _ex.toString()); |
|
411 } |
|
412 return score; |
|
413 } |
|
414 |
|
415 public String openCloseMultipleStores() |
|
416 { |
|
417 String score = ""; |
|
418 try |
|
419 { |
|
420 // open /close one store at a time |
|
421 Utils.startTiming(); |
|
422 for (int i = 0; i < STORE_NAMES.length; i++) |
|
423 { |
|
424 RecordStore r = RecordStore.openRecordStore(STORE_NAMES[i], false); |
|
425 r.closeRecordStore(); |
|
426 } |
|
427 Utils.stopTiming(); |
|
428 score = Utils.getTime(Utils.getDiff()); |
|
429 |
|
430 } |
|
431 catch (RecordStoreException _ex) |
|
432 { |
|
433 System.out.println("RecordStoreException: " + _ex.toString()); |
|
434 } |
|
435 return score; |
|
436 } |
|
437 |
333 } |
438 } |