Stats Helper

A stats helper

License

License

The Artistic License 2.0
Categories

Categories

Ant Build Tools
GroupId

GroupId

com.github.phantomthief
ArtifactId

ArtifactId

stats-helper
Last Version

Last Version

0.2.2
Release Date

Release Date

Type

Type

jar
Description

Description

Stats Helper
A stats helper
Project URL

Project URL

https://github.com/PhantomThief/stats-helper
Source Code Management

Source Code Management

https://github.com/PhantomThief/stats-helper.git

Download stats-helper

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.phantomthief/stats-helper/ -->
<dependency>
    <groupId>com.github.phantomthief</groupId>
    <artifactId>stats-helper</artifactId>
    <version>0.2.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.phantomthief/stats-helper/
implementation 'com.github.phantomthief:stats-helper:0.2.2'
// https://jarcasting.com/artifacts/com.github.phantomthief/stats-helper/
implementation ("com.github.phantomthief:stats-helper:0.2.2")
'com.github.phantomthief:stats-helper:jar:0.2.2'
<dependency org="com.github.phantomthief" name="stats-helper" rev="0.2.2">
  <artifact name="stats-helper" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.phantomthief', module='stats-helper', version='0.2.2')
)
libraryDependencies += "com.github.phantomthief" % "stats-helper" % "0.2.2"
[com.github.phantomthief/stats-helper "0.2.2"]

Dependencies

compile (4)

Group / Artifact Type Version
com.google.guava : guava jar 19.0
joda-time : joda-time jar 2.9.3
org.slf4j : slf4j-api jar 1.7.14
com.github.phantomthief : more-lambdas jar 0.1.8

test (1)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.0.2

Project Modules

There are no modules declared in this project.

stats-helper

统计最近一段时间的数据

  • 支持自定义的时间间隔(默认10秒、1分钟和1小时)
  • 自定义统计的数据类型
  • 目前只支持jdk1.8

使用

<dependency>
    <groupId>com.github.phantomthief</groupId>
    <artifactId>stats-helper</artifactId>
    <version>0.2.0-SNAPSHOT</version>
</dependency>
// 声明
SimpleDurationStats<SimpleCounter> durationStats = SimpleDurationStats.newBuilder().build();
        
// 执行统计
durationStats.stat(SimpleCounter.stats(10));

// 获取统计数据,key是时间间隔
Map<Long, SimpleCounter> stats = durationStats.getStats();

// 友好输出
DurationStatsUtils.format(stats, Object::toString);
    

注意事项

  • 定制的Counter必须实现com.github.phantomthief.stats.n.counter.Duration接口
  • 可以使用MultiDurationStats实现一个不同key的统计集合

Versions

Version
0.2.2
0.2.1
0.2.0
0.1.0