summaryrefslogtreecommitdiff
path: root/icu4j/perf-tests/src/com/ibm/icu/dev/test/perf/ServiceObjectCreationPerf.java
blob: 0db4ad18483e9eb9e343acc65564a0a0c11b15f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
 *******************************************************************************
 * Copyright (C) 2014, International Business Machines Corporation and         *
 * others. All Rights Reserved.                                                *
 *******************************************************************************
 */
package com.ibm.icu.dev.test.perf;


/**
 * ICU service object creation performance test cases
 */
public class ServiceObjectCreationPerf extends PerfTest {
    private static final long DEF_COUNT = 1000L;

    public static void main(String... args) throws Exception {
        new ServiceObjectCreationPerf().run(args);
    }

    PerfTest.Function TestCalendarJava() {
        return new PerfTest.Function() {
            private long n = DEF_COUNT;
            public void call() {
                for (long i = 0; i < n; i++) {
                    @SuppressWarnings("unused")
                    java.util.Calendar cal = java.util.Calendar.getInstance();
                }
            }
            public long getOperationsPerIteration() {
                return n;
            }
        };
    }

    PerfTest.Function TestCalendarICU() {
        return new PerfTest.Function() {
            private long n = DEF_COUNT;
            public void call() {
                for (long i = 0; i < n; i++) {
                    @SuppressWarnings("unused")
                    com.ibm.icu.util.Calendar cal = com.ibm.icu.util.Calendar.getInstance();
                }
            }
            public long getOperationsPerIteration() {
                return n;
            }
        };
    }

    PerfTest.Function TestTimeZoneJava() {
        return new PerfTest.Function() {
            private long n = DEF_COUNT;
            public void call() {
                for (long i = 0; i < n; i++) {
                    @SuppressWarnings("unused")
                    java.util.TimeZone tz = java.util.TimeZone.getDefault();
                }
            }
            public long getOperationsPerIteration() {
                return n;
            }
        };
    }

    PerfTest.Function TestTimeZoneICU() {
        return new PerfTest.Function() {
            private long n = DEF_COUNT;
            public void call() {
                for (long i = 0; i < n; i++) {
                    @SuppressWarnings("unused")
                    com.ibm.icu.util.TimeZone tz = com.ibm.icu.util.TimeZone.getDefault();
                }
            }
            public long getOperationsPerIteration() {
                return n;
            }
        };
    }

}