commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Borcherds (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MATH-1406) official support for compiling on GWT 2.8
Date Mon, 06 Mar 2017 10:23:33 GMT

    [ https://issues.apache.org/jira/browse/MATH-1406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15897043#comment-15897043
] 

Michael Borcherds commented on MATH-1406:
-----------------------------------------

/*
 * 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.commons.math3;

import org.apache.commons.math3.util.FastMath;
import org.geogebra.common.main.App;
import org.geogebra.common.util.debug.Log;

/**
 * Performance benchmark for FastMath.
 * 
 */
public class FastMathTestPerformance {
	private static final int RUNS = 1000000;// Integer.parseInt(System.getProperty("testRuns",
											// "10000000"));
	private static final double F1 = 1d / RUNS;

	// Header format
	// private static final String FMT_HDR = "%-5s %13s %13s %13s Runs=%d Java
	// %s (%s) %s (%s)";
	// Detail format
	// private static final String FMT_DTL = "%-5s %6d %6.1f %6d %6.4f %6d
	// %6.4f";
	private App app;

	public void runTests(App app) {
		this.app = app;
		Log.debug((" " + "Name" + " " + "StrictMath" + " "
				+ "FastMath" + " " + "Math" + " " + RUNS + " "
		// + System.getProperty("java.version") + " "
		// + System.getProperty("java.runtime.version", "?") + " "
		// + System.getProperty("java.vm.name") + " " +
		// System.getProperty("java.vm.version")
		));
		testAbs();
		testAcos();
		testAsin();
		testAtan();
		testAtan2();
		testCbrt();
		testCos();
		testCosh();
		testExp();
		testExpm1();
		testHypot();
		testLog();
		testLog10();
		testLog1p();
		testPow();
		testSin();
		testSinh();
		testSqrt();
		testTan();
		testTanh();

	}

	@SuppressWarnings("boxing")
	private void report(String name, long strictMathTime,
			long fastMathTime, long mathTime) {
		long unitTime = strictMathTime;
		Log.debug((" " + name + " " + strictMathTime / RUNS
				+ " " + (double) strictMathTime / unitTime + " "
				+ fastMathTime / RUNS + " " + (double) fastMathTime / unitTime
				+ " " + mathTime / RUNS + " " +
				(double) mathTime / unitTime));
	}

	private void assertTrue(boolean condition) {
		if (!condition) {
			Log.debug("assertion failed!");
			// System.exit(1);
		}
	}

	private void testLog() {
		double x = 0;
		long time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.log(0.01 + i);
		}
		long strictMath = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += FastMath.log(0.01 + i);
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.log(0.01 + i);
		}
		long mathTime = nanoTime() - time;

		report("log", strictMath, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	static long nanoTime(App app0) {
		return (long) (app0.getMillisecondTime() * 1000);
	}

	private void testLog10() {
		double x = 0;
		long time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.log10(0.01 + i);
		}
		long strictMath = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += FastMath.log10(0.01 + i);
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.log10(0.01 + i);
		}
		long mathTime = nanoTime() - time;

		report("log10", strictMath, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	private long nanoTime() {
		return nanoTime(app);
	}

	private void testLog1p() {
		double x = 0;
		long time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.log1p(-0.9 + i);
		}
		long strictMath = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += FastMath.log1p(-0.9 + i);
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.log1p(-0.9 + i);
		}
		long mathTime = nanoTime() - time;

		report("log1p", strictMath, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	private void testPow() {
		double x = 0;
		long time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.pow(0.01 + i * F1, i * F1);
		}
		long strictTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += FastMath.pow(0.01 + i * F1, i * F1);
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.pow(0.01 + i * F1, i * F1);
		}
		long mathTime = nanoTime() - time;
		report("pow", strictTime, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	private void testExp() {
		double x = 0;
		long time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.exp(100 * i * F1);
		}
		long strictTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += FastMath.exp(100 * i * F1);
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.exp(100 * i * F1);
		}
		long mathTime = nanoTime() - time;

		report("exp", strictTime, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	private void testSin() {
		double x = 0;
		long time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.sin(100 * (i - RUNS / 2) * F1);
		}
		long strictTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += FastMath.sin(100 * (i - RUNS / 2) * F1);
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.sin(100 * (i - RUNS / 2) * F1);
		}
		long mathTime = nanoTime() - time;

		report("sin", strictTime, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	private void testAsin() {
		double x = 0;
		long time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.asin(0.999 * (i - RUNS / 2) * F1);
		}
		long strictTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += FastMath.asin(0.999 * (i - RUNS / 2) * F1);
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.asin(0.999 * (i - RUNS / 2) * F1);
		}
		long mathTime = nanoTime() - time;

		report("asin", strictTime, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	private void testCos() {
		double x = 0;
		long time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.cos(100 * (i - RUNS / 2) * F1);
		}
		long strictTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += FastMath.cos(100 * (i - RUNS / 2) * F1);
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.cos(100 * (i - RUNS / 2) * F1);
		}
		long mathTime = nanoTime() - time;

		report("cos", strictTime, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	private void testAcos() {
		double x = 0;
		long time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.acos(0.999 * (i - RUNS / 2) * F1);
		}
		long strictTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += FastMath.acos(0.999 * (i - RUNS / 2) * F1);
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.acos(0.999 * (i - RUNS / 2) * F1);
		}
		long mathTime = nanoTime() - time;
		report("acos", strictTime, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	private void testTan() {
		double x = 0;
		long time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.tan(100 * (i - RUNS / 2) * F1);
		}
		long strictTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += FastMath.tan(100 * (i - RUNS / 2) * F1);
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.tan(100 * (i - RUNS / 2) * F1);
		}
		long mathTime = nanoTime() - time;

		report("tan", strictTime, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	private void testAtan() {
		double x = 0;
		long time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.atan(100 * (i - RUNS / 2) * F1);
		}
		long strictTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += FastMath.atan(100 * (i - RUNS / 2) * F1);
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.atan(100 * (i - RUNS / 2) * F1);
		}
		long mathTime = nanoTime() - time;

		report("atan", strictTime, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	private void testAtan2() {
		double x = 0;
		long time = nanoTime();
		int max = (int) FastMath.floor(FastMath.sqrt(RUNS));
		for (int i = 0; i < max; i++) {
			for (int j = 0; j < max; j++) {
				x += Math.atan2((i - max / 2) * (100.0 / max),
						(j - max / 2) * (100.0 / max));
			}
		}
		long strictTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < max; i++) {
			for (int j = 0; j < max; j++) {
				x += FastMath.atan2((i - max / 2) * (100.0 / max),
						(j - max / 2) * (100.0 / max));
			}
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < max; i++) {
			for (int j = 0; j < max; j++) {
				x += Math.atan2((i - max / 2) * (100.0 / max),
						(j - max / 2) * (100.0 / max));
			}
		}
		long mathTime = nanoTime() - time;

		report("atan2", strictTime, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	private void testHypot() {
		double x = 0;
		long time = nanoTime();
		int max = (int) FastMath.floor(FastMath.sqrt(RUNS));
		for (int i = 0; i < max; i++) {
			for (int j = 0; j < max; j++) {
				x += Math.atan2((i - max / 2) * (100.0 / max),
						(j - max / 2) * (100.0 / max));
			}
		}
		long strictTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < max; i++) {
			for (int j = 0; j < max; j++) {
				x += FastMath.atan2((i - max / 2) * (100.0 / max),
						(j - max / 2) * (100.0 / max));
			}
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < max; i++) {
			for (int j = 0; j < max; j++) {
				x += Math.atan2((i - max / 2) * (100.0 / max),
						(j - max / 2) * (100.0 / max));
			}
		}
		long mathTime = nanoTime() - time;

		report("hypot", strictTime, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	private void testCbrt() {
		double x = 0;
		long time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.cbrt(100 * i * F1);
		}
		long strictTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += FastMath.cbrt(100 * i * F1);
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.cbrt(100 * i * F1);
		}
		long mathTime = nanoTime() - time;

		report("cbrt", strictTime, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	private void testSqrt() {
		double x = 0;
		long time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.sqrt(100 * i * F1);
		}
		long strictTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += FastMath.sqrt(100 * i * F1);
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.sqrt(100 * i * F1);
		}
		long mathTime = nanoTime() - time;

		report("sqrt", strictTime, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	private void testCosh() {
		double x = 0;
		long time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.cosh(100 * (i - RUNS / 2) * F1);
		}
		long strictTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += FastMath.cosh(100 * (i - RUNS / 2) * F1);
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.cosh(100 * (i - RUNS / 2) * F1);
		}
		long mathTime = nanoTime() - time;

		report("cosh", strictTime, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	private void testSinh() {
		double x = 0;
		long time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.sinh(100 * (i - RUNS / 2) * F1);
		}
		long strictTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += FastMath.sinh(100 * (i - RUNS / 2) * F1);
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.sinh(100 * (i - RUNS / 2) * F1);
		}
		long mathTime = nanoTime() - time;

		report("sinh", strictTime, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	private void testTanh() {
		double x = 0;
		long time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.tanh(100 * (i - RUNS / 2) * F1);
		}
		long strictTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += FastMath.tanh(100 * (i - RUNS / 2) * F1);
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.tanh(100 * (i - RUNS / 2) * F1);
		}
		long mathTime = nanoTime() - time;

		report("tanh", strictTime, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	private void testExpm1() {
		double x = 0;
		long time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.expm1(100 * (i - RUNS / 2) * F1);
		}
		long strictTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += FastMath.expm1(100 * (i - RUNS / 2) * F1);
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.expm1(100 * (i - RUNS / 2) * F1);
		}
		long mathTime = nanoTime() - time;
		report("expm1", strictTime, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	private void testAbs() {
		double x = 0;
		long time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.abs(i * (1 - 0.5 * RUNS));
		}
		long strictTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += FastMath.abs(i * (1 - 0.5 * RUNS));
		}
		long fastTime = nanoTime() - time;

		x = 0;
		time = nanoTime();
		for (int i = 0; i < RUNS; i++) {
			x += Math.abs(i * (1 - 0.5 * RUNS));
		}
		long mathTime = nanoTime() - time;

		report("abs", strictTime, fastTime, mathTime);
		assertTrue(!Double.isNaN(x));
	}

	@SuppressWarnings("boxing")
	private void testSimpleBenchmark() {
		final String SM = "StrictMath";
		final String M = "Math";
		final String FM = "FastMath";

		final int numStat = 100;
		final int numCall = RUNS / numStat;

		final double x = Math.random();
		final double y = Math.random();

		PerfTestUtils.timeAndReport(app, "log", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.log(x);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.log(x);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.log(x);
					}
				});

		PerfTestUtils.timeAndReport(app, "log10", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.log10(x);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.log10(x);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.log10(x);
					}
				});

		PerfTestUtils.timeAndReport(app, "log1p", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.log1p(x);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.log1p(x);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.log1p(x);
					}
				});

		PerfTestUtils.timeAndReport(app, "pow", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.pow(x, y);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.pow(x, y);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.pow(x, y);
					}
				});

		PerfTestUtils.timeAndReport(app, "exp", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.exp(x);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.exp(x);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.exp(x);
					}
				});

		PerfTestUtils.timeAndReport(app, "sin", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.sin(x);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.sin(x);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.sin(x);
					}
				});

		PerfTestUtils.timeAndReport(app, "asin", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.asin(x);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.asin(x);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.asin(x);
					}
				});

		PerfTestUtils.timeAndReport(app, "cos", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.cos(x);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.cos(x);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.cos(x);
					}
				});

		PerfTestUtils.timeAndReport(app, "acos", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.acos(x);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.acos(x);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.acos(x);
					}
				});

		PerfTestUtils.timeAndReport(app, "tan", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.tan(x);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.tan(x);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.tan(x);
					}
				});

		PerfTestUtils.timeAndReport(app, "atan", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.atan(x);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.atan(x);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.atan(x);
					}
				});

		PerfTestUtils.timeAndReport(app, "atan2", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.atan2(x, y);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.atan2(x, y);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.atan2(x, y);
					}
				});

		PerfTestUtils.timeAndReport(app, "hypot", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.hypot(x, y);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.hypot(x, y);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.hypot(x, y);
					}
				});

		PerfTestUtils.timeAndReport(app, "cbrt", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.cbrt(x);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.cbrt(x);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.cbrt(x);
					}
				});

		PerfTestUtils.timeAndReport(app, "sqrt", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.sqrt(x);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.sqrt(x);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.sqrt(x);
					}
				});

		PerfTestUtils.timeAndReport(app, "cosh", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.cosh(x);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.cosh(x);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.cosh(x);
					}
				});

		PerfTestUtils.timeAndReport(app, "sinh", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.sinh(x);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.sinh(x);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.sinh(x);
					}
				});

		PerfTestUtils.timeAndReport(app, "tanh", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.tanh(x);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.tanh(x);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.tanh(x);
					}
				});

		PerfTestUtils.timeAndReport(app, "expm1", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.expm1(x);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.expm1(x);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.expm1(x);
					}
				});

		PerfTestUtils.timeAndReport(app, "abs", numCall, numStat, false,
				new PerfTestUtils.RunTest(SM) {
					@Override
					public Double call() throws Exception {
						return Math.abs(x);
					}
				}, new PerfTestUtils.RunTest(M) {
					@Override
					public Double call() throws Exception {
						return Math.abs(x);
					}
				}, new PerfTestUtils.RunTest(FM) {
					@Override
					public Double call() throws Exception {
						return FastMath.abs(x);
					}
				});
	}
}


> official support for compiling on GWT 2.8
> -----------------------------------------
>
>                 Key: MATH-1406
>                 URL: https://issues.apache.org/jira/browse/MATH-1406
>             Project: Commons Math
>          Issue Type: Improvement
>            Reporter: Michael Borcherds
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> Is there any interest in allowing Apache Commons Math to be officially supported on GWT?
> With GWT 2.8.0 the changes needed aren't too hard to get most of it to compile
> You can see the diff from 3.6.1 here:
> https://github.com/murkle/commons-math/issues/1



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message