Redis 安装配置
2013-12-03 15:54
351 查看
/*
需求:获取一段程序运行的代码。
原理:获取程序开和结束的时间并相减即可。
获取时间:java虚拟机中提供的system类中有这么一个方法:
System.currentTimeMillis();可获取时间.
当代码块完成优化后,就可以解决这类问题。
这种方式:模板方法设计模式。
什么是模板方法呢?
在定义功能时,功能的一部分是确定的,但是有一部分是不
确定的,而确定的部分在使用不确定的部分,这是将不确定的
部分暴漏出去,给子类去实现。
*/
abstract class GetTime
{
public final void getTime()
{
long start = System.currentTimeMillis();
runcode();
long end = System.currentTimeMillis();
System.out.println("毫秒:"+(end-start));
}
public abstract void runcode();//不确定问题
}
class SubTime extends GetTime
{
public void runcode()
{
for(int x=0;x<4000;x++)
{
System.out.print(x);
}
}
}
class TemplateDemo
{
public static void main(String[] args)
{
SubTime gt = new SubTime();
gt.getTime();
}
}
需求:获取一段程序运行的代码。
原理:获取程序开和结束的时间并相减即可。
获取时间:java虚拟机中提供的system类中有这么一个方法:
System.currentTimeMillis();可获取时间.
当代码块完成优化后,就可以解决这类问题。
这种方式:模板方法设计模式。
什么是模板方法呢?
在定义功能时,功能的一部分是确定的,但是有一部分是不
确定的,而确定的部分在使用不确定的部分,这是将不确定的
部分暴漏出去,给子类去实现。
*/
abstract class GetTime
{
public final void getTime()
{
long start = System.currentTimeMillis();
runcode();
long end = System.currentTimeMillis();
System.out.println("毫秒:"+(end-start));
}
public abstract void runcode();//不确定问题
}
class SubTime extends GetTime
{
public void runcode()
{
for(int x=0;x<4000;x++)
{
System.out.print(x);
}
}
}
class TemplateDemo
{
public static void main(String[] args)
{
SubTime gt = new SubTime();
gt.getTime();
}
}
相关文章推荐
- dump redis所有key
- NoSQL之Redis对set(集合)数据类型的操作之二
- Redis消息通知系统的实现
- NoSQL之Redis对set(集合)数据类型的操作之一
- 实现一个简单的服务端推送方案
- Redis在Windows上编译(Visual C++…
- Redis存储系统
- redis 服务的搭建与使用
- NoSQL之Redis对lists类型的操作
- Ubuntu 12.10下安装Redis(图文详解)+ Jedis连接Redis
- ubuntu12.04下redis安装/配置
- 在Windows上以服务方式运行 MSOPenTech/Redis
- Redis 起步(linux)
- Redis Desktop Manager发现病毒
- 用 Redis 实现分布式锁(分析)
- Redis实现分布式锁
- 基于keepalived的redis通信链接数测试
- NoSQL数据库 — MongoDB和Redis
- NoSQL之Redis对数据类型hash的操作
- Erlang学习:MochiWeb + ERedis