mirror of https://github.com/sbt/sbt.git
Add Blake3
This commit is contained in:
parent
cddb496180
commit
e9b9e8de12
|
|
@ -56,10 +56,10 @@ jobs:
|
|||
java: 17
|
||||
distribution: zulu
|
||||
jobtype: 12
|
||||
- os: ubuntu-latest
|
||||
java: 17
|
||||
distribution: temurin
|
||||
jobtype: 13
|
||||
# - os: ubuntu-latest
|
||||
# java: 17
|
||||
# distribution: temurin
|
||||
# jobtype: 13
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 25
|
||||
env:
|
||||
|
|
@ -207,8 +207,8 @@ jobs:
|
|||
shell: bash
|
||||
run: |
|
||||
./sbt -v "scripted cache/*"
|
||||
- name: Hash Benchmark
|
||||
if: ${{ matrix.jobtype == 13 }}
|
||||
shell: bash
|
||||
run: |
|
||||
./sbt -v "hashBenchmark/Jmh/run -i 5 -wi 3 -f1 -t1"
|
||||
# - name: Hash Benchmark
|
||||
# if: ${{ matrix.jobtype == 13 }}
|
||||
# shell: bash
|
||||
# run: |
|
||||
# ./sbt -v "hashBenchmark/Jmh/run -i 5 -wi 3 -f1 -t1"
|
||||
|
|
|
|||
|
|
@ -408,6 +408,7 @@ lazy val hashBenchmark = (project in file("internal") / "hash-benchmark")
|
|||
utilCommonSettings,
|
||||
name := "Hash Benchmark",
|
||||
Jmh / run / javaOptions ++= Seq("-Xmx1G", "-Dfile.encoding=UTF8"),
|
||||
libraryDependencies += blake3,
|
||||
mimaSettings,
|
||||
publish / skip := true,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
package sbt.internal.util
|
||||
|
||||
import java.util.concurrent.TimeUnit
|
||||
import org.openjdk.jmh.annotations.*
|
||||
import sbt.util.Digest
|
||||
|
||||
import java.nio.file.{ Path as NioPath }
|
||||
import java.nio.file.{ Files, Path as NioPath }
|
||||
import sbt.io.IO
|
||||
import sbt.io.syntax.*
|
||||
import sbt.util.Digest
|
||||
import scala.util.Using
|
||||
import org.openjdk.jmh.annotations.*
|
||||
import pt.kcry.blake3.{ Blake3 as Blake3Impl }
|
||||
|
||||
@State(Scope.Benchmark)
|
||||
abstract class AbstractFileHashBenchmark:
|
||||
|
|
@ -47,3 +49,12 @@ class Sha1FileHashBenchmark extends AbstractFileHashBenchmark:
|
|||
class Sha256FileHashBenchmark extends AbstractFileHashBenchmark:
|
||||
override def hash(path: NioPath): String =
|
||||
Digest.sha256Hash(path).toString
|
||||
|
||||
class Blake3FileHashBenchmark extends AbstractFileHashBenchmark:
|
||||
override def hash(path: NioPath): String =
|
||||
Using.resource(Files.newInputStream(path)) { input =>
|
||||
val digest = Blake3Impl.newHasher()
|
||||
digest.update(input)
|
||||
val h = digest.doneHex(64)
|
||||
s"blake3-$h/${Files.size(path)}"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package sbt.internal.util
|
|||
import java.util.concurrent.{ ThreadLocalRandom, TimeUnit }
|
||||
import net.openhft.hashing.LongHashFunction
|
||||
import org.openjdk.jmh.annotations.*
|
||||
import pt.kcry.blake3.Blake3
|
||||
import sbt.util.Digest
|
||||
import sbt.internal.util.hashing.Hashing
|
||||
import scala.util.hashing.MurmurHash3
|
||||
|
|
@ -58,3 +59,7 @@ class Md5HashBenchmark extends AbstractHashBenchmark:
|
|||
class Sha256HashBenchmark extends AbstractHashBenchmark:
|
||||
override def hash(buf: Array[Byte]): String =
|
||||
Digest.sha256Hash(buf).toString
|
||||
|
||||
class Blake3HashBenchmark extends AbstractHashBenchmark:
|
||||
override def hash(buf: Array[Byte]): String =
|
||||
Blake3.hex(buf, 64)
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ object Dependencies {
|
|||
val scalaCollectionCompat = "org.scala-lang.modules" %% "scala-collection-compat" % "2.14.0"
|
||||
|
||||
val caffeine = "com.github.ben-manes.caffeine" % "caffeine" % "2.8.5"
|
||||
val blake3 = "pt.kcry" %% "blake3" % "3.1.2"
|
||||
|
||||
val hedgehog = "qa.hedgehog" %% "hedgehog-sbt" % "0.13.0"
|
||||
val disruptor = "com.lmax" % "disruptor" % "3.4.2"
|
||||
|
|
|
|||
Loading…
Reference in New Issue