lanking520 commented on a change in pull request #13095: [MXNET-1041] Add Java 
benchmark
URL: https://github.com/apache/incubator-mxnet/pull/13095#discussion_r232147674
 
 

 ##########
 File path: 
scala-package/examples/src/main/java/org/apache/mxnetexamples/javaapi/benchmark/JavaBenchmark.java
 ##########
 @@ -0,0 +1,135 @@
+/*
+ * 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.mxnetexamples.javaapi.benchmark;
+
+import org.apache.mxnet.javaapi.Context;
+import org.kohsuke.args4j.CmdLineParser;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class JavaBenchmark {
+
+    private static boolean runBatch = false;
+
+    private static void parse(Object inst, String[] args) {
+        CmdLineParser parser  = new CmdLineParser(inst);
+        try {
+            parser.parseArgument(args);
+        } catch (Exception e) {
+            System.err.println(e.getMessage() + e);
+            parser.printUsage(System.err);
+            System.exit(1);
+        }
+    }
+
+    private static long percentile(int p, long[] seq) {
+        Arrays.sort(seq);
+        int k = (int) Math.ceil((seq.length - 1) * (p / 100.0));
+        return seq[k];
+    }
+
+    private static void printStatistics(long[] inferenceTimesRaw, String 
metricsPrefix)  {
+        long[] inferenceTimes = inferenceTimesRaw;
+        // remove head and tail
+        if (inferenceTimes.length > 2) {
+            inferenceTimes = Arrays.copyOfRange(inferenceTimesRaw,
 
 Review comment:
   > I agree with @piyushghai, i think it would make sense to drop max(x%, 1), 
wdyt ?
   @piyushghai @nswamy Bare with me, any technical reason or proof of concept 
for doing this? Why dropping the first 10% and the last 10% would bring a 
better result? Why not 20%?(under the assumption that the time cost is a normal 
distribution, it would be better to drop the smallest 5% and the largest 5% so 
we fit 2 sigma)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to