[心缘地方]同学录
首页 | 功能说明 | 站长通知 | 最近更新 | 编码查看转换 | 代码下载 | 常见问题及讨论 | 《深入解析ASP核心技术》 | 王小鸭自动发工资条VBA版
登录系统:用户名: 密码: 如果要讨论问题,请先注册。

[备忘]ite.remove()导致的性能问题

上一篇:[备忘]pyinstaller打包python程序
下一篇:[备忘]用CryptoJS进行aes加密,用java解密,CryptoJS AES encryption and Java AES decryption

添加日期:2025/2/7 16:54:47 快速返回   返回列表 阅读78次
一个日志,100M
每行解析,然后显示。
大概需要10秒钟,
但是一旦输入过滤内容,就耗时60秒。


// 按时间过滤
Iterator<AccessLog> ite = result.iterator();
while (ite.hasNext()) {
    AccessLog row = ite.next();
    String rowTime = row.getRequestTime();
    if (rowTime == null) {
        ite.remove();
        continue;
    }
    if (beginTime.length() > 0 && rowTime.compareTo(beginTime) < 0) {
        ite.remove();
        continue;
    }


开始以为是compareTo慢,
后来打印时间差,发现是ite.remove慢

看了下result,是个ArrayList,也就是数组呗,当初随手写的,
果断改成LinkedList,变成10秒了,OK了。
 

评论 COMMENTS
没有评论 No Comments.

添加评论 Add new comment.
昵称 Name:
评论内容 Comment:
验证码(不区分大小写)
Validation Code:
(not case sensitive)
看不清?点这里换一张!(Change it here!)
 
评论由管理员查看后才能显示。the comment will be showed after it is checked by admin.
CopyRight © 心缘地方 2005-2999. All Rights Reserved