- 授权协议: BSD
- 开发语言: Java
- 操作系统: 跨平台
- 软件首页: https://tehleo.github.io/junion/
- 软件文档: https://github.com/TehLeo/junion/blob/master/README.md
- 官方下载: https://github.com/TehLeo/junion/releases
软件介绍
JUnion 用于为 Java 编程语言提供结构类型。
功能特性
结构类型
自动对齐数据
手动对齐数据
创建结构类型的数组
64 位可寻址数组
修改原生 DirectByteBuffers
检查数组下标
嵌套结构
结构引用
空引用检查
数组切割
泛型
栈分配
查看更多特性介绍 https://tehleo.github.io/junion/features.html
当创建 int 数组时,我们有两个主要选项:
int[] intArray = new int[1000]; Integer[] intBoxedArray = new Integer[1000];
那么,intArray, intBoxedArray 需要多少个字节才能存储 1000 个 int 数据?结果如下 ——
intArray 4016 bytes 4*1000 + ~16(around 16 bytes for array header) intBoxedArray 20016 bytes (4 + ~12 + ~4)*1000 + ~16 (具体数据取决于 VM)
可以看到,后者几乎是前者的 5 倍,因此我们应该偏向于选择使用原始数组 (primitive arrays)。
考虑这样一个问题
class Point { float x,y;}
Point[] arr = new Point[500];arr 占用了 14016 个字节,而数据包含了 500 个 points,每个 points 有两个浮点数,因此 4000 个字节应该足够了。
但如果 Point 是一个结构类型(struct),arr 大约只占用 4000 个字节。
使用 JUnion,可以通过 @Struct 注解标记一个类来做到这一点!
创建 struct Vec3:
@Struct
public class Vec3 {
public float x,y,z;
}然后,你可以将其用作:
//Create a new struct array Vec3[] arr = Vec3[10]; arr[5].x = 10; Vec3 v = arr[5]; ... // ByteBuffer a = ByteBuffer.allocateDirect(10*Mem.sizeOf(Vec3.class)) .order(ByteOrder.nativeOrder()); //Modify Direct Native Bytebuffer as it were a struct Vec3 arr = Mem.wrap(a); arr[5].x = 10; ...
性能测试
互联网+秋叶课堂:我的网课创业
秋叶 / 北京:机械工业出版社 / 2016-3-1 / 39.0
在线教育被很多人视为 “互联网+”创业热潮中的下一个风口,越来越多的老师和创业者选择在线教育创业。本书作者秋叶老师2013年双11正式带一帮小伙伴开始在线教育创业,在短短两年内“从0到1”,累计做到了超500万元的销售业绩,成为国内Office领域在线教育运营最成功的团队之一。在这本书中秋叶老师结合自己的实战经历,向各位完整剖析了两年创业的真实复盘思考,是一本值得在线教育创业同行入手的必读书。 ......一起来看看 《互联网+秋叶课堂:我的网课创业》 这本书的介绍吧!
