beanMapper性能测试

 
 public static void test1() throws InstantiationException, IllegalAccessException {
        BeanMapper beanMapper = BeanMappers.load();
        Map<String, Object> source = new HashMap<String, Object>();
        source.put("id", 1001l);
        long begin = System.nanoTime();
        BlogDetailDO obj = (BlogDetailDO) beanMapper.getFromMap("TA-BLOG-DETAIL", source);
        long end = System.nanoTime();
        System.out.println((end - begin) / 1000);
    }

    public static void test2() {
        long begin = System.nanoTime();
        Map<String, Object> blogCore = new HashMap<String, Object>();

        Long id = ObjectUtil.toLong(blogCore.get("_id"));
        Integer status = ObjectUtil.toInt(blogCore.get("status"));
        Long photo_id = ObjectUtil.toLong(blogCore.get("photo_id"));
        Long root_id = ObjectUtil.toLong(blogCore.get("root_id"));
        Integer is_root = id.equals(root_id) ? 1 : 0;
        Integer buyable = ObjectUtil.toInt(blogCore.get("buyable"));
        Integer photo_width = ObjectUtil.toInt(blogCore.get("photo_width"));
        Integer photo_weight = ObjectUtil.toInt(blogCore.get("photo_weight"));
        String photo_path = ObjectUtil.toString(blogCore.get("photo_path"));
        Long sender_id = ObjectUtil.toLong(blogCore.get("sender_id"));
        String sender_username = ObjectUtil.toString(blogCore.get("sender_username"));
        String sender_avatar = ObjectUtil.toString(blogCore.get("sender_avatar"));
        Integer like_count = ObjectUtil.toInt(blogCore.get("like_count"));
        Integer favorite_count = ObjectUtil.toInt(blogCore.get("favorite_count"));
        Integer reply_count = ObjectUtil.toInt(blogCore.get("reply_count"));
        String price = ObjectUtil.toString(blogCore.get("item_price"));

        BlogDetailDO obj = new BlogDetailDO();
        obj.setId(id);
        obj.setLike_count(like_count);
        obj.setStatus(status);
        obj.setPhoto_id(photo_id);
        obj.setRoot_id(root_id);
        obj.setBuyable(buyable);
        obj.setPhoto_width(photo_width);
        obj.setPhoto_height(photo_weight);
        obj.setPhoto_path(photo_path);
        obj.setSender_id(sender_id);
        obj.setSender_username(sender_username);
        obj.setSender_avatar(sender_avatar);
        obj.setFavorite_count(favorite_count);
        obj.setReply_count(reply_count);
        obj.setPrice(price);

        long end = System.nanoTime();
        System.out.println((end - begin) / 1000);

    }

    public static void test3() {
        long begin = System.nanoTime();
         "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20".split(";");
         long end = System.nanoTime();
         System.out.println((end - begin) / 1000);
    }
 

test1:
112
108
121
122

 

test2:
45
41

37
41

 

test3:

318
150
173
153

 

只要不比java string split慢就行。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值