Created
November 12, 2012 10:22
-
-
Save jawher/4058518 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ThymeleafBenchmark implements Benchmark { | |
private Context context; | |
private TemplateEngine engine; | |
public ThymeleafBenchmark(Collection<Todo> todos) { | |
engine = new TemplateEngine(); | |
final ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver(); | |
templateResolver.setPrefix("templating/clash/thymeleaf/"); | |
templateResolver.setCacheable(true); | |
engine.setTemplateResolver(templateResolver); | |
StandardCacheManager cache = new StandardCacheManager(); | |
cache.setTemplateCacheMaxSize(10); | |
cache.setFragmentCacheMaxSize(10); | |
context = new Context(); | |
context.setVariable("todos", todos); | |
context.setVariable("page", "list.html"); | |
context.setVariable("fragment", "list"); | |
run(1); | |
} | |
@Override | |
public void run(int reps) { | |
final DevNull out = new DevNull(); | |
for (int i = 0; i < reps; i++) { | |
try { | |
engine.process("base.html", context, out); | |
} catch (Exception e) { | |
throw new RuntimeException(e); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment