感觉反射调用对整个Web过程来说可以忽略不计哦,虽然和直接调用相差还是蛮大的
我机器(945主板、Celeron D 3.06、1G内存、XP系统)的测试结果:
不添加干扰方法
:797
:109
添加了干扰方法后
:812
:120
大家可以做下测试,代码如下
package example;
import java.lang.reflect.Method;
public class Methoder {
public static void main(String[] args) throws Exception {
long start = System.currentTimeMillis();
for (int i = 0; i < 100000; ++i) {
p1();
}
System.out.println(":" + (System.currentTimeMillis() - start));
start = System.currentTimeMillis();
for (int i = 0; i < 100000; ++i) {
p2();
}
System.out.println(":" + (System.currentTimeMillis() - start));
}
public static void p1() throws Exception {
Test t = new Test();
Class c = t.getClass();
Method m = c.getMethod("sayHello", new Class[0]);
m.invoke(t, new Object[0]);
}
public static void p2() throws Exception {
Test t = new Test();
t.sayHello();
}
}
class Test {
public void sayHello() {
// System.out.println("Test:");
int l = 0;
for (int i = 0; i < 1000; ++i) {
l += i;
}
}
// 以下方法为干扰用,但是两种调用方法都时间延长了点
public void sayHello1() {
}
public void sayHello2() {
}
public void sayHello3() {
}
public void sayHello4() {
}
public void sayHello5() {
}
public void sayHello6() {
}
public void sayHello7() {
}
public void sayHello8() {
}
public void sayHello9() {
}
public void sayHello10() {
}
public void sayHello11() {
}
public void sayHello12() {
}
public void sayHello13() {
}
public void sayHello14() {
}
public void sayHello15() {
}
public void sayHello16() {
}
public void sayHello17() {
}
public void sayHello18() {
}
public void sayHello19() {
}
public void sayHello20() {
}
public void sayHello21() {
}
public void sayHello22() {
}
public void sayHello23() {
}
public void sayHello24() {
}
public void sayHello25() {
}
public void sayHello26() {
}
public void sayHello27() {
}
public void sayHello28() {
}
public void sayHello29() {
}
public void sayHello30() {
}
}
分享到:
- 2008-06-19 10:40
- 浏览 1109
- 评论(4)
- 论坛回复 / 浏览 (4 / 2259)
- 查看更多
相关推荐
Web Performance in Action: Building Faster Web Pages by Jeremy Wagner English | 2017 | ISBN: 1617293776 | 376 pages | PDF The content of the web is maturing and increasing in complexity, but internet...
In Web Components in Action you'll learn to design, build, and deploy reusable Web Components from scratch. Foreword by Gray Norton. Purchase of the print book includes a free eBook in PDF, Kindle,...
在web.xml中配置action或.do,附上详细的文档
通用web层action,完美解决shiro注解权限控制,读取子类泛型
Web Performance in Action Building Faster Web Pages 英文mobi 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Web Performance in Action Building Faster Web Pages 英文无水印pdf pdf使用FoxitReader和PDF-XChangeViewer测试可以打开
对Web应用请求进行深度分析,发现不管是页面请求还是ajax请求,只要在后端Controller的Action上设置权限检查关口即可进行精准权限管控。相应的设计思路应运而生。结合反射自动生成权限列表。借助授权过程检查,自动...
web_xml中ActionServlet中的属性
Amazon Web Services in Action, Second Edition is a comprehensive introduction to computing, storing, and networking in the AWS cloud. Readers will find clear, relevant coverage of all the essential ...
Amazon Web Services in Action introduces you to computing, storing, and networking in the AWS cloud. You'll start with a broad overview of AWS and learn how to spin-up servers manually and from the ...
mvc通过反射获取action方法,适用于权限控制。
Amazon.Web.Services.in.Action.2015.9.pdf
commonweb.action
Web Performance in Action is your companion guide to making websites faster. Throughout the course of this book, you'll learn techniques that speed the delivery of your site's assets to the user, ...
我们在开发过程中经常会发生spring注入错误或失败的情况,其实Web服务器端在Action、dao、service包之内是很容易实现的,在这些包之外实现spring注入就不容易了,总是出错,其实根本原因是无法获得相应的spring上...
教你如何用ssh进行分页,从前端的jsp页面代码,到action代码,dao,daoimpl代码,service,serviceimpl,层层嵌套,层次清晰。一看就会!
Hibernate-In-Action JSTL-in-Action Spring-in-action Struts in Action WebWork In Action
Amazon Web Services in Action introduces you to computing, storing and networking in the AWS cloud. You'll start with a broad overview of AWS and learn how to spin up servers manually and from the ...
struts2对action中的所有方法进行校验