1
0
This repository has been archived on 2021-02-02. You can view files and clone it, but cannot push or open issues or pull requests.

49 lines
1.3 KiB
Java

package com.binarythought.picotemplate.example;
import com.binarythought.picotemplate.Template;
import com.binarythought.picotemplate.TemplateDictionary;
import java.io.File;
public class TemplateExample {
public static void main(String args[]) throws Exception
{
Template template = new Template(new File("res/test.html"));
TemplateDictionary dict = new TemplateDictionary();
dict.put("object1", "rifle");
dict.show("section");
TemplateDictionary d1 = dict.createChild("section");
d1.put("object2", "fighting");
TemplateDictionary d2 = dict.createChild("section");
d2.put("object2", "fun");
System.out.println("*** Parsed Template: ");
System.out.println(template.parse(dict));
long t = System.currentTimeMillis();
template.parse(dict);
System.out.println("1 Template: "+(System.currentTimeMillis()-t)+"ms");
t = System.currentTimeMillis();
for(int i=0;i < 1000; i++){
template.parse(dict);
}
System.out.println("1000 Templates: "+(System.currentTimeMillis()-t)+"ms");
t = System.currentTimeMillis();
for(int i=0;i < 10000; i++){
template.parse(dict);
}
System.out.println("10000 Templates: "+(System.currentTimeMillis()-t)+"ms");
t = System.currentTimeMillis();
for(int i=0;i < 100000; i++){
template.parse(dict);
}
System.out.println("100000 Templates: "+(System.currentTimeMillis()-t)+"ms");
}
}