Tue, 09 Oct 2012 10:09:34 -0700
7197424: update copyright year to match last edit in jdk8 hotspot repository
Summary: Update copyright year to 2012 for relevant files
Reviewed-by: dholmes, coleenp
duke@435 | 1 | /* |
stefank@2314 | 2 | * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_RUNTIME_TIMER_HPP |
stefank@2314 | 26 | #define SHARE_VM_RUNTIME_TIMER_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "utilities/globalDefinitions.hpp" |
stefank@2314 | 29 | |
duke@435 | 30 | // Timers for simple measurement. |
duke@435 | 31 | |
duke@435 | 32 | class elapsedTimer VALUE_OBJ_CLASS_SPEC { |
duke@435 | 33 | friend class VMStructs; |
duke@435 | 34 | private: |
duke@435 | 35 | jlong _counter; |
duke@435 | 36 | jlong _start_counter; |
duke@435 | 37 | bool _active; |
duke@435 | 38 | public: |
duke@435 | 39 | elapsedTimer() { _active = false; reset(); } |
duke@435 | 40 | void add(elapsedTimer t); |
duke@435 | 41 | void start(); |
duke@435 | 42 | void stop(); |
duke@435 | 43 | void reset() { _counter = 0; } |
duke@435 | 44 | double seconds() const; |
duke@435 | 45 | jlong milliseconds() const; |
duke@435 | 46 | jlong ticks() const { return _counter; } |
duke@435 | 47 | jlong active_ticks() const; |
duke@435 | 48 | bool is_active() const { return _active; } |
duke@435 | 49 | }; |
duke@435 | 50 | |
duke@435 | 51 | // TimeStamp is used for recording when an event took place. |
duke@435 | 52 | class TimeStamp VALUE_OBJ_CLASS_SPEC { |
duke@435 | 53 | private: |
duke@435 | 54 | jlong _counter; |
duke@435 | 55 | public: |
duke@435 | 56 | TimeStamp() { _counter = 0; } |
duke@435 | 57 | void clear() { _counter = 0; } |
duke@435 | 58 | // has the timestamp been updated since being created or cleared? |
duke@435 | 59 | bool is_updated() const { return _counter != 0; } |
duke@435 | 60 | // update to current elapsed time |
duke@435 | 61 | void update(); |
duke@435 | 62 | // update to given elapsed time |
duke@435 | 63 | void update_to(jlong ticks); |
duke@435 | 64 | // returns seconds since updated |
duke@435 | 65 | // (must not be in a cleared state: must have been previously updated) |
duke@435 | 66 | double seconds() const; |
duke@435 | 67 | jlong milliseconds() const; |
duke@435 | 68 | // ticks elapsed between VM start and last update |
duke@435 | 69 | jlong ticks() const { return _counter; } |
duke@435 | 70 | // ticks elapsed since last update |
duke@435 | 71 | jlong ticks_since_update() const; |
duke@435 | 72 | }; |
duke@435 | 73 | |
duke@435 | 74 | // TraceTime is used for tracing the execution time of a block |
duke@435 | 75 | // Usage: |
duke@435 | 76 | // { TraceTime t("block time") |
duke@435 | 77 | // some_code(); |
duke@435 | 78 | // } |
duke@435 | 79 | // |
duke@435 | 80 | |
duke@435 | 81 | class TraceTime: public StackObj { |
duke@435 | 82 | private: |
duke@435 | 83 | bool _active; // do timing |
duke@435 | 84 | bool _verbose; // report every timing |
duke@435 | 85 | bool _print_cr; // add a CR to the end of the timer report |
duke@435 | 86 | elapsedTimer _t; // timer |
duke@435 | 87 | elapsedTimer* _accum; // accumulator |
duke@435 | 88 | outputStream* _logfile; // output log file |
duke@435 | 89 | public: |
duke@435 | 90 | // Constuctors |
duke@435 | 91 | TraceTime(const char* title, |
duke@435 | 92 | bool doit = true, |
duke@435 | 93 | bool print_cr = true, |
duke@435 | 94 | outputStream *logfile = NULL); |
duke@435 | 95 | TraceTime(const char* title, |
duke@435 | 96 | elapsedTimer* accumulator, |
duke@435 | 97 | bool doit = true, |
duke@435 | 98 | bool verbose = false, |
duke@435 | 99 | outputStream *logfile = NULL ); |
duke@435 | 100 | ~TraceTime(); |
duke@435 | 101 | |
duke@435 | 102 | // Accessors |
duke@435 | 103 | void set_verbose(bool verbose) { _verbose = verbose; } |
duke@435 | 104 | bool verbose() const { return _verbose; } |
duke@435 | 105 | |
duke@435 | 106 | // Activation |
duke@435 | 107 | void suspend() { if (_active) _t.stop(); } |
duke@435 | 108 | void resume() { if (_active) _t.start(); } |
duke@435 | 109 | }; |
duke@435 | 110 | |
duke@435 | 111 | class TraceCPUTime: public StackObj { |
duke@435 | 112 | private: |
duke@435 | 113 | bool _active; // true if times will be measured and printed |
duke@435 | 114 | bool _print_cr; // if true print carriage return at end |
duke@435 | 115 | double _starting_user_time; // user time at start of measurement |
duke@435 | 116 | double _starting_system_time; // system time at start of measurement |
duke@435 | 117 | double _starting_real_time; // real time at start of measurement |
duke@435 | 118 | outputStream* _logfile; // output is printed to this stream |
duke@435 | 119 | bool _error; // true if an error occurred, turns off output |
duke@435 | 120 | |
duke@435 | 121 | public: |
duke@435 | 122 | TraceCPUTime(bool doit = true, |
duke@435 | 123 | bool print_cr = true, |
duke@435 | 124 | outputStream *logfile = NULL); |
duke@435 | 125 | ~TraceCPUTime(); |
duke@435 | 126 | }; |
stefank@2314 | 127 | |
stefank@2314 | 128 | #endif // SHARE_VM_RUNTIME_TIMER_HPP |