test/jdk/jdk/jfr/jvm/TestFormatDuration.java
author cito
Thu, 28 Nov 2019 18:30:18 +0100
changeset 59312 43eee1237934
permissions -rw-r--r--
8232594: Make the output of the JFR command duration more user friendly Reviewed-by: egahlin, cito Contributed-by: chiroito107@gmail.com, erik.gahlin@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
59312
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
     1
/*
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
     2
 * Copyright (c) 2019, 2019, Oracle and/or its affiliates. All rights reserved.
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
     4
 *
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    10
 *
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    15
 * accompanied this code).
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    16
 *
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    20
 *
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    23
 * questions.
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    24
 */
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    25
package jdk.jfr.jvm;
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    26
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    27
import jdk.jfr.internal.Utils;
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    28
import jdk.test.lib.Asserts;
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    29
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    30
import java.time.Duration;
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    31
import java.util.Locale;
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    32
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    33
/**
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    34
 * @test
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    35
 * @key jfr
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    36
 * @requires vm.hasJFR
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    37
 * @library /test/lib
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    38
 * @modules jdk.jfr/jdk.jfr.internal
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    39
 * @run main/othervm jdk.jfr.jvm.TestFormatDuration
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    40
 */
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    41
public class TestFormatDuration {
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    42
    public static void main(String[] args) throws Exception{
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    43
        Locale.setDefault(Locale.US);
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    44
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    45
        // Nanoseconds
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    46
        assertDuration("0 ns   ", "0 s");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    47
        assertDuration("1 ns   ", "0.000001 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    48
        assertDuration("10 ns  ", "0.000010 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    49
        assertDuration("100 ns ", "0.000100 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    50
        assertDuration("999 ns ", "0.000999 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    51
        assertDuration("1000 ns", "0.00100 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    52
        assertDuration("1004 ns", "0.00100 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    53
        assertDuration("1005 ns", "0.00101 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    54
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    55
        // 10 us
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    56
        assertDuration("9 us 994 ns", "0.00999 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    57
        assertDuration("9 us 995 ns", "0.0100 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    58
        assertDuration("10 us      ", "0.0100 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    59
        assertDuration("10 us 49 ns", "0.0100 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    60
        assertDuration("10 us 50 ns", "0.0101 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    61
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    62
        // 100 us
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    63
        assertDuration("99 us 949 ns ", "0.0999 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    64
        assertDuration("99 us 950 ns ", "0.100 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    65
        assertDuration("100 us       ", "0.100 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    66
        assertDuration("100 us 499 ns", "0.100 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    67
        assertDuration("100 us 500 ns", "0.101 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    68
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    69
        // 1 ms
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    70
        assertDuration("999 us 499 ns       ", "0.999 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    71
        assertDuration("999 us 500 ns       ", "1.00 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    72
        assertDuration("1 ms                ", "1.00 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    73
        assertDuration("1 ms 4 us 999 ns    ", "1.00 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    74
        assertDuration("1 ms 5 us", "1.01 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    75
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    76
        // 10 ms
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    77
        assertDuration("9 ms 994 us 999 ns", "9.99 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    78
        assertDuration("9 ms 995 us       ", "10.0 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    79
        assertDuration("10 ms             ", "10.0 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    80
        assertDuration("10 ms 49 us 999 ns", "10.0 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    81
        assertDuration("10 ms 50 us 999 ns", "10.1 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    82
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    83
        // 100 ms
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    84
        assertDuration("99 ms 949 us 999 ns ", "99.9 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    85
        assertDuration("99 ms 950 us 000 ns ", "100 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    86
        assertDuration("100 ms              ", "100 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    87
        assertDuration("100 ms 499 us 999 ns", "100 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    88
        assertDuration("100 ms 500 us       ", "101 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    89
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    90
        // 1 second
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    91
        assertDuration("999 ms 499 us 999 ns  ", "999 ms");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    92
        assertDuration("999 ms 500 us         ", "1.00 s");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    93
        assertDuration("1 s                   ", "1.00 s");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    94
        assertDuration("1 s 4 ms 999 us 999 ns", "1.00 s");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    95
        assertDuration("1 s 5 ms              ", "1.01 s");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    96
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    97
        // 10 seconds
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    98
        assertDuration("9 s 994 ms 999 us 999 ns ", "9.99 s");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
    99
        assertDuration("9 s 995 ms               ", "10.0 s");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   100
        assertDuration("10 s                     ", "10.0 s");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   101
        assertDuration("10 s 049 ms 999 us 999 ns", "10.0 s");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   102
        assertDuration("10 s 050 ms              ", "10.1 s");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   103
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   104
        // 1 minute
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   105
        assertDuration("59 s 949 ms 999 us 999 ns", "59.9 s");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   106
        assertDuration("59 s 950 ms              ", "1 m 0 s");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   107
        assertDuration("1 m 0 s                  ", "1 m 0 s");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   108
        assertDuration("60 s 499 ms 999 us 999 ns", "1 m 0 s");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   109
        assertDuration("60 s 500 ms              ", "1 m 1 s");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   110
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   111
        // 10 minutes
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   112
        assertDuration("10 m 0 s", "10 m 0 s");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   113
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   114
        // 1 hour
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   115
        assertDuration("59 m 59 s 499 ms 999 us 999 ns", "59 m 59 s");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   116
        assertDuration("59 m 59 s 500 ms              ", "1 h 0 m");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   117
        assertDuration("1 h 0 m                       ", "1 h 0 m");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   118
        assertDuration("1 h 29 s 999 ms 999 us 999 ns ", "1 h 0 m");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   119
        assertDuration("1 h 30 s                      ", "1 h 1 m");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   120
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   121
        // 1 day
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   122
        assertDuration("23 h 59 m 29 s 999 ms 999 us 999 ns", "23 h 59 m");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   123
        assertDuration("23 h 59 m 30 s                     ", "1 d 0 h");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   124
        assertDuration("1 d 0 h                            ", "1 d 0 h");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   125
        assertDuration("1 d 29 m 59 s 999 ms 999 us 999 ns ", "1 d 0 h");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   126
        assertDuration("1 d 30 m                           ", "1 d 1 h");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   127
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   128
        // 100 days
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   129
        assertDuration("100 d 13 h", "100 d 13 h");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   130
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   131
        // 1000 days
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   132
        assertDuration("1000 d 13 h", "1000 d 13 h");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   133
    }
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   134
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   135
    private static void assertDuration(String value, String expected) throws Exception {
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   136
        long nanos = parse(value);
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   137
        System.out.println(value + " == " + expected + " ? (" + nanos + " ns) ");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   138
        Asserts.assertEquals(Utils.formatDuration(Duration.ofNanos(nanos)), expected);
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   139
        if (nanos != 0) {
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   140
            Asserts.assertEquals(Utils.formatDuration(Duration.ofNanos(-nanos)), "-" + expected);
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   141
        }
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   142
    }
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   143
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   144
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   145
    private static long parse(String duration) throws Exception {
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   146
        String[] t = duration.trim().split(" ");
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   147
        long nanos = 0;
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   148
        for (int i = 0; i < t.length - 1; i += 2) {
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   149
            nanos += Long.parseLong(t[i]) * parseUnit(t[i + 1]);
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   150
        }
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   151
        return nanos;
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   152
    }
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   153
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   154
    private static long parseUnit(String unit) throws Exception {
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   155
        switch (unit) {
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   156
            case "ns":
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   157
                return 1L;
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   158
            case "us":
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   159
                return 1_000L;
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   160
            case "ms":
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   161
                return 1_000_000L;
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   162
            case "s":
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   163
                return 1_000_000_000L;
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   164
            case "m":
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   165
                return 60 * 1_000_000_000L;
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   166
            case "h":
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   167
                return 3600 * 1_000_000_000L;
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   168
            case "d":
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   169
                return 24 * 3600 * 1_000_000_000L;
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   170
        }
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   171
        throw new Exception("Test error. Unknown unit " + unit);
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   172
    }
43eee1237934 8232594: Make the output of the JFR command duration more user friendly
cito
parents:
diff changeset
   173
}