package org.boilit.ebm.engines;

import org.boilit.ebm.*;
import webit.script.Engine;

import java.io.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Boilit
 * @see
 */
public final class Webit extends Benchmark {
    private Engine engine;
    private String templateUrl;

    @Override
    public void init() {
        templateUrl = "/templates/webit.html";

        engine = Engine.createEngine("/webitl-default.props");
        engine.setEncoding(this.getOutputEncoding());
        engine.setEnableAsmNative(true);
    }

    @Override
    protected void workOnBytes(List<StockModel> items) throws Exception {
        final OutputStream outputStream = this.getOutputStream();
        final Map<String, Object> model = new HashMap<String, Object>();
        model.put("items", items);
        model.put("outputEncoding", this.getOutputEncoding());
        this.engine.getTemplate(this.templateUrl).merge(model, outputStream);
        this.close(outputStream);
    }

    @Override
    protected void workOnChars(List<StockModel> items) throws Exception {
        final Writer writer = this.getWriter();
        final Map<String, Object> model = new HashMap<String, Object>();
        model.put("items", items);
        model.put("outputEncoding", this.getOutputEncoding());
        this.engine.getTemplate(this.templateUrl).merge(model, writer);
        this.close(writer);
    }

    public static void main(String[] args) throws Exception {
        EngineInfo ei = EngineInfoFactory.getWebitEngineInfo();
        Benchmark benchmark = Utilities.inject(args);
        benchmark.run();

        File file = new File(Utilities.getClassPath(), ei.getName().concat(".txt"));
        BufferedWriter writer = new BufferedWriter(new FileWriter(file));
        writer.write(ei.getName() + ";");
        writer.write(ei.getVersion() + ";");
        writer.write(benchmark.getElapsedTime() + ";");
        writer.write(String.valueOf(benchmark.getOutputSize()));
        writer.flush();
        writer.close();
    }
}

@@ -274,18 +274,57 @@
 e engine
+_bytes;%0A    private Engine engine_chars
 ;%0A
-
     priv
@@ -439,79 +439,537 @@
 %22;%0A%0A
+%09
     
-    engine = Engine.createEngine(%22/webitl-default.props%22);%0A        
+Map parameters = new HashMap();%0A%09    parameters.put(%22webit.script.Engine.encoding%22, this.getOutputEncoding());%0A%09    %0A%09    parameters.put(%22webit.script.Engine.textStatmentFactoryClass%22, %22webit.script.core.text.impl.CharArrayTextStatmentFactory%22);%0A%09    engine_chars = Engine.createEngine(null, parameters);%0A        %0A        parameters.put(%22webit.script.Engine.textStatmentFactoryClass%22, %22webit.script.core.text.impl.ByteArrayTextStatmentFactory%22);%0A%09    engine_bytes = Engine.createEngine(null, parameters);%0A        %0A        //
 engi
@@ -1014,24 +1014,26 @@
 ));%0A        
+//
 engine.setEn
@@ -1396,32 +1396,38 @@
      this.engine
+_bytes
 .getTemplate(thi
@@ -1809,32 +1809,32 @@
 putEncoding());%0A
-
         this.eng
@@ -1836,16 +1836,22 @@
 s.engine
+_chars
 .getTemp

Update Webit.java