@@ -0,0 +1,3083 @@
+package org.mixer2.xhtml;%0A%0Aimport java.io.File;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0Aimport org.apache.commons.lang.builder.ReflectionToStringBuilder;%0Aimport org.apache.commons.lang.builder.ToStringBuilder;%0Aimport org.apache.commons.lang.builder.ToStringStyle;%0Aimport org.apache.commons.lang.time.StopWatch;%0Aimport org.junit.Before;%0Aimport org.junit.BeforeClass;%0Aimport org.junit.Test;%0Aimport org.mixer2.Mixer2Engine;%0Aimport org.mixer2.jaxb.xhtml.Html;%0Aimport org.mixer2.util.CastUtil;%0A%0Apublic class ToStringPerformanceTest %7B%0A%0A    private String templateFileName = %22sample-xhtml1-transitional.html%22;%0A    private String templateFilePath;%0A    private static Mixer2Engine m2e = Mixer2EngineSingleton.getInstance();%0A%0A    private int loop = 1000;%0A%0A    @BeforeClass%0A    public static void beforeClass() %7B%0A    %7D%0A%0A    @Before%0A    public void before() %7B%0A        templateFilePath = getClass().getResource(templateFileName).toString();%0A        String osname = System.getProperty(%22os.name%22);%0A        if(osname.indexOf(%22Windows%22)%3E=0)%7B%0A            templateFilePath = templateFilePath.replaceFirst(%22file:/%22, %22%22);%0A        %7D else %7B%0A            templateFilePath = templateFilePath.replaceFirst(%22file:%22, %22%22);%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void loopToString() throws Exception %7B%0A        Html html = m2e.loadHtmlTemplate(new File(templateFilePath));%0A        StopWatch stopWatch = new StopWatch();%0A        stopWatch.start();%0A        for (int i=0; i%3Cloop; i++) %7B%0A            html.toString();%0A        %7D%0A        stopWatch.stop();%0A        System.out.println(%22   normal toString(): loop= %22 + loop + %22, time(msec)= %22 + stopWatch.getTime());%0A    %7D%0A%0A    @Test%0A    public void loopToStringByReflectionToStringBuilder() throws Exception %7B%0A        Html html = m2e.loadHtmlTemplate(new File(templateFilePath));%0A        StopWatch stopWatch = new StopWatch();%0A        stopWatch.start();%0A        for (int i=0; i%3Cloop; i++) %7B%0A            toStringByReflectionToStringBuilder(html);%0A        %7D%0A        stopWatch.stop();%0A        System.out.println(%22ReflectionToString(): loop= %22 + loop + %22, time(msec)= %22 + stopWatch.getTime());%0A    %7D%0A%0A    private String toStringByReflectionToStringBuilder(Object bean) %7B%0A        return (new ReflectionToStringBuilder(bean,%0A                ToStringStyle.MULTI_LINE_STYLE) %7B%0A            public ToStringBuilder append(String fieldName, Object obj) %7B%0A                if (obj != null) %7B%0A                    if (obj instanceof List%3C?%3E) %7B%0A                        List%3C?%3E list = CastUtil.cast(obj);%0A                        if (0 %3C list.size()) %7B%0A                            super.append(fieldName, obj);%0A                        %7D%0A                    %7D else if (obj instanceof Map%3C?, ?%3E) %7B%0A                        Map%3C?, ?%3E map = CastUtil.cast(obj);%0A                        if (0 %3C map.size()) %7B%0A                            super.append(fieldName, obj);%0A                        %7D%0A                    %7D else %7B%0A                        super.append(fieldName, obj);%0A                    %7D%0A                %7D%0A                return this;%0A            %7D%0A        %7D).toString();%0A    %7D%0A    %0A%7D%0A

add performance test