tyrg-common

�������������

License

License

Categories

Categories

Security
GroupId

GroupId

cn.tyrg
ArtifactId

ArtifactId

base-common-security
Last Version

Last Version

2.7.2
Release Date

Release Date

Type

Type

jar
Description

Description

tyrg-common
�������������
Source Code Management

Source Code Management

https://github.com/Bpazy/Id

Download base-common-security

How to add to project

<!-- https://jarcasting.com/artifacts/cn.tyrg/base-common-security/ -->
<dependency>
    <groupId>cn.tyrg</groupId>
    <artifactId>base-common-security</artifactId>
    <version>2.7.2</version>
</dependency>
// https://jarcasting.com/artifacts/cn.tyrg/base-common-security/
implementation 'cn.tyrg:base-common-security:2.7.2'
// https://jarcasting.com/artifacts/cn.tyrg/base-common-security/
implementation ("cn.tyrg:base-common-security:2.7.2")
'cn.tyrg:base-common-security:jar:2.7.2'
<dependency org="cn.tyrg" name="base-common-security" rev="2.7.2">
  <artifact name="base-common-security" type="jar" />
</dependency>
@Grapes(
@Grab(group='cn.tyrg', module='base-common-security', version='2.7.2')
)
libraryDependencies += "cn.tyrg" % "base-common-security" % "2.7.2"
[cn.tyrg/base-common-security "2.7.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Id

Maven Build Status codecov

分布式id生成,整体随时间递增。

最大支持1024个节点,每个节点每毫秒生成ID上限为4096个。

Usage

Add maven denpendency:

<dependency>
    <groupId>com.github.bpazy</groupId>
    <artifactId>id</artifactId>
    <version>{version}</version>
</dependency>

And then go:

public class Main {
    public static void main(String[] args) {
        System.out.println(Id.next());
    }
}

Benchmark

# JMH version: 1.19
# VM version: JDK 1.8.0_161, VM 25.161-b12
# VM invoker: C:\Program Files\Java\jdk1.8.0_161\jre\bin\java.exe
# VM options: -javaagent:D:\Program Files\JetBrains\ToolBox\apps\IDEA-U\ch-0\183.4588.61\lib\idea_rt.jar=4143:D:\Program Files\JetBrains\ToolBox\apps\IDEA-U\ch-0\183.4588.61\bin -Dfile.encoding=UTF-8
# Warmup: 1 iterations, 1 s each
# Measurement: 5 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: com.github.bpazy.idbenchmark.Main.idBenchmark

# Run progress: 0.00% complete, ETA 00:00:18
# Fork: 1 of 3
# Warmup Iteration   1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2024509.850 ops/s
Iteration   1: 4096581.066 ops/s
Iteration   2: 4097063.699 ops/s
Iteration   3: 4097580.963 ops/s
Iteration   4: 4099701.559 ops/s
Iteration   5: 4098296.272 ops/s

# Run progress: 33.33% complete, ETA 00:00:13
# Fork: 2 of 3
# Warmup Iteration   1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2328552.612 ops/s
Iteration   1: 4079420.331 ops/s
Iteration   2: 4023722.559 ops/s
Iteration   3: 4098380.166 ops/s
Iteration   4: 4101047.384 ops/s
Iteration   5: 4097627.770 ops/s

# Run progress: 66.67% complete, ETA 00:00:06
# Fork: 3 of 3
# Warmup Iteration   1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2343553.817 ops/s
Iteration   1: 4096149.582 ops/s
Iteration   2: 4096496.911 ops/s
Iteration   3: 4069862.862 ops/s
Iteration   4: 4090216.938 ops/s
Iteration   5: 4069581.830 ops/s


Result "com.github.bpazy.idbenchmark.Main.idBenchmark":
  4087448.659 ±(99.9%) 21897.203 ops/s [Average]
  (min, avg, max) = (4023722.559, 4087448.659, 4101047.384), stdev = 20482.657
  CI (99.9%): [4065551.457, 4109345.862] (assumes normal distribution)


# Run complete. Total time: 00:00:20

Benchmark          Mode  Cnt        Score       Error  Units
Main.idBenchmark  thrpt   15  4087448.659 ± 21897.203  ops/s

reference by https://segmentfault.com/a/1190000011282426

Versions

Version
2.7.2
1.0.0