• 请不要在回答技术问题时复制粘贴 AI 生成的内容
BacGa
V2EX  ›  程序员

Java 问题 [函数运行耗时] [文件流压缩]

  •  
  •   BacGa · Jan 4, 2020 · 3317 views
    This topic created in 2496 days ago, the information mentioned may be changed or developed.

    1.对函数运行耗时计算,除了 long begin/end = System.nanoTime();这种方案 还有其他通用高效的轮子吗

    2.文件压缩能不能只经历 io 流的转换而不需生成中间文件落地,直接从 fileinputstream 转成 zipoutputstream

    9 replies  •  2020-01-04 18:07:57 +08:00
    wysnylc
    wysnylc
    Jan 4, 2020
    1
    1,获取当前执行时间已经是最简单的了,还要啥轮子?
    2,第二个我弄过类似的,文件流可以互相转换不需要写入磁盘
    BacGa
    BacGa
    OP
    Jan 4, 2020
    2
    @wysnylc 大师兄 文件流的写法能给看看嘛
    wysnylc
    wysnylc
    Jan 4, 2020
    3
    alvinbone88
    alvinbone88
    Jan 4, 2020 via Android
    4
    第一个问题,Java Microbenchmark Harness
    luozic
    luozic
    Jan 4, 2020 via iPhone
    5
    jmh 基于注解 可以写到测试类里面 通过命令跑。
    BacGa
    BacGa
    OP
    Jan 4, 2020
    6
    @alvinbone88
    @luozic 感谢
    @wysnylc 师兄 图挂了 我 vx bacga_void_man :-)
    xiangyuecn
    xiangyuecn
    Jan 4, 2020
    7
    不知道 ByteArrayInputStream ByteArrayOutputStream 有没有用,C#里面是 MemoryStream,反而觉得 Memory 比 ByteArray 好记
    guyeu
    guyeu
    Jan 4, 2020❤️1
    8
    1. guava 有计时工具包 Stopwatch ;
    2. new ZipOutputStream(new FileOutputStream(out)),直接输出压缩文件,本来就不需要中间落一次地。
    stimulate1797
    stimulate1797
    Jan 4, 2020
    9
    JMH 了解下
    ```xml
    <!-- JMH-->
    <dependency>
    <groupId>org.openjdk.jmh</groupId>
    <artifactId>jmh-core</artifactId>
    <version>${jmh.version}</version>
    </dependency>
    <dependency>
    <groupId>org.openjdk.jmh</groupId>
    <artifactId>jmh-generator-annprocess</artifactId>
    <version>${jmh.version}</version>
    <scope>provided</scope>
    </dependency>
    ```
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2506 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 14:58 · PVG 22:58 · LAX 06:58 · JFK 09:58
    ♥ Do have faith in what you're doing.