GithubHelp home page GithubHelp logo

bad-show / zutil Goto Github PK

View Code? Open in Web Editor NEW

This project forked from duanluan/zutil

0.0 0.0 0.0 6.26 MB

追求更快更全的 Java 工具类

Home Page: https://duanluan.github.io/ZUtil/

License: Apache License 2.0

Java 100.00%

zutil's Introduction

ZUtil

star

追求更快更全的 Java 工具类。

工具类使用请查看文档javadoc

和 Hutool 的性能对比测试请查看 jmh.contrast

特性

Stargazers over time

Stargazers over time

说明

仓库

  • Maven:

    <dependency>
      <groupId>top.csaf</groupId>
      <artifactId>ZUtil</artifactId>
      <version>1.11.0</version>
    </dependency>
  • Gradle

    // groovy
    implementation 'top.csaf:ZUtil:1.11.0'
    // kotlin
    implementation("top.csaf:ZUtil:1.11.0")

JMH 性能对比测试结果解释

// Benchmark                                                 Mode     Cnt    Score    Error   Units
// ToPinyinTest.toPinyinByHutool                            thrpt       5    2.880 ±  0.160  ops/us
// ToPinyinTest.toPinyinByZUtil                             thrpt       5    4.577 ±  0.133  ops/us
// ToPinyinTest.toPinyinByHutool                             avgt       5    0.356 ±  0.012   us/op
// ToPinyinTest.toPinyinByZUtil                              avgt       5    0.216 ±  0.006   us/op
// ToPinyinTest.toPinyinByHutool                           sample  175058    0.435 ±  0.008   us/op
// ToPinyinTest.toPinyinByHutool:toPinyinByHutool·p0.00    sample            0.300            us/op
// ToPinyinTest.toPinyinByHutool:toPinyinByHutool·p0.50    sample            0.400            us/op
// ToPinyinTest.toPinyinByHutool:toPinyinByHutool·p0.90    sample            0.500            us/op
// ToPinyinTest.toPinyinByHutool:toPinyinByHutool·p0.95    sample            0.500            us/op
// ToPinyinTest.toPinyinByHutool:toPinyinByHutool·p0.99    sample            0.900            us/op
// ToPinyinTest.toPinyinByHutool:toPinyinByHutool·p0.999   sample            1.600            us/op
// ToPinyinTest.toPinyinByHutool:toPinyinByHutool·p0.9999  sample           40.900            us/op
// ToPinyinTest.toPinyinByHutool:toPinyinByHutool·p1.00    sample          277.504            us/op
// ToPinyinTest.toPinyinByZUtil                            sample  162384    0.393 ±  0.008   us/op
// ToPinyinTest.toPinyinByZUtil:toPinyinByZUtil·p0.00      sample            0.200            us/op
// ToPinyinTest.toPinyinByZUtil:toPinyinByZUtil·p0.50      sample            0.300            us/op
// ToPinyinTest.toPinyinByZUtil:toPinyinByZUtil·p0.90      sample            0.500            us/op
// ToPinyinTest.toPinyinByZUtil:toPinyinByZUtil·p0.95      sample            0.600            us/op
// ToPinyinTest.toPinyinByZUtil:toPinyinByZUtil·p0.99      sample            1.000            us/op
// ToPinyinTest.toPinyinByZUtil:toPinyinByZUtil·p0.999     sample            2.500            us/op
// ToPinyinTest.toPinyinByZUtil:toPinyinByZUtil·p0.9999    sample           45.425            us/op
// ToPinyinTest.toPinyinByZUtil:toPinyinByZUtil·p1.00      sample          170.496            us/op
// ToPinyinTest.toPinyinByHutool                               ss       5   30.880 ± 37.754   us/op
// ToPinyinTest.toPinyinByZUtil                                ss       5   23.060 ± 16.885   us/op

Mode 即为org.openjdk.jmh.annotations.Mode,分为:

  • thrpt:Throughput(吞吐量), ops/time,分数越大越好
  • avgt:Average time(平均时间), time/op,分数越小越好
  • sample:Sampling time(采样时间),分数越小越好
  • ss:Single shot invocation time(单次调用时间):分数越小越好

参与开发

  1. ForkClone 项目到本地。
  2. 开发:
    • 新增类或方法需提前加群沟通。
    • 修复 BUG(fix)、优化性能(perf)或新增/更正测试(test)。
  3. 测试:
    • 使用org.junit.jupiter.api.Assertions进行代码覆盖率测试
    ……
    import static org.junit.jupiter.api.Assertions.*;
    
    @Slf4j
    @DisplayName("NanoId 工具类测试")
    class NanoIdUtilsTest {
    
      @DisplayName("生成 NanoID")
      @Test
      void randomNanoId() {
        /** {@link top.csaf.id.NanoIdUtils#randomNanoId(int, char[], java.util.Random) } */
        assertThrows(NullPointerException.class, () -> NanoIdUtils.randomNanoId(0, (char[]) null, NanoIdUtils.DEFAULT_ID_GENERATOR));
        assertThrows(NullPointerException.class, () -> NanoIdUtils.randomNanoId(0, new char[0], null));
        assertThrows(IllegalArgumentException.class, () -> NanoIdUtils.randomNanoId(0, new char[0], NanoIdUtils.DEFAULT_ID_GENERATOR));
        assertThrows(IllegalArgumentException.class, () -> NanoIdUtils.randomNanoId(1, new char[0], NanoIdUtils.DEFAULT_ID_GENERATOR));
        assertThrows(IllegalArgumentException.class, () -> NanoIdUtils.randomNanoId(1, new char[256], NanoIdUtils.DEFAULT_ID_GENERATOR));
        assertDoesNotThrow(() -> NanoIdUtils.randomNanoId(NanoIdUtils.DEFAULT_SIZE, NanoIdUtils.DEFAULT_ALPHABET, NanoIdUtils.DEFAULT_ID_GENERATOR));
      }
    }
    • Maventest进行测试,测试后会在target下生成jacoco.exec
    • Mavenjacoco:report生成代码覆盖率测试报告,在target/site目录下。
    • 查看更新的类或方法,覆盖率在 90% 以上时提交。
  4. 提交时遵循 Angular 提交消息规范,提交后新建 pull request 即可。

zutil's People

Contributors

duanluan avatar shinydays avatar yeliulee avatar robertindie avatar hdgaadd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.