---
title: "造了个轮子^_^，firefly应用程序框架，性能大幅超越spring3MVC和Struts2，含测试报告"
author: "hypercube1024"
date: "2011-01-03T02:27:27Z"
tags: []
categories: ["编程语言"]
slug: "firefly-spring3mvc-struts2"
draft: false
lastmod: "2011-01-03T15:25:12Z"
id: 857825
url: "https://hypercube1024.iteye.com/blog/857825"
---

现在的开源框架都是大而全，动辄xxMB的jar包，感觉用不了那么多的功能，而且性能有些不尽如人意。所以还是自己造个轮子吧。

 

firefly的特性

- 高性能，性能大幅超越spring3、struts2等，详情请看[性能测试报告](https://code.google.com/p/firefly/wiki/firefly_performance_test1)
- 精简、轻量、无侵入，firefly.jar只有44k
- core包含IOC、MVC、Interceptor等常用功能
- 使用简单，基于约定优于配置的思想，默认使用Annotation配置方式

 

firefly的使用风格类似Spring3，具体可以看

[http://code.google.com/p/firefly/wiki/guide](http://code.google.com/p/firefly/wiki/guide)

 

代码已经发布到 google code ，有兴趣的同学可以一起来开发

[http://code.google.com/p/firefly/](http://code.google.com/p/firefly/)

 

 

# 测试环境

- windows7 jdk1.6.0\_22
- JDK参数：-Xms128m -Xmx512m -XX:+DisableExplicitGC
- 服务器：jetty 6.1.25
- CPU: T6600 内存：3G
- 测试工具：JMeter

# []()用例1测试报告[¶](https://code.google.com/p/firefly/wiki/firefly_performance_test1#%E7%94%A8%E4%BE%8B1%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A)

往JSP打印“你好 firefly!”

500线程，循环2次

取跑10次之后的成绩

**框架** **版本** **吞吐量** **错误率** fireflyMVC 1.0-SNAPSHOT 38910.506/分钟 0% Servlet 2.5 38022.814/分钟 0% Spring3MVC 3.0.5.RELEASE 13106.16/分钟 0% Struts2 2.2.1.1 1256.571/分钟 0%

 

# []()用例1

往JSP打印“你好 firefly!”

## []()JSP代码

```
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
        <title>firefly</title>
</head>
<body>
        ${hello}
</body>
</html>
```

 

## []()firefly测试代码

```
        @RequestMapping(value = "/hello")
        public String index(HttpServletRequest request) {
                request.setAttribute("hello", "你好 firefly!");
                return "/index.jsp";
        }
```

 

## []()Servlet测试代码

```
        @Override
        public void doGet(HttpServletRequest request, HttpServletResponse response)
                        throws ServletException, IOException {
                request.setAttribute("hello", "你好 firefly!");
                request.getRequestDispatcher("/WEB-INF/page/index.jsp").forward(
                                request, response);
        }
```

 

## []()Spring3MVC测试代码

```
        @RequestMapping(value="/spring", method=RequestMethod.GET)
        public String index(HttpServletRequest request) {
                request.setAttribute("hello", "你好 firefly!");
                return "/index";
        }
```

 

## []()Struts2测试代码

```
    public String execute() throws Exception {
        setMessage("你好 firefly!");
        return SUCCESS;
    }
```