src/hotspot/share/gc/shared/gcTraceTime.cpp
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 35061 hotspot/src/share/vm/gc/shared/gcTraceTime.cpp@be6025ebffea
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
     1
/*
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 27887
diff changeset
     2
 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
     4
 *
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
     7
 * published by the Free Software Foundation.
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
     8
 *
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    13
 * accompanied this code).
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    14
 *
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    18
 *
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    21
 * questions.
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    22
 *
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    23
 */
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    24
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    25
#include "precompiled.hpp"
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    26
#include "gc/shared/gcTraceTime.inline.hpp"
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    27
#include "logging/log.hpp"
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    28
#include "runtime/os.hpp"
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    29
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    30
GCTraceCPUTime::GCTraceCPUTime() :
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    31
  _active(log_is_enabled(Info, gc, cpu)),
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    32
  _starting_user_time(0.0),
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    33
  _starting_system_time(0.0),
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    34
  _starting_real_time(0.0)
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    35
{
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    36
  if (_active) {
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    37
    bool valid = os::getTimesSecs(&_starting_real_time,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    38
                               &_starting_user_time,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    39
                               &_starting_system_time);
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    40
    if (!valid) {
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    41
      log_warning(gc, cpu)("TraceCPUTime: os::getTimesSecs() returned invalid result");
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    42
      _active = false;
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    43
    }
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    44
  }
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    45
}
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    46
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    47
GCTraceCPUTime::~GCTraceCPUTime() {
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    48
  if (_active) {
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    49
    double real_time, user_time, system_time;
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    50
    bool valid = os::getTimesSecs(&real_time, &user_time, &system_time);
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    51
    if (valid) {
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    52
      log_info(gc, cpu)("User=%3.2fs Sys=%3.2fs Real=%3.2fs",
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    53
                        user_time - _starting_user_time,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    54
                        system_time - _starting_system_time,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    55
                        real_time - _starting_real_time);
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    56
    } else {
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    57
      log_warning(gc, cpu)("TraceCPUTime: os::getTimesSecs() returned invalid result");
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    58
    }
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    59
  }
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents:
diff changeset
    60
}