{
Configuration config = new Configuration();
// config.setDebugMode(false);
config.setClassicCompatible(false);
config.setClassForTemplateLoading(PerformanceTest.class, "/freemarker/testcase");
Template template = config.getTemplate("PerformanceTest.fm");
boolean toFile = args.length > 0 && args[0].equals("file");
File f = File.createTempFile("fmPerfTest", ".txt");
f.deleteOnExit();
OutputStream nullStream = new NullStream();
SimpleHash h = new SimpleHash();
h.put("ii", new TestSequence());
h.put("j", new TestHash());
h.put("k", new TestMethod());
for(;;)
{
OutputStream stream = toFile ? new BufferedOutputStream(new FileOutputStream(f)) : nullStream;
Writer writer = new OutputStreamWriter(stream, "UTF-8");
try
{
template.process(h, writer);
}
finally
{
writer.close();
}