From 5eb1f9f7b34bc59fae029a646c21e32675b865c7 Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Fri, 22 Sep 2017 09:34:53 -0500 Subject: [PATCH] MAPREDUCE-6965. QuasiMonteCarlo should use Time.monotonicNow for measuring durations. Contributed by Chetna Chaudhari (cherry picked from commit 908d8e914ef55aca69cb8e725e62bda29d1073cc) --- .../java/org/apache/hadoop/examples/QuasiMonteCarlo.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/QuasiMonteCarlo.java b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/QuasiMonteCarlo.java index 1a0c3726c9a..67f0fef67a6 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/QuasiMonteCarlo.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/QuasiMonteCarlo.java @@ -38,6 +38,7 @@ import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import org.apache.hadoop.mapreduce.lib.output.SequenceFileOutputFormat; +import org.apache.hadoop.util.Time; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; @@ -302,13 +303,13 @@ public static BigDecimal estimatePi(int numMaps, long numPoints, //start a map/reduce job System.out.println("Starting Job"); - final long startTime = System.currentTimeMillis(); + final long startTime = Time.monotonicNow(); job.waitForCompletion(true); if (!job.isSuccessful()) { System.out.println("Job " + job.getJobID() + " failed!"); System.exit(1); } - final double duration = (System.currentTimeMillis() - startTime)/1000.0; + final double duration = (Time.monotonicNow() - startTime)/1000.0; System.out.println("Job Finished in " + duration + " seconds"); //read outputs