/hazelcast/src/test/java/com/hazelcast/core/IListPerformance.java

https://bitbucket.org/gabral6_gmailcom/hazelcast · Java · 69 lines · 46 code · 8 blank · 15 comment · 5 complexity · 574f1e052c13e14967ef652dc3f636b1 MD5 · raw file

  1. /*
  2. * Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.hazelcast.core;
  17. import org.junit.After;
  18. import org.junit.Test;
  19. import org.junit.runner.RunWith;
  20. import static junit.framework.Assert.assertTrue;
  21. @RunWith(com.hazelcast.util.RandomBlockJUnit4ClassRunner.class)
  22. public class IListPerformance extends PerformanceTest {
  23. private IList<Integer> list = Hazelcast.getList("IListPerformance");
  24. @After
  25. public void clear() {
  26. t.stop();
  27. t.printResult();
  28. list.clear();
  29. assertTrue(list.isEmpty());
  30. }
  31. @Test
  32. public void testListAdd() {
  33. String test = "testListAdd";
  34. t = new PerformanceTimer(test, ops);
  35. for (int i = 0; i < ops; ++i) {
  36. list.add(i);
  37. }
  38. }
  39. @Test
  40. public void testListContains() {
  41. String test = "testListContains";
  42. for (int i = 0; i < ops; ++i) {
  43. list.add(i);
  44. }
  45. t = new PerformanceTimer(test, ops);
  46. for (int i = 0; i < ops; ++i) {
  47. list.contains(i);
  48. }
  49. }
  50. @Test
  51. public void testListIterator() {
  52. String test = "testListIterator";
  53. for (int i = 0; i < ops; ++i) {
  54. list.add(i);
  55. }
  56. t = new PerformanceTimer(test, ops);
  57. for (Integer aList : list) {
  58. int a = aList;
  59. }
  60. }
  61. }