本文整理了Java中java.lang.management.ThreadMXBean.getCurrentThreadCpuTime()
方法的一些代码示例,展示了ThreadMXBean.getCurrentThreadCpuTime()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ThreadMXBean.getCurrentThreadCpuTime()
方法的具体详情如下:
包路径:java.lang.management.ThreadMXBean
类名称:ThreadMXBean
方法名:getCurrentThreadCpuTime
暂无
代码示例来源:origin: prestodb/presto
private static long currentThreadCpuTime()
{
return THREAD_MX_BEAN.getCurrentThreadCpuTime();
}
代码示例来源:origin: apache/incubator-druid
/**
* Returns the total CPU time for current thread.
* This method should be called after verifying that cpu time measurement for current thread is supported by JVM
*
* @return total CPU time for the current thread in nanoseconds.
*
* @throws UnsupportedOperationException if the Java virtual machine does not support CPU time measurement for
* the current thread.
*/
public static long getCurrentThreadCpuTime()
{
return THREAD_MX_BEAN.getCurrentThreadCpuTime();
}
}
代码示例来源:origin: kevin-wayne/algs4
/**
* Returns the elapsed CPU time (in seconds) since the stopwatch was created.
*
* @return elapsed CPU time (in seconds) since the stopwatch was created
*/
public double elapsedTime() {
long now = threadTimer.getCurrentThreadCpuTime();
return (now - start) / NANOSECONDS_PER_SECOND;
}
代码示例来源:origin: scouter-project/scouter
public static long getCurrentThreadCPU() {
if (threadmx == null)
return 0;
try {
return threadmx.getCurrentThreadCpuTime() / 1000000L;
} catch (Throwable t) {
return 0;
}
}
public static long getCurrentThreadCPUnano() {
代码示例来源:origin: scouter-project/scouter
public static long getCurrentThreadCPUnano() {
if (threadmx == null)
return 0;
try {
return threadmx.getCurrentThreadCpuTime() ;
} catch (Throwable t) {
return 0;
}
}
public static long getCurrentThreadAllocBytes(boolean ok) {
代码示例来源:origin: scouter-project/scouter
public static long getCurrentThreadCPUnano() {
if (threadmx == null)
return 0;
try {
return threadmx.getCurrentThreadCpuTime() ;
} catch (Throwable t) {
return 0;
}
}
public static long getCurrentThreadAllocBytes(boolean ok) {
代码示例来源:origin: scouter-project/scouter
public static long getCurrentThreadCPU() {
if (threadmx == null)
return 0;
try {
return threadmx.getCurrentThreadCpuTime() / 1000000L;
} catch (Throwable t) {
return 0;
}
}
public static long getCurrentThreadCPUnano() {
代码示例来源:origin: scouter-project/scouter
public static long getCurrentThreadCPU() {
if (threadmx == null)
return 0;
try {
return threadmx.getCurrentThreadCpuTime() / 1000000L;
} catch (Throwable t) {
return 0;
}
}
public static long getCurrentThreadCPUnano() {
代码示例来源:origin: scouter-project/scouter
public static long getCurrentThreadCPUnano() {
if (threadmx == null)
return 0;
try {
return threadmx.getCurrentThreadCpuTime() ;
} catch (Throwable t) {
return 0;
}
}
public static long getCurrentThreadAllocBytes(boolean ok) {
代码示例来源:origin: scouter-project/scouter
public static long getCurrentThreadCPU() {
if (threadmx == null)
return 0;
try {
return threadmx.getCurrentThreadCpuTime() / 1000000L;
} catch (Throwable t) {
return 0;
}
}
public static long getCurrentThreadCPUnano() {
代码示例来源:origin: scouter-project/scouter
public static long getCurrentThreadCPU() {
if (threadmx == null)
return 0;
try {
return threadmx.getCurrentThreadCpuTime() / 1000000L;
} catch (Throwable t) {
return 0;
}
}
public static long getCurrentThreadCPUnano() {
代码示例来源:origin: scouter-project/scouter
public static long getCurrentThreadCPUnano() {
if (threadmx == null)
return 0;
try {
return threadmx.getCurrentThreadCpuTime() ;
} catch (Throwable t) {
return 0;
}
}
public static long getCurrentThreadAllocBytes(boolean ok) {
代码示例来源:origin: scouter-project/scouter
public static long getCurrentThreadCPUnano() {
if (threadmx == null)
return 0;
try {
return threadmx.getCurrentThreadCpuTime() ;
} catch (Throwable t) {
return 0;
}
}
public static long getCurrentThreadAllocBytes(boolean ok) {
代码示例来源:origin: stagemonitor/stagemonitor
public static long getCpuTime() {
return isCurrentThreadCpuTimeSupported ? threadMXBean.getCurrentThreadCpuTime() : 0L;
}
}
代码示例来源:origin: kevin-wayne/algs4
/**
* Initializes a new stopwatch.
*/
public StopwatchCPU() {
threadTimer = ManagementFactory.getThreadMXBean();
start = threadTimer.getCurrentThreadCpuTime();
}
代码示例来源:origin: prestodb/presto
private static long currentThreadCpuTime()
{
return THREAD_MX_BEAN.getCurrentThreadCpuTime();
}
代码示例来源:origin: prestodb/presto
@Override
public void commit()
{
try {
rcFileWriter.close();
}
catch (IOException | UncheckedIOException e) {
try {
rollbackAction.call();
}
catch (Exception ignored) {
// ignore
}
throw new PrestoException(HIVE_WRITER_CLOSE_ERROR, "Error committing write to Hive", e);
}
if (validationInputFactory.isPresent()) {
try {
try (RcFileDataSource input = validationInputFactory.get().get()) {
long startThreadCpuTime = THREAD_MX_BEAN.getCurrentThreadCpuTime();
rcFileWriter.validate(input);
validationCpuNanos += THREAD_MX_BEAN.getCurrentThreadCpuTime() - startThreadCpuTime;
}
}
catch (IOException | UncheckedIOException e) {
throw new PrestoException(HIVE_WRITE_VALIDATION_FAILED, e);
}
}
}
代码示例来源:origin: prestodb/presto
@Override
public void commit()
{
try {
orcWriter.close();
}
catch (IOException | UncheckedIOException e) {
try {
rollbackAction.call();
}
catch (Exception ignored) {
// ignore
}
throw new PrestoException(HIVE_WRITER_CLOSE_ERROR, "Error committing write to Hive", e);
}
if (validationInputFactory.isPresent()) {
try {
try (OrcDataSource input = validationInputFactory.get().get()) {
long startThreadCpuTime = THREAD_MX_BEAN.getCurrentThreadCpuTime();
orcWriter.validate(input);
validationCpuNanos += THREAD_MX_BEAN.getCurrentThreadCpuTime() - startThreadCpuTime;
}
}
catch (IOException | UncheckedIOException e) {
throw new PrestoException(HIVE_WRITE_VALIDATION_FAILED, e);
}
}
}
代码示例来源:origin: btraceio/btrace
static long getCurrentThreadCpuTime() {
initThreadMBean();
threadMBean.setThreadCpuTimeEnabled(true);
return threadMBean.getCurrentThreadCpuTime();
}
代码示例来源:origin: gocd/gocd
public long getSystemTime() {
ThreadMXBean bean = ManagementFactory.getThreadMXBean();
return bean.isCurrentThreadCpuTimeSupported() ?
(bean.getCurrentThreadCpuTime() - bean.getCurrentThreadUserTime()) : 0L;
}
内容来源于网络,如有侵权,请联系作者删除!