Permalink
Browse files

Uncluttering, still.

  • Loading branch information...
1 parent 00e18fb commit abf97b4669a242776be908e49c562e391c9c6f7d @julienrf committed Jul 25, 2012
Showing with 7 additions and 15 deletions.
  1. +7 −15 src/main/scala/tutorial/LinearAlgebra.scala
@@ -71,23 +71,15 @@ trait Prog extends LinearAlgebra {
object Usage extends App {
- object ConcreteProg extends Prog with EffectExp with LinearAlgebraExp with LinearAlgebraOpt with CompileScala { self =>
+ val concreteProg = new Prog with EffectExp with LinearAlgebraExp with LinearAlgebraOpt with CompileScala { self =>
override val codegen = new ScalaGenEffect with ScalaGenLinearAlgebra { val IR: self.type = self }
- lazy val compiledF = {
- codegen.emitSource(f, "f", new java.io.PrintWriter(System.out))
- codegen.emitSource(g, "g", new java.io.PrintWriter(System.out))
- compile(f)
- }
+ codegen.emitSource(f, "F", new java.io.PrintWriter(System.out))
+ codegen.emitSource(g, "G", new java.io.PrintWriter(System.out))
}
+ val f = concreteProg.compile(concreteProg.f)
+ println(f(Seq(1.0, 2.0)))
- val t = System.currentTimeMillis
- println(ConcreteProg.compiledF(Seq(1.0, 2.0)))
- println(System.currentTimeMillis - t)
-
- object InterpretedProg extends Prog with LinearAlgebraInterpreter
-
- val t2 = System.currentTimeMillis
- println(InterpretedProg.f(Seq(1.0, 2.0)))
- println(System.currentTimeMillis - t2)
+ val interpretedProg = new Prog with LinearAlgebraInterpreter
+ println(interpretedProg.f(Seq(1.0, 2.0)))
}

0 comments on commit abf97b4

Please sign in to comment.