Skip to content

Instantly share code, notes, and snippets.

@Fabszn
Created June 11, 2012 22:58
Show Gist options
  • Save Fabszn/2913252 to your computer and use it in GitHub Desktop.
Save Fabszn/2913252 to your computer and use it in GitHub Desktop.
public class LambdaJBenchmark implements Benchmark {
public void iterateSimpleList(final List<String> lines) {
convert(lines, new Converter<Object, Object>() {
public Object convert(Object o) {
return o;
}
});
}
}
public class JavaBenchmark implements Benchmark {
public void iterateSimpleList(final List<String> lines) {
final List<Line> l = new ArrayList<Line>();
for (String s : lines) {
StringTokenizer st = new StringTokenizer(s);
final Line line = new Line(s, st.countTokens(), 0);
l.add(line);
}
}
}
public class GuavaBenchmark implements Benchmark {
private Map<String, List<Long>> context = Maps.newHashMap();
public void iterateSimpleList(final List<String> lines) {
List<Line> l = Lists.transform(lines, new Function<String, Line>() {
public Line apply(@Nullable String s) {
System.out.println(s);
StringTokenizer st = new StringTokenizer(s);
final Line line = new Line(s, st.countTokens(), 0);
return line;
}
});
}
}
public interface Benchmark {
public void iterateSimpleList(final List<String> lines);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment