public abstract class AbstractRecorder extends Object implements Recorder
限定符和类型 | 类和说明 |
---|---|
class |
AbstractRecorder.Collect |
static interface |
AbstractRecorder.Collector |
static interface |
AbstractRecorder.EveryPattern<T extends SpeedEvent>
记录器接口,添加函数式编程
|
static interface |
AbstractRecorder.StatisticPattern<V>
统计接口,添加了函数式编程支持
|
限定符和类型 | 字段和说明 |
---|---|
protected AbstractRecorder.EveryPattern |
everyPattern |
protected String |
name |
protected State |
state |
protected AbstractRecorder.StatisticPattern |
statisticPattern |
构造器和说明 |
---|
AbstractRecorder(String name)
构造方法
|
限定符和类型 | 方法和说明 |
---|---|
AbstractRecorder.Collect |
collect(AbstractRecorder.Collector collector) |
Recorder |
end()
结束一次记录,在这里进行一次记录的输出,同时将耗时的值保存到列表用于统计
进行状态判断,是否已经停止测试
|
AbstractRecorder.EveryPattern |
getEveryPattern()
取得记录接口的实现
|
String |
getName()
取得记录器名称
|
AbstractRecorder.StatisticPattern |
getStatisticPattern()
返回统计接口的实现
|
protected abstract void |
onEnd()
实际启动时实现记录结束时间等操作,由子类实现
|
protected abstract void |
onReset()
重置清空记速器内容
|
protected abstract void |
onStart()
实际启动时实现记录开始时间,由子类实现
|
protected abstract void |
onStatistics()
执行统计操作
|
protected abstract void |
onStop()
执行停止计时器的操作
|
Recorder |
reset()
重置记速器,重置前执行一次统计
|
protected abstract AbstractRecorder.EveryPattern |
setEveryPattern()
向记录器中添加默认的记录接口
|
Recorder |
setEveryPattern(AbstractRecorder.EveryPattern everyPattern)
设置记录器的记录接口
|
protected abstract AbstractRecorder.StatisticPattern |
setStatisticPattern()
向记录器中添加默认的统计接口
|
Recorder |
setStatisticPattern(AbstractRecorder.StatisticPattern statisticPattern)
设置记录器的统计接口
|
Recorder |
start()
开始一次记录,在这里应该创建一个SpeedEvent实体对象,传入开始时间;
进行状态判断,从而知道是否能够正常的开始测试;
start和end希望可以多线程进行操作,所以在这里不能实现状态控制,只能由子类来实现。
|
Recorder |
statistics()
执行统计,执行统计时将状态设置为统计中,此时不允许进行操作记速器的行为
|
void |
stop()
停止计时,停止前进行一次统计,执行后状态为STOP
|
protected String name
protected AbstractRecorder.EveryPattern everyPattern
protected AbstractRecorder.StatisticPattern statisticPattern
protected volatile State state
public AbstractRecorder(String name)
name
- 记录器名称protected abstract AbstractRecorder.EveryPattern setEveryPattern()
public Recorder start()
protected abstract void onStart()
public Recorder end()
protected abstract void onEnd()
protected abstract void onReset()
protected abstract void onStop()
public Recorder statistics()
statistics
在接口中 Recorder
protected abstract void onStatistics()
protected abstract AbstractRecorder.StatisticPattern setStatisticPattern()
public Recorder setEveryPattern(AbstractRecorder.EveryPattern everyPattern)
everyPattern
- 记录接口public Recorder setStatisticPattern(AbstractRecorder.StatisticPattern statisticPattern)
statisticPattern
- 统计接口public AbstractRecorder.EveryPattern getEveryPattern()
public AbstractRecorder.StatisticPattern getStatisticPattern()
public AbstractRecorder.Collect collect(AbstractRecorder.Collector collector)
Copyright © 2020. All rights reserved.