summaryrefslogtreecommitdiff
path: root/sources/scalac/Global.java
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2005-01-25 17:11:28 +0000
committerpaltherr <paltherr@epfl.ch>2005-01-25 17:11:28 +0000
commit9d8942df91f6c8ff6d7d2ed04a57ded78cdf0948 (patch)
tree5d9f3497727c05b746d07a593ab60c4b5c014a9f /sources/scalac/Global.java
parent2cd85f1d31d933f84448bbcbc0a8cbd225cfbfe4 (diff)
downloadscala-9d8942df91f6c8ff6d7d2ed04a57ded78cdf0948.tar.gz
scala-9d8942df91f6c8ff6d7d2ed04a57ded78cdf0948.tar.bz2
scala-9d8942df91f6c8ff6d7d2ed04a57ded78cdf0948.zip
- Replaced start and stop in Global by a timer.
Diffstat (limited to 'sources/scalac/Global.java')
-rw-r--r--sources/scalac/Global.java39
1 files changed, 11 insertions, 28 deletions
diff --git a/sources/scalac/Global.java b/sources/scalac/Global.java
index b6c039c495..8d220bfdc5 100644
--- a/sources/scalac/Global.java
+++ b/sources/scalac/Global.java
@@ -28,6 +28,9 @@ import scala.tools.util.Position;
import scala.tools.util.SourceFile;
import scala.tools.util.SourceReader;
import scala.tools.util.Reporter;
+import scala.tools.util.Timer;
+import scala.tools.util.DummyTimer;
+import scala.tools.util.ReporterTimer;
import scalac.ast.*;
import scalac.ast.parser.*;
@@ -79,9 +82,9 @@ public abstract class Global {
*/
public final Reporter reporter;
- /** a stack for maintaining timestamps
+ /** the timer
*/
- private final Stack startTimes = new Stack();
+ public final Timer timer;
/** the source file charset
*/
@@ -186,13 +189,10 @@ public abstract class Global {
PRINTER_SWING = "swing",
};
- /**
- * Creates an instance variable.
- *
- * @param args
- */
- public Global(CompilerCommand args) {
- this(args, false);
+ public static Timer getTimer(Reporter reporter) {
+ return reporter.verbose
+ ? (Timer)new ReporterTimer(reporter)
+ : (Timer)DummyTimer.object;
}
/** hooks for installing printers
@@ -208,14 +208,14 @@ public abstract class Global {
* @param args
* @param interpret
*/
- public Global(CompilerCommand args, boolean interpret) {
+ public Global(CompilerCommand args, Timer timer, boolean interpret) {
assert Debug.initialize() || true;
if (Global.instance != null) // jaco bug: can't use assert here
/* throw */ Debug.abort("duplicate creation of Global");
Global.instance = this;
this.args = args;
this.reporter = args.reporter();
- this.start(); // timestamp to compute the total time
+ this.timer = timer;
this.noimports = args.noimports.value;
this.nopredefs = args.nopredefs.value;
//this.optimize = args.optimize.optimize;
@@ -651,21 +651,4 @@ public abstract class Global {
return currentPhase.descriptor.hasLogFlag();
}
- /** start a new timer
- */
- public void start() {
- startTimes.push(new Long(System.currentTimeMillis()));
- }
-
- /**
- * issue timing information
- *
- * @param message
- */
- public void stop(String message) {
- long start = ((Long)startTimes.pop()).longValue();
- reporter.inform("[" + message + " in " +
- (System.currentTimeMillis() - start) + "ms]");
- }
-
}