From: <ni...@us...> - 2010-07-25 17:21:09
|
Revision: 13692 http://jmol.svn.sourceforge.net/jmol/?rev=13692&view=rev Author: nicove Date: 2010-07-25 17:21:03 +0000 (Sun, 25 Jul 2010) Log Message: ----------- Java 1.5 : direct use of methods added in Java 1.5 Modified Paths: -------------- trunk/Jmol/test/org/jmol/util/Profiling.java Modified: trunk/Jmol/test/org/jmol/util/Profiling.java =================================================================== --- trunk/Jmol/test/org/jmol/util/Profiling.java 2010-07-25 17:04:07 UTC (rev 13691) +++ trunk/Jmol/test/org/jmol/util/Profiling.java 2010-07-25 17:21:03 UTC (rev 13692) @@ -25,39 +25,13 @@ package org.jmol.util; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - /** * Class for measuring performance of Jmol code. */ public class Profiling { private static long start; - private final static Method method; - private final static String unit; - static { - Method tmpMethod = null; - String tmpUnit = null; - try { - tmpMethod = System.class.getDeclaredMethod("nanoTime", null); - tmpUnit = "ns"; - } catch (NoSuchMethodException e) { - // System.nanoTime() doesn't exist (pre 1.5 Java) - } - if (tmpMethod == null) { - try { - tmpMethod = System.class.getDeclaredMethod("currentTimeMillis", null); - tmpUnit = "ms"; - } catch (NoSuchMethodException e) { - System.err.println("No System.currentTimeMillis() method"); - } - } - method = tmpMethod; - unit = tmpUnit; - } - public static void startProfiling() { start = getTime(); } @@ -74,26 +48,10 @@ } public static long getTime() { - if (method == null) { - return 0; - } - Object result = null; - try { - result = method.invoke(null, null); - } catch (IllegalArgumentException e) { - // - } catch (IllegalAccessException e) { - // - } catch (InvocationTargetException e) { - // - } - if (result instanceof Long) { - return ((Long) result).longValue(); - } - return 0; + return System.nanoTime(); } public static String getUnit() { - return unit; + return "ns"; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |