summaryrefslogtreecommitdiff
path: root/sources
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
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')
-rw-r--r--sources/scala/tools/scalac/Global.scala5
-rw-r--r--sources/scala/tools/scalac/Main.scala6
-rw-r--r--sources/scala/tools/scalac/ast/parser/ParserPhase.scala4
-rw-r--r--sources/scala/tools/scaladoc/Main.scala1
-rw-r--r--sources/scala/tools/scalai/InterpreterShell.java1
-rw-r--r--sources/scalac/CompilationLoop.java4
-rw-r--r--sources/scalac/Global.java39
-rw-r--r--sources/scalac/symtab/SymbolLoader.java6
8 files changed, 26 insertions, 40 deletions
diff --git a/sources/scala/tools/scalac/Global.scala b/sources/scala/tools/scalac/Global.scala
index d55a2ecafa..d7376bdfbf 100644
--- a/sources/scala/tools/scalac/Global.scala
+++ b/sources/scala/tools/scalac/Global.scala
@@ -13,6 +13,7 @@ import scalac.backend.msil.GenMSIL;
import scalac.symtab.Symbol;
import scalac.util.Debug;
import scala.tools.scalac.backend.GenJVMFromICode;
+import scala.tools.util.Timer;
package scala.tools.scalac {
@@ -23,8 +24,10 @@ import typechecker.Infer;
/** The global environment of a compiler run
*
*/
-class Global(args: CompilerCommand, interpret: boolean) extends scalac_Global(args, interpret) {
+class Global(args: CompilerCommand, timer: Timer, interpret: Boolean) extends scalac_Global(args, timer, interpret) {
+ def this(args: CompilerCommand, interpret: Boolean) =
+ this(args, scalac_Global.getTimer(args.reporter()), interpret);
def this(args: CompilerCommand) = this(args, false);
override def newInfer(): Infer =
diff --git a/sources/scala/tools/scalac/Main.scala b/sources/scala/tools/scalac/Main.scala
index ae3c4e6258..bcd94be4ce 100644
--- a/sources/scala/tools/scalac/Main.scala
+++ b/sources/scala/tools/scalac/Main.scala
@@ -41,11 +41,13 @@ object Main {
}
}
if (ok) {
- val global = new Global(command);
+ val timer = scalac_Global.getTimer(reporter);
+ timer.start();
+ val global = new Global(command, timer, false);
val units = global.compile(command.files.toArray(), false);
if (reporter.errors() == 0)
if (!global.PHASE.CODEGEN.hasSkipFlag()) global.dump(units);
- global.stop("total");
+ timer.stop("total");
global.reporter.printSummary();
}
}
diff --git a/sources/scala/tools/scalac/ast/parser/ParserPhase.scala b/sources/scala/tools/scalac/ast/parser/ParserPhase.scala
index e373cdc853..2885ea10bf 100644
--- a/sources/scala/tools/scalac/ast/parser/ParserPhase.scala
+++ b/sources/scala/tools/scalac/ast/parser/ParserPhase.scala
@@ -16,9 +16,9 @@ package scala.tools.scalac.ast.parser {
class ParserPhase(global: scalac_Global, descriptor: PhaseDescriptor) extends Phase(global, descriptor) {
override def apply(unit: CompilationUnit): Unit = {
- global.start();
+ global.timer.start();
unit.body = new Parser(unit).parse();
- global.stop("parsed " + unit.source);
+ global.timer.stop("parsed " + unit.source);
}
}
}
diff --git a/sources/scala/tools/scaladoc/Main.scala b/sources/scala/tools/scaladoc/Main.scala
index 8bce80a250..f72a9c0819 100644
--- a/sources/scala/tools/scaladoc/Main.scala
+++ b/sources/scala/tools/scaladoc/Main.scala
@@ -52,7 +52,6 @@ object Main {
}
generator.apply();
}
- global.stop("total");
global.reporter.printSummary();
}
// System.exit(if (reporter.errors() > 0) 1 else 0);
diff --git a/sources/scala/tools/scalai/InterpreterShell.java b/sources/scala/tools/scalai/InterpreterShell.java
index a26d59c845..59fb135ecf 100644
--- a/sources/scala/tools/scalai/InterpreterShell.java
+++ b/sources/scala/tools/scalai/InterpreterShell.java
@@ -91,7 +91,6 @@ public class InterpreterShell {
public void main(String[] files, String script, String main, String[]args){
if (interactive && !nologo) showBanner();
if (files.length > 0) load(lfiles = files);
- global.stop("total"); // !!! remove ?
if (global.reporter.errors() == 0 && script != null) eval(script);
if (global.reporter.errors() == 0 && main != null) call(main, args);
if (interactive)
diff --git a/sources/scalac/CompilationLoop.java b/sources/scalac/CompilationLoop.java
index 00cf6a576a..94700d355d 100644
--- a/sources/scalac/CompilationLoop.java
+++ b/sources/scalac/CompilationLoop.java
@@ -94,7 +94,7 @@ public class CompilationLoop {
// Update the current phase pointer.
Phase phase = global.currentPhase = phases[current];
// If the phase is not yet started, start it.
- if (indexes[current] == 0) global.start();
+ if (indexes[current] == 0) global.timer.start();
// Apply the phase to all available units. It's important
// to not cache the result of "size()" as new units may be
// added during the loop.
@@ -104,7 +104,7 @@ public class CompilationLoop {
// If no new units were introduced, stop the phase.
if (next == current) {
PhaseDescriptor descriptor = phase.descriptor;
- global.stop(descriptor.taskDescription());
+ global.timer.stop(descriptor.taskDescription());
CompilationUnit[] units =
(CompilationUnit[])unitss[current].toArray(
new CompilationUnit[unitss[current].size()]);
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]");
- }
-
}
diff --git a/sources/scalac/symtab/SymbolLoader.java b/sources/scalac/symtab/SymbolLoader.java
index d02829f191..2f656c92e0 100644
--- a/sources/scalac/symtab/SymbolLoader.java
+++ b/sources/scalac/symtab/SymbolLoader.java
@@ -63,15 +63,15 @@ public abstract class SymbolLoader extends Type.LazyType {
public final void complete(Symbol symbol) {
Symbol root = getRootSymbol(symbol);
try {
- long start = System.currentTimeMillis();
Phase phase = global.currentPhase;
global.currentPhase = global.PHASE.ANALYZER.phase();
+ global.timer.start();
String source = doComplete(root);
+ global.timer.stop("loaded " + source);
global.currentPhase = phase;
- long end = System.currentTimeMillis();
- global.operation("loaded " + source + " in " + (end-start) + "ms");
checkValidity(root, source);
} catch (IOException exception) {
+ global.timer.drop();
if (global.debug) exception.printStackTrace();
String error = "error while loading " + symbol;
String message = exception.getMessage();