Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:一个测网络延迟和带宽的程序,发10M的数据有问题 [Re:wordby]
cxp108





发贴: 363
积分: 12
于 2006-06-23 17:06 user profilesend a private message to usersend email to cxp108search all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
What are you talking about?What are you talking about?What are you talking about?What are you talking about?What are you talking about?What are you talking about?汗啊.........................

强烈建议楼主加强J2SE的基础知识,特别是虚拟机的一些特性!


String str="0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789",sendstr=null;
for(int i=0;i<10;i++)
sendstr+=str;
sendstr+="12345678123456781234";

String realsendstr=null;
for(int k=0;k<1000;k++)
realsendstr+=sendstr;



这段程序会把你JVM的内存飞速地榨干啊!

如果你需要频繁增长你的String 请使用StringBuffer

另外,String 并不一定是 :一个字符 = 1字节 , 你这样的计算方式有明显的不妥,而且JVM组装String
也需要不少时间,这在一定程度上都会影响程序的准确率。

楼主为什么不使用传输 byte[]的方式来计算,不是更加准确么?




话题树型展开
人气 标题 作者 字数 发贴时间
6072 一个测网络延迟和带宽的程序,发10M的数据有问题 wordby 3828 2006-06-23 12:01
5083 Re:一个测网络延迟和带宽的程序,发10M的数据有问题 cxp108 565 2006-06-23 17:06
4936 Re:一个测网络延迟和带宽的程序,发10M的数据有问题 wordby 427 2006-06-25 19:36
5130 Re:一个测网络延迟和带宽的程序,发10M的数据有问题 cxp108 115 2006-06-28 09:04

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923