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 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 uuid = UuidGenerator.generate(this);
30 }
31 long time = System.currentTimeMillis() - startTime;
32 double timePerUuidGenaration = time / (double) m_numberOfInvocations;
33 System.out.println("timePerUuidGenaration = " + timePerUuidGenaration);
34 }
35
36 public static void main(String[] args) {
37 TestRunner.run(suite());
38 }
39
40 public static Test suite() {
41 return new TestSuite(UUIDTest.class);
42 }
43 }