当前位置: 首页 > news >正文

html5国内网站网站首页制作的过程

html5国内网站,网站首页制作的过程,做房地产网站建设,购物网站php源代码在处理大文件时#xff0c;如果利用普通的FileInputStream 或者FileOutputStream 抑或RandomAccessFile 来进行频繁的读写操作#xff0c;都将导致进程因频繁读写外存而降低速度.如下为一个对比实验。package test;import java.io.BufferedInputStream;import java.io.FileIn…在处理大文件时如果利用普通的FileInputStream 或者FileOutputStream 抑或RandomAccessFile 来进行频繁的读写操作都将导致进程因频繁读写外存而降低速度.如下为一个对比实验。package test;import java.io.BufferedInputStream;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.io.RandomAccessFile;import java.nio.MappedByteBuffer;import java.nio.channels.FileChannel;public class Test {public static void main(String[] args) {try {FileInputStream fisnew FileInputStream(/home/tobacco/test/res.txt);int sum0;int n;long t1System.currentTimeMillis();try {while((nfis.read())0){sumn;}} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}long tSystem.currentTimeMillis()-t1;System.out.println(sum:sum time:t);} catch (FileNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();}try {FileInputStream fisnew FileInputStream(/home/tobacco/test/res.txt);BufferedInputStream bisnew BufferedInputStream(fis);int sum0;int n;long t1System.currentTimeMillis();try {while((nbis.read())0){sumn;}} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}long tSystem.currentTimeMillis()-t1;System.out.println(sum:sum time:t);} catch (FileNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();}MappedByteBuffer buffernull;try {buffernew RandomAccessFile(/home/tobacco/test/res.txt,rw).getChannel().map(FileChannel.MapMode.READ_WRITE, 0, 1253244);int sum0;int n;long t1System.currentTimeMillis();for(int i0;i1253244;i){n0x000000ffbuffer.get(i);sumn;}long tSystem.currentTimeMillis()-t1;System.out.println(sum:sum time:t);} catch (FileNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}测试文件为一个大小为1253244字节的文件。测试结果sum:220152087 time:1464sum:220152087 time:72sum:220152087 time:25说明读数据无误。删去其中的数据处理部分。package test;import java.io.BufferedInputStream;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.io.RandomAccessFile;import java.nio.MappedByteBuffer;import java.nio.channels.FileChannel;public class Test {public static void main(String[] args) {try {FileInputStream fisnew FileInputStream(/home/tobacco/test/res.txt);int sum0;int n;long t1System.currentTimeMillis();try {while((nfis.read())0){//sumn;}} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}long tSystem.currentTimeMillis()-t1;System.out.println(sum:sum time:t);} catch (FileNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();}try {FileInputStream fisnew FileInputStream(/home/tobacco/test/res.txt);BufferedInputStream bisnew BufferedInputStream(fis);int sum0;int n;long t1System.currentTimeMillis();try {while((nbis.read())0){//sumn;}} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}long tSystem.currentTimeMillis()-t1;System.out.println(sum:sum time:t);} catch (FileNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();}MappedByteBuffer buffernull;try {buffernew RandomAccessFile(/home/tobacco/test/res.txt,rw).getChannel().map(FileChannel.MapMode.READ_WRITE, 0, 1253244);int sum0;int n;long t1System.currentTimeMillis();for(int i0;i1253244;i){//n0x000000ffbuffer.get(i);//sumn;}long tSystem.currentTimeMillis()-t1;System.out.println(sum:sum time:t);} catch (FileNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}测试结果sum:0 time:1458sum:0 time:67sum:0 time:8由此可见将文件部分或者全部映射到内存后进行读写速度将提高很多。这是因为内存映射文件首先将外存上的文件映射到内存中的一块连续区域被当成一个字节数组进行处理读写操作直接对内存进行操作而后再将内存区域重新映射到外存文件这就节省了中间频繁的对外存进行读写的时间大大降低了读写时间。
http://www.huolong8.cn/news/201964/

相关文章:

  • 网站背景视频服务外包
  • 宝坻手机网站建设搜题公众号怎么制作
  • qt 可以做网站吗怎么查网站的关键词
  • 青岛网站建设开发外包网店运营推广实训
  • 有什么建筑网站wordpress产品主题
  • 佛山seo代理计费百度seo如何快速排名
  • 公司网站建设空间宝塔建设网站教程
  • 网站建设与管理适合女生吗seo教学平台
  • 高师本科化学实验教学体系建设与创新型人才培养 教学成果奖申报网站1对1视频
  • 网站项目需求移动营销型网站建设
  • 维护网站律师做网站
  • 网站建设 青岛seo关键词排名优化怎么样
  • 网站推广任务 ip点击开发网址
  • 广陵区建设局网站广东宏福建设有限公司网站
  • 企业网站建设费用财务处理深圳市年年卡网络科技有限公司
  • 网站建设套餐利用百度图片做网站外链
  • 网络营销推广的劣势网站建设 猫云seo
  • 网站运营与管理的一个目的是鄂州做网站的公司
  • 全球做网站的公司排名wordpress部分图片不显示
  • 专业3合1网站建设电话怎么做音乐mp3下载网站
  • 做网站找沈阳横纵网络建设棋牌类网站要多少钱
  • 如何给网站设置关键词安徽百度关键词优化
  • 石河子做网站的公司专注咖啡相关的网站
  • 编写app的软件seo职位全称
  • 做网站广告公司网站首页设计报价多少
  • c 做网站网站对网站建设功能的情况说明
  • 做美食软件视频网站wordpress选择哪种固定连接
  • 咸阳城乡建设局网站vue做的网站有什么
  • wordpress 做购物网站网站建设翻译成英文
  • 免费个人网站域名江西龙峰建设集团的网站