This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko.git


The following commit(s) were added to refs/heads/main by this push:
     new 4b2917faae Create ByteString_indexOfSlice_Benchmark.scala (#2325)
4b2917faae is described below

commit 4b2917faaecc3f68d5c37a61ea58d8f2f591c8eb
Author: PJ Fanning <[email protected]>
AuthorDate: Sat Oct 18 18:14:16 2025 +0100

    Create ByteString_indexOfSlice_Benchmark.scala (#2325)
    
    Update ByteString_indexOfSlice_Benchmark.scala
---
 .../util/ByteString_indexOfSlice_Benchmark.scala   | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git 
a/bench-jmh/src/main/scala/org/apache/pekko/util/ByteString_indexOfSlice_Benchmark.scala
 
b/bench-jmh/src/main/scala/org/apache/pekko/util/ByteString_indexOfSlice_Benchmark.scala
new file mode 100644
index 0000000000..3d458129e9
--- /dev/null
+++ 
b/bench-jmh/src/main/scala/org/apache/pekko/util/ByteString_indexOfSlice_Benchmark.scala
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * license agreements; and to You under the Apache License, version 2.0:
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * This file is part of the Apache Pekko project, which was derived from Akka.
+ */
+
+/*
+ * Copyright (C) 2014-2022 Lightbend Inc. <https://www.lightbend.com>
+ */
+
+package org.apache.pekko.util
+
+import java.util.concurrent.TimeUnit
+import java.nio.charset.StandardCharsets
+
+import org.openjdk.jmh.annotations._
+
+@State(Scope.Benchmark)
+@Measurement(timeUnit = TimeUnit.MILLISECONDS)
+class ByteString_indexOfSlice_Benchmark {
+  val start = ByteString("abcdefg") ++ ByteString("hijklmno") ++ 
ByteString("pqrstuv")
+  val bss = start ++ start ++ start ++ start ++ start ++ ByteString("xyz")
+
+  val bs = bss.compact // compacted
+  val xyz = "xyz".getBytes(StandardCharsets.UTF_8)
+
+  @Benchmark
+  def bss_indexOfSlice: Int = bss.indexOfSlice(xyz, 1)
+
+  @Benchmark
+  def bs_indexOfSlice: Int = bs.indexOfSlice(xyz, 1)
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to