Skip to content

Commit

Permalink
resolve debug issue
Browse files Browse the repository at this point in the history
  • Loading branch information
TilmanNeumann committed Jan 2, 2025
1 parent ca1aba5 commit d90635d
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
package de.tilman_neumann.jml.transcendental;

import org.apache.logging.log4j.Logger;

import java.math.BigDecimal;

import org.apache.logging.log4j.LogManager;

import de.tilman_neumann.jml.precision.Scale;
Expand All @@ -26,8 +29,7 @@
public class EulerConstantPerformanceTest {
private static final Logger LOG = LogManager.getLogger(EulerConstantPerformanceTest.class);

/** it feels as if the compiler optimizes the computation away if we do not log the result... */
private static final boolean DEBUG = true;
private static final boolean DEBUG = false;

/**
* @param args ignored
Expand All @@ -40,14 +42,16 @@ public static void main(String[] args) {

t0 = System.currentTimeMillis();
for (Scale scale=Scale.valueOf(2); scale.compareTo(maxScale)<0; scale = scale.add(1)) {
if (DEBUG) LOG.debug("gamma_v1(" + scale + ") = " + EulerConstant.gamma_v1(scale));
BigDecimal gamma = EulerConstant.gamma_v1(scale);
if (DEBUG) LOG.debug("gamma_v1(" + scale + ") = " + gamma);
}
LOG.info("gamma_v1(" + maxScale + ") = " + EulerConstant.gamma_v1(maxScale));
String duration_v1 = TimeUtil.timeDiffStr(t0, System.currentTimeMillis());

t0 = System.currentTimeMillis();
for (Scale scale=Scale.valueOf(2); scale.compareTo(maxScale)<0; scale = scale.add(1)) {
if (DEBUG) LOG.debug("gamma_v2(" + scale + ") = " + EulerConstant.gamma_v2(scale));
BigDecimal gamma = EulerConstant.gamma_v2(scale);
if (DEBUG) LOG.debug("gamma_v2(" + scale + ") = " + gamma);
}
LOG.info("gamma_v2(" + maxScale + ") = " + EulerConstant.gamma_v2(maxScale));
String duration_v2 = TimeUtil.timeDiffStr(t0, System.currentTimeMillis());
Expand Down

0 comments on commit d90635d

Please sign in to comment.