Disruptor笔记(二)-测试
来源:互联网 发布:创业软件招聘 编辑:程序博客网 时间:2024/06/05 20:04
- 引入Hamcrest:是一个书写匹配器对象时允许直接定义匹配规则的框架.更丰富的表达方式,不侵入代码
- 使用Jmock来做Mock库
- 使用Junit4
工具类
Util工具类提供计算容量2的n次方的方法
/**
* Calculate the next power of 2, greater than or equal to x.<p>
* From Hacker's Delight, Chapter 3, Harry S. Warren Jr.
*
* @param x Value to round up
* @return The next power of 2 from x inclusive
*/
public static int ceilingNextPowerOfTwo(final int x)
{
return 1 << (32 - Integer.numberOfLeadingZeros(x - 1));
}
顺便学习一下Integer有趣的函数:
numberOfLeadingZeros
public static int numberOfLeadingZeros(int i)
Returns the numberof zero bits preceding the highest-order ("leftmost") one-bit in thetwo's complement binary representation of the specified int value. Returns 32 if the specified value has no one-bits in its two'scomplement representation, in other words if it is equal to zero.
Note that this method is closely related to the logarithmbase 2. For all positive int values x:
· floor(log2(x))= 31 -numberOfLeadingZeros(x)
· ceil(log2(x))= 32 -numberOfLeadingZeros(x - 1)
Returns:
the number of zerobits preceding the highest-order ("leftmost") one-bit in the two'scomplement binary representation of the specified int value, or 32 ifthe value is equal to zero.
Since:
1.5
numberOfTrailingZeros
public static int numberOfTrailingZeros(int i)
Returns the numberof zero bits following the lowest-order ("rightmost") one-bit in thetwo's complement binary representation of the specified int value. Returns 32 if the specified value has no one-bits in its two'scomplement representation, in other words if it is equal to zero.
Returns:
the number of zerobits following the lowest-order ("rightmost") one-bit in the two'scomplement binary representation of the specified int value, or 32 if thevalue is equal to zero.
Since:
1.5
bitCount
public static int bitCount(int i)
Returns the numberof one-bits in the two's complement binary representation of the specified int value. This function is sometimes referred to as thepopulation count.
Returns:
the number ofone-bits in the two's complement binary representation of the specified int value.
Since:
1.5- Disruptor笔记(二)-测试
- Disruptor笔记(二)-测试
- disruptor 二
- disruptor(二)
- disruptor 笔记
- Disruptor学习总结(二):Disruptor分析
- Disruptor介绍(二)
- Disruptor笔记(五)-FAQ
- Disruptor笔记(五)-FAQ
- disruptor学习笔记
- Disruptor使用笔记
- Disruptor个人笔记(一)
- Disruptor源码阅读笔记
- disruptor实操作手册(二)
- Disruptor笔记(一)-预备知识
- Disruptor笔记(三)-处理模式
- Disruptor笔记(一)-预备知识
- Disruptor笔记(三)-处理模式
- SqlServer2008 Service Broker点对点模式应用
- Linux下block层的监控工具blktrace
- 在做带folder的form时,进入FORM出现一片空白
- POJ 1067(取石子游戏)
- java 正则表达式库
- Disruptor笔记(二)-测试
- 深入Java核心 Java 内存分配(2)_字符串的存储
- Winsock五种IO模型的性能分析
- Disruptor笔记(三)-处理模式
- ubuntu终端命令
- MySQL DISABLE/ENABLE KEYS的作用
- Disruptor笔记(四)-关键类和代码
- 2011年50款最新最酷的jQuery插件介绍和演示:第一部分
- Disruptor笔记(五)-FAQ