rohityadav1993 commented on code in PR #13107:
URL: https://github.com/apache/pinot/pull/13107#discussion_r1622832355


##########
pinot-common/src/main/java/org/apache/pinot/common/utils/Benchmark.java:
##########
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.common.utils;
+
+import java.util.Random;
+import java.util.regex.Pattern;
+
+
+public class Benchmark {
+  public static final String SEPARATOR = "_";
+  public static final String UPLOADED_PREFIX = "uploaded";
+  public static final String UPLOADED_REALTIME_SEGMENT_NAME_REGEX = 
"^uploaded_(.+)_(\\d+)_(\\d+)_(\\d+)$";
+  private static final Pattern NAME_PATTERN = 
Pattern.compile(UPLOADED_REALTIME_SEGMENT_NAME_REGEX);
+
+  private Benchmark() {
+  }
+
+  public static boolean isUploadedRealtimeSegmentNameMethod1(String 
segmentName) {
+    String[] parts = segmentName.split(SEPARATOR);

Review Comment:
   Got you, I wasn't aware of the subtelty. This file was also not supposed to 
be checked in, removing.
   Did some benchmark with 3 methods:
   
   ```
   Method 1 (String.split()) took: 2266343500 ns
   Method 2 (regex match) took: 3760987625 ns
   Method 3 (StringUtils.split()) took: 2412549250 ns
   
   Method 3 is 0.939397817474607 times faster than Method 1
   Method 3 is 1.5589267763134784 times faster than Method 2
   ```
   
   ```
   Method 1 (String.split()) took: 2462188708 ns
   Method 2 (regex match) took: 4130721000 ns
   Method 3 (StringUtils.split()) took: 2082269750 ns
   
   Method 3 is 1.1824542463818628 times faster than Method 1
   Method 3 is 1.983758828557155 times faster than Method 2
   ```
   
   ```
   Method 1 (String.split()) took: 2275362125 ns
   Method 2 (regex match) took: 4017714167 ns
   Method 3 (StringUtils.split()) took: 2003299125 ns
   
   Method 3 is 1.1358074770785915 times faster than Method 1
   Method 3 is 2.0055488053986945 times faster than Method 2
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to