public class ConcurrentMeasureRunner extends AbstractMeasureRunner
| 限定符和类型 | 字段和说明 |
|---|---|
protected Set<CompletableFuture<Void>> |
runningFutures
用于存放正在运行中的 Future 线程,便于在手动"停止"运行时,能取消正在执行中的任务.
|
canceled, completed, eachMeasures, endNanoTime, executorService, failure, startNanoTime, success| 构造器和说明 |
|---|
ConcurrentMeasureRunner()
构造方法.
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
loopMeasure(int runs,
boolean printErrorLog,
Runnable runnable)
单个线程的循环批量执行测量.
|
MeasureResult |
run(Options options,
Runnable runnable)
执行 runnable 方法,并将执行结果的耗时纳秒(ns)值存入结果对象中.
|
void |
stop()
停止相关的运行测量任务.
|
getCosts, getFailure, getMeasureResult, getSuccess, getTotal, isCancelled, isCompleted, setEndNanoTimeIfEmptyclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetEndNanoTime, getStartNanoTimeprotected final Set<CompletableFuture<Void>> runningFutures
public MeasureResult run(Options options, Runnable runnable)
options - 运行的配置选项实例runnable - 可运行实例protected void loopMeasure(int runs,
boolean printErrorLog,
Runnable runnable)
runs - 批量运行次数printErrorLog - 是否打印输出错误日志runnable - 可执行实例public void stop()
注意:如果任务未完成,则立即停止线程池,但是还不能停止正在运行中的若干任务线程, 暂时还没想到一个更好的、高性能的停止所有运行中的任务的方法.
Copyright © 2020. All rights reserved.