1   /*
2    * Copyright (c) 2005, 2009 The Australian National University.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Apache License v2.0.
5    * You may obtain the license at
6    * 
7    *    http://www.opensource.org/licenses/apache2.0.php
8    */
9   package org.dacapo.harness;
10  
11  import java.io.File;
12  import java.lang.reflect.Constructor;
13  
14  import org.dacapo.parser.Config;
15  
16  /**
17   * @date $Date: 2009-12-24 11:19:36 +1100 (Thu, 24 Dec 2009) $
18   * @id $Id: Lusearch.java 738 2009-12-24 00:19:36Z steveb-oss $
19   */
20  public class Lusearch extends org.dacapo.harness.Benchmark {
21    private final Object benchmark;
22  
23    public Lusearch(Config config, File scratch) throws Exception {
24      super(config, scratch, false);
25      Class<?> clazz = Class.forName("org.dacapo.lusearch.Search", true, loader);
26      this.method = clazz.getMethod("main", String[].class);
27      Constructor<?> cons = clazz.getConstructor();
28      useBenchmarkClassLoader();
29      try {
30        benchmark = cons.newInstance();
31      } finally {
32        revertClassLoader();
33      }
34    }
35  
36    @Override
37    public void iterate(String size) throws Exception {
38      method.invoke(benchmark, (Object) (config.preprocessArgs(size, scratch)));
39    }
40  }
41