KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > UUIDTest


1 /**************************************************************************************
2  * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
3  * http://aspectwerkz.codehaus.org *
4  * ---------------------------------------------------------------------------------- *
5  * The software in this package is published under the terms of the LGPL license *
6  * a copy of which has been included with this distribution in the license.txt file. *
7  **************************************************************************************/

8 package test;
9
10 import junit.framework.Test;
11 import junit.framework.TestCase;
12 import junit.framework.TestSuite;
13 import junit.textui.TestRunner;
14 import org.codehaus.aspectwerkz.util.UuidGenerator;
15
16 /**
17  * @author <a HREF="mailto:jboner@codehaus.org">Jonas BonŽr </a>
18  */

19 public class UUIDTest extends TestCase {
20     private int m_numberOfInvocations = 1000000;
21
22     public UUIDTest(String JavaDoc name) {
23         super(name);
24     }
25
26     public void testPerformance() {
27         long startTime = System.currentTimeMillis();
28         for (int i = 0; i < m_numberOfInvocations; i++) {
29             String JavaDoc uuid = UuidGenerator.generate(this);
30         }
31         long time = System.currentTimeMillis() - startTime;
32         double timePerUuidGenaration = time / (double) m_numberOfInvocations;
33     }
34
35     public static void main(String JavaDoc[] args) {
36         TestRunner.run(suite());
37     }
38
39     public static Test suite() {
40         return new TestSuite(UUIDTest.class);
41     }
42 }
Popular Tags