未分類 24 7 月 2019 Java 问题 [函数运行耗时] [文件流压缩] Java 问题 [函数运行耗时] [文件流压缩] 資深大佬 : BacGa 62 1.对函数运行耗时计算,除了 long begin/end = System.nanoTime();这种方案 还有其他通用高效的轮子吗 2.文件压缩能不能只经历 io 流的转换而不需生成中间文件落地,直接从 fileinputstream 转成 zipoutputstream 大佬有話說 (9) 資深大佬 : wysnylc 1,获取当前执行时间已经是最简单的了,还要啥轮子?2,第二个我弄过类似的,文件流可以互相转换不需要写入磁盘 主 資深大佬 : BacGa @wysnylc 大师兄 文件流的写法能给看看嘛 資深大佬 : wysnylc 資深大佬 : alvinbone88 第一个问题,Java Microbenchmark Harness 資深大佬 : luozic jmh 基于注解 可以写到测试类里面 通过命令跑。 主 資深大佬 : BacGa @alvinbone88 @luozic 感谢@wysnylc 师兄 图挂了 我 vx bacga_void_man 🙂 資深大佬 : xiangyuecn 不知道 ByteArrayInputStream ByteArrayOutputStream 有没有用,C#里面是 MemoryStream,反而觉得 Memory 比 ByteArray 好记 資深大佬 : guyeu 1. guava 有计时工具包 Stopwatch ;2. new ZipOutputStream(new FileOutputStream(out)),直接输出压缩文件,本来就不需要中间落一次地。 資深大佬 : itning 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>“`