首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

sitemesh性能测试结果比较惊艳(已经补下新的对比测试结果)

2012-10-10 
sitemesh性能测试结果比较惊艳(已经补上新的对比测试结果)最近想在一个项目中使用sitemesh作为view层的装

sitemesh性能测试结果比较惊艳(已经补上新的对比测试结果)
最近想在一个项目中使用sitemesh作为view层的装饰器,于是今天就做了一下sitemesh的性能测试。
由于只是测试view层的性能,所以系统框架只有了spring mvc3(3.0.3)+freemarker(2.3.16)+sitemesh(2.4.2)
servlet容器:jetty-6.1.21
jdk:1.6.0_17-b04
压力测试工具:loadRunner 8.1
应用服务器配置:8cup    Intel(R) Xeon(R) CPU   E5410  @ 2.33GHz;   内存:4G
测试代码:

@Controllerpublic class TestController {@RequestMapping(value="/hello", method=RequestMethod.GET)public void sayHello(Model model){model.addAttribute("timestamp",new Long(System.currentTimeMillis()));}}

freemaker代码
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /><meta http-equiv="Cache-Control" content="no-store"/><meta http-equiv="Pragma" content="no-cache"/><meta http-equiv="Expires" content="0"/></head><title>freemarker title</title><body><#list 1..100 as r><#list 1..1000 as xx><h5>${timestamp%xx}</h5></#list></#list></body></html>

sitemesh相关配置:
web.xml:<filter>    <filter-name>sitemesh</filter-name>    <filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class></filter><filter-mapping>    <filter-name>sitemesh</filter-name>    <url-pattern>/*</url-pattern></filter-mapping>decorators.xml<decorators defaultdir="/decorators">    <!-- Any urls that are excluded will never be decorated by Sitemesh -->    <excludes>        <pattern>/exclude.jsp</pattern>        <pattern>/exclude/*</pattern>    </excludes>    <decorator name="main" page="main.jsp">        <pattern>/*</pattern>    </decorator></decorators>

装饰器页面main.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%><%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %><%@ taglib uri="http://www.opensymphony.com/sitemesh/page" prefix="page" %><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title><decorator:title default="Mysterious page..." /></title><decorator:head /></head><body><h1>header</h1> <decorator:body /><h1>footer</h1></body></html>

30用户并发访问上面页面,jetty启动时没有使用任何jvm优化参数
不使用sitemesh时的测试结果

Visualvm的监控截图

使用sitemesh时的测试结果

Visualvm的监控截图


从上面这些测试结果来看sitemesh对页面平均响应时间的影响还是比较小的,这个影响我觉得基本可以接受。
但是从Visualvm的监控结果让我非常的惊讶,使用sitemesh以后使得jvm的内存使用剧增,是未使用之前的10倍之多,与此同时cpu的使用率也是原来的3-4倍,由于内存使用量的剧增导致jvm的GC也频繁了许多。


新做的一轮测试,供大家参考
参考 rapid-framework的继承实现方式得到的测试结果



参考老外搞的freemarker layouthttp://richardbarabe.wordpress.com/2009/03/19/freemarker-a-brief-example/ 实现方式得到的测试结果



从上面这一轮测试可以看出来这两种方案的实现效果在页面响应时间上差不多,基本没有区别。内存波动也大致相同,唯一差别较大的是,使用rapid测试的场景cpu的使用率波动较频繁,而使用宏实现的装饰器cpu波动较少,CPU使用率相对较低。
此外使用rapid的场景中线程数的波动图较其他几个场景的波动要明显,不过在测试的时候我没有注意到这个情况,所以目前还不知道线程数量增多的原因。我怀疑是在这个场景下由于请求处理的稍微慢一些,导致VVM统计的活动线程数要高于其他场景。
希望以上这些测试结果对大家有参考意义。
 

热点排行