// Path: src/main/java/org/gololang/microbenchmarks/support/CodeLoader.java
// public class CodeLoader {
// 
//   private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
// 
//   public MethodHandle golo(String file, String func, int argCount) {
//     GoloClassLoader classLoader = new GoloClassLoader();
//     String filename = "snippets/golo/" + file + ".golo";
//     Class<?> module = classLoader.load(filename, CodeLoader.class.getResourceAsStream("/" + filename));
//     try {
//       return LOOKUP.findStatic(module, func, MethodType.genericMethodType(argCount));
//     } catch (Exception e) {
//       throw new RuntimeException(e);
//     }
//   }
// 
//   public MethodHandle groovy(String file, String method, MethodType type) {
//     CompilerConfiguration.DEFAULT.getOptimizationOptions().put("indy", false);
//     CompilerConfiguration configuration = new CompilerConfiguration();
//     configuration.getOptimizationOptions().put("indy", false);
//     GroovyClassLoader classLoader = new GroovyClassLoader();
//     return _groovy(file, method, type, classLoader);
//   }
// 
//   public MethodHandle groovy_indy(String file, String method, MethodType type) {
//     CompilerConfiguration.DEFAULT.getOptimizationOptions().put("indy", true);
//     CompilerConfiguration configuration = new CompilerConfiguration();
//     configuration.getOptimizationOptions().put("indy", true);
//     GroovyClassLoader classLoader = new GroovyClassLoader();
//     return _groovy(file, method, type, classLoader);
//   }
// 
//   private MethodHandle _groovy(String file, String method, MethodType type, GroovyClassLoader classLoader) {
//     String filename = "snippets/groovy/" + file + ".groovy";
//     Class klass = classLoader.parseClass(CodeLoader.class.getResourceAsStream("/" + filename), filename);
//     try {
//       return LOOKUP.findStatic(klass, method, type);
//     } catch (Exception e) {
//       throw new RuntimeException(e);
//     }
//   }
// 
//   public clojure.lang.Var clojure(String file, String namespace, String ref) {
//     try {
//       // Damn you Clojure 1.5, somehow RT needs to be loaded in a way or the other
//       Class.forName("clojure.lang.RT");
//       String filename = "snippets/clojure/" + file + ".clj";
//       InputStreamReader reader = new InputStreamReader(CodeLoader.class.getResourceAsStream("/" + filename));
//       clojure.lang.Compiler.load(reader);
//       return clojure.lang.RT.var(namespace, ref);
//     } catch (ClassNotFoundException e) {
//       throw new RuntimeException(e);
//     }
//   }
// 
//   public JRubyContainerAndReceiver jruby(String file) {
//     ScriptingContainer container = new ScriptingContainer();
//     String filename = "snippets/jruby/" + file + ".rb";
//     return new JRubyContainerAndReceiver(container,
//         container.runScriptlet(CodeLoader.class.getResourceAsStream("/" + filename), filename));
//   }
// 
//   public ScriptEngine nashorn(String file) {
//     try {
//       ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
//       if (engine != null) {
//         engine.eval(new InputStreamReader(CodeLoader.class.getResourceAsStream("/snippets/js/" + file + ".js")));
//       }
//       return engine;
//     } catch (Exception e) {
//       throw new RuntimeException(e);
//     }
//   }
// 
//   public PythonInterpreter jython(String file) {
//     PythonInterpreter pythonInterpreter = new PythonInterpreter();
//     String filename = "snippets/jython/" + file + ".py";
//     pythonInterpreter.execfile(CodeLoader.class.getResourceAsStream("/" + filename));
//     return pythonInterpreter;
//   }
// }


import org.gololang.microbenchmarks.support.CodeLoader;
import org.openjdk.jmh.annotations.*;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import static java.lang.invoke.MethodType.genericMethodType;
import static java.lang.invoke.MethodType.methodType;
      }
    }
  }

  @State(Scope.Thread)
  static public class GoloState {

    MethodHandle sumHandle;
    MethodHandle sumWithConstantHandle;
    MethodHandle sumOfConstantsHandle;

    @Setup(Level.Trial)
    public void setup() {
      sumHandle = new CodeLoader().golo("arithmetic", "sum", 2);
      sumWithConstantHandle = new CodeLoader().golo("arithmetic", "sum_with_constant", 1);
      sumOfConstantsHandle = new CodeLoader().golo("arithmetic", "sum_of_constants", 0);
    }
  }

  @State(Scope.Thread)
  static public class GroovyState {

    MethodHandle sumHandle;
    MethodHandle sumWithConstantHandle;
    MethodHandle sumOfConstantsHandle;
    MethodHandle fastSumHandle;
    MethodHandle fastestSumHandle;

    @Setup(Level.Trial)
    public void setup() {
// Path: src/main/java/org/gololang/microbenchmarks/support/CodeLoader.java
// public class CodeLoader {
// 
//   private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
// 
//   public MethodHandle golo(String file, String func, int argCount) {
//     GoloClassLoader classLoader = new GoloClassLoader();
//     String filename = "snippets/golo/" + file + ".golo";
//     Class<?> module = classLoader.load(filename, CodeLoader.class.getResourceAsStream("/" + filename));
//     try {
//       return LOOKUP.findStatic(module, func, MethodType.genericMethodType(argCount));
//     } catch (Exception e) {
//       throw new RuntimeException(e);
//     }
//   }
// 
//   public MethodHandle groovy(String file, String method, MethodType type) {
//     CompilerConfiguration.DEFAULT.getOptimizationOptions().put("indy", false);
//     CompilerConfiguration configuration = new CompilerConfiguration();
//     configuration.getOptimizationOptions().put("indy", false);
//     GroovyClassLoader classLoader = new GroovyClassLoader();
//     return _groovy(file, method, type, classLoader);
//   }
// 
//   public MethodHandle groovy_indy(String file, String method, MethodType type) {
//     CompilerConfiguration.DEFAULT.getOptimizationOptions().put("indy", true);
//     CompilerConfiguration configuration = new CompilerConfiguration();
//     configuration.getOptimizationOptions().put("indy", true);
//     GroovyClassLoader classLoader = new GroovyClassLoader();
//     return _groovy(file, method, type, classLoader);
//   }
// 
//   private MethodHandle _groovy(String file, String method, MethodType type, GroovyClassLoader classLoader) {
//     String filename = "snippets/groovy/" + file + ".groovy";
//     Class klass = classLoader.parseClass(CodeLoader.class.getResourceAsStream("/" + filename), filename);
//     try {
//       return LOOKUP.findStatic(klass, method, type);
//     } catch (Exception e) {
//       throw new RuntimeException(e);
//     }
//   }
// 
//   public clojure.lang.Var clojure(String file, String namespace, String ref) {
//     try {
//       // Damn you Clojure 1.5, somehow RT needs to be loaded in a way or the other
//       Class.forName("clojure.lang.RT");
//       String filename = "snippets/clojure/" + file + ".clj";
//       InputStreamReader reader = new InputStreamReader(CodeLoader.class.getResourceAsStream("/" + filename));
//       clojure.lang.Compiler.load(reader);
//       return clojure.lang.RT.var(namespace, ref);
//     } catch (ClassNotFoundException e) {
//       throw new RuntimeException(e);
//     }
//   }
// 
//   public JRubyContainerAndReceiver jruby(String file) {
//     ScriptingContainer container = new ScriptingContainer();
//     String filename = "snippets/jruby/" + file + ".rb";
//     return new JRubyContainerAndReceiver(container,
//         container.runScriptlet(CodeLoader.class.getResourceAsStream("/" + filename), filename));
//   }
// 
//   public ScriptEngine nashorn(String file) {
//     try {
//       ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
//       if (engine != null) {
//         engine.eval(new InputStreamReader(CodeLoader.class.getResourceAsStream("/snippets/js/" + file + ".js")));
//       }
//       return engine;
//     } catch (Exception e) {
//       throw new RuntimeException(e);
//     }
//   }
// 
//   public PythonInterpreter jython(String file) {
//     PythonInterpreter pythonInterpreter = new PythonInterpreter();
//     String filename = "snippets/jython/" + file + ".py";
//     pythonInterpreter.execfile(CodeLoader.class.getResourceAsStream("/" + filename));
//     return pythonInterpreter;
//   }
// }


// Path: src/main/java/org/gololang/microbenchmarks/arithmetic/CostOfSumMicroBenchmark.java
import org.gololang.microbenchmarks.support.CodeLoader;
import org.openjdk.jmh.annotations.*;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import static java.lang.invoke.MethodType.genericMethodType;
import static java.lang.invoke.MethodType.methodType;

      }
    }
  }

  @State(Scope.Thread)
  static public class GoloState {

    MethodHandle sumHandle;
    MethodHandle sumWithConstantHandle;
    MethodHandle sumOfConstantsHandle;

    @Setup(Level.Trial)
    public void setup() {
      sumHandle = new CodeLoader().golo("arithmetic", "sum", 2);
      sumWithConstantHandle = new CodeLoader().golo("arithmetic", "sum_with_constant", 1);
      sumOfConstantsHandle = new CodeLoader().golo("arithmetic", "sum_of_constants", 0);
    }
  }

  @State(Scope.Thread)
  static public class GroovyState {

    MethodHandle sumHandle;
    MethodHandle sumWithConstantHandle;
    MethodHandle sumOfConstantsHandle;
    MethodHandle fastSumHandle;
    MethodHandle fastestSumHandle;

    @Setup(Level.Trial)
    public void setup() {
      sumHandle = new CodeLoader().groovy("arithmetic", "sum", genericMethodType(2));